bncs

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2018 License: MPL-2.0 Imports: 9 Imported by: 14

Documentation

Overview

Package bncs implements the old Battle.net chat protocol for Warcraft III. The protocol is used for multiple classic games, but this package only implements the small set of packets required for Warcraft III to log on and enter chat.

Based on protocol documentation by https://bnetdocs.org/

Each packet type is mapped to a struct type that implements the Packet interface. To deserialize from a binary stream, use DeserializePacket().

This package tries to keep ammortized heap memory allocations to 0.

General serialization format:

(UINT8)  Protocol signature (0xFF)
(UINT8)  Packet type ID
(UINT16) Packet size
[Packet Data]

Index

Constants

View Source
const (
	PidNull                   = 0x00 // C -> S | S -> C
	PidStopAdv                = 0x02 // C -> S |
	PidGetAdvListEx           = 0x09 // C -> S | S -> C
	PidEnterChat              = 0x0A // C -> S | S -> C
	PidJoinChannel            = 0x0C // C -> S |
	PidChatCommand            = 0x0E // C -> S |
	PidChatEvent              = 0x0F //        | S -> C
	PidFloodDetected          = 0x13 //        | S -> C
	PidMessageBox             = 0x19 //        | S -> C
	PidStartAdvex3            = 0x1C // C -> S | S -> C
	PidNotifyJoin             = 0x22 // C -> S |
	PidPing                   = 0x25 // C -> S | S -> C
	PidNetGamePort            = 0x45 // C -> S |
	PidAuthInfo               = 0x50 // C -> S | S -> C
	PidAuthCheck              = 0x51 // C -> S | S -> C
	PidAuthAccountCreate      = 0x52 // C -> S | S -> C
	PidAuthAccountLogon       = 0x53 // C -> S | S -> C
	PidAuthAccountLogonProof  = 0x54 // C -> S | S -> C
	PidAuthAccountChange      = 0x55 // C -> S | S -> C
	PidAuthAccountChangeProof = 0x56 // C -> S | S -> C
	PidSetEmail               = 0x59 // C -> S |
	PidClanInfo               = 0x75 //        | S -> C
)

BNCS packet type identifiers

View Source
const ProtocolGreeting = 0x01

ProtocolGreeting is the BNCS magic number first sent by the client when initiating a connection.

View Source
const ProtocolSig = 0xFF

ProtocolSig is the BNCS magic number used in the packet header.

Variables

View Source
var (
	ErrNoProtocolSig     = errors.New("bncs: Invalid bncs packet (no signature found)")
	ErrInvalidPacketSize = errors.New("bncs: Invalid packet size")
	ErrInvalidChecksum   = errors.New("bncs: Checksum invalid")
	ErrUnexpectedConst   = errors.New("bncs: Unexpected constant value")
	ErrBufferTooSmall    = errors.New("bncs: Packet exceeds buffer size")
)

Errors

Functions

func ReadPacket

func ReadPacket(r io.Reader, b *DeserializationBuffer) ([]byte, int, error)

ReadPacket reads exactly one packet from r and returns it in the proper (deserialized) packet type.

func ReadPacketWithBuffer

func ReadPacketWithBuffer(r io.Reader, b *DeserializationBuffer) ([]byte, int, error)

ReadPacketWithBuffer reads exactly one packet from r and returns its raw bytes.

func SerializePacket

func SerializePacket(w io.Writer, p Packet) (int, error)

SerializePacket serializes p and writes it to w.

func SerializePacketWithBuffer

func SerializePacketWithBuffer(w io.Writer, b *SerializationBuffer, p Packet) (int, error)

SerializePacketWithBuffer serializes p and writes it to w.

Types

type AccountCreateResult

type AccountCreateResult uint32

AccountCreateResult enum

const (
	AccountCreateSuccess        AccountCreateResult = 0x00 // Successfully created account name.
	AccountCreateNameExists     AccountCreateResult = 0x04 // Name already exists.
	AccountCreateNameTooShort   AccountCreateResult = 0x07 // Name is too short/blank.
	AccountCreateIllegalChar    AccountCreateResult = 0x08 // Name contains an illegal character.
	AccountCreateBlacklist      AccountCreateResult = 0x09 // Name contains an illegal word.
	AccountCreateTooFewAlphaNum AccountCreateResult = 0x0A // Name contains too few alphanumeric characters.
	AccountCreateAdjacentPunct  AccountCreateResult = 0x0B // Name contains adjacent punctuation characters.
	AccountCreateTooManyPunct   AccountCreateResult = 0x0C // Name contains too many punctuation characters.
)

AuthAccountCreate result

func (AccountCreateResult) String

func (r AccountCreateResult) String() string

type AdvListResult

type AdvListResult uint32

AdvListResult enum

const (
	AdvListSuccess           AdvListResult = 0x00 // OK
	AdvListNotFound          AdvListResult = 0x01 // Game doesn't exist
	AdvListIncorrectPassword AdvListResult = 0x02 // Incorrect password
	AdvListFull              AdvListResult = 0x03 // Game full
	AdvListStarted           AdvListResult = 0x04 // Game already started
	AdvListCDKeyNotAllowed   AdvListResult = 0x05 // Spawned CD-Key not allowed
	AdvListRequestRate       AdvListResult = 0x06 // Too many server requests
)

Game status

func (AdvListResult) String

func (s AdvListResult) String() string

type AuthAccountChangePassProofReq added in v1.2.0

type AuthAccountChangePassProofReq struct {
	ClientPasswordProof [20]byte
	NewSalt             [32]byte
	NewVerifier         [32]byte
}

AuthAccountChangePassProofReq implements the [0x56] SID_AUTH_ACCOUNTCHANGEPROOF packet (C -> S).

This message is sent after receiving a successful SID_AUTH_ACCOUNTCHANGE message, and contains the proof for the client's new password.

Format:

(UINT8)[20] Old password proof
(UINT8)[32] New password's salt (s)
(UINT8)[32] New password's verifier (v)

func (*AuthAccountChangePassProofReq) Deserialize added in v1.2.0

func (pkt *AuthAccountChangePassProofReq) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthAccountChangePassProofReq) Serialize added in v1.2.0

func (pkt *AuthAccountChangePassProofReq) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthAccountChangePassProofResp added in v1.2.0

type AuthAccountChangePassProofResp struct {
	AuthAccountLogonProofResp
}

AuthAccountChangePassProofResp implements the [0x56] SID_AUTH_ACCOUNTCHANGEPROOF packet (S -> C).

This message reports success or failure for a password change operation.

Status:

0x00: Password changed
0x02: Incorrect old password

Format:

(UINT32)     Status code
 (UINT8)[20] Server password proof for old password (M2)

func (*AuthAccountChangePassProofResp) Serialize added in v1.2.0

func (pkt *AuthAccountChangePassProofResp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthAccountChangePassReq added in v1.2.0

type AuthAccountChangePassReq struct {
	AuthAccountLogonReq
}

AuthAccountChangePassReq implements the [0x55] SID_AUTH_ACCOUNTCHANGE packet (C -> S).

This message is used to change the client's password.

Format:

 (UINT8)[32] Client key (A)
(STRING)     Username

func (*AuthAccountChangePassReq) Serialize added in v1.2.0

func (pkt *AuthAccountChangePassReq) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthAccountChangePassResp added in v1.2.0

type AuthAccountChangePassResp struct {
	AuthAccountLogonResp
}

AuthAccountChangePassResp implements the [0x55] SID_AUTH_ACCOUNTCHANGE packet (S -> C).

Reports success or failure on a password change operation. If an error occurs, the salt and server key values are set to zero.

Status:

0x00: Change accepted, requires proof.
0x01: Account doesn't exist.
0x05: Account requires upgrade.
Other: Unknown (failure).

Format:

(UINT32)     Status
 (UINT8)[32] Salt (s)
 (UINT8)[32] Server key (B)

func (*AuthAccountChangePassResp) Serialize added in v1.2.0

func (pkt *AuthAccountChangePassResp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthAccountCreateReq

type AuthAccountCreateReq struct {
	Salt     [32]byte
	Verifier [32]byte
	Username string
}

AuthAccountCreateReq implements the [0x52] SID_AUTH_ACCOUNTCREATE packet (C -> S).

This message is sent to create an NLS-style account. It contains the client's salt and verifier values, which are saved by the server for use with future logons.

Format:

 (UINT8)[32] Salt (s)
 (UINT8)[32] Verifier (v)
(STRING)     Username

func (*AuthAccountCreateReq) Deserialize

func (pkt *AuthAccountCreateReq) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthAccountCreateReq) Serialize

func (pkt *AuthAccountCreateReq) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthAccountCreateResp

type AuthAccountCreateResp struct {
	Result AccountCreateResult
}

AuthAccountCreateResp implements the [0x52] SID_AUTH_ACCOUNTCREATE packet (S -> C).

The message reports the success or failure of an account creation attempt.

Possible status codes:

0x00: Successfully created account name.
0x04: Name already exists.
0x07: Name is too short/blank.
0x08: Name contains an illegal character.
0x09: Name contains an illegal word.
0x0a: Name contains too few alphanumeric characters.
0x0b: Name contains adjacent punctuation characters.
0x0c: Name contains too many punctuation characters.
Any other: Name already exists.

Format:

(UINT32)  Status

func (*AuthAccountCreateResp) Deserialize

func (pkt *AuthAccountCreateResp) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthAccountCreateResp) Serialize

func (pkt *AuthAccountCreateResp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthAccountLogonProofReq

type AuthAccountLogonProofReq struct {
	ClientPasswordProof [20]byte
}

AuthAccountLogonProofReq implements the [0x54] SID_AUTH_ACCOUNTLOGONPROOF packet (C -> S).

This message is sent to the server after a successful SID_AUTH_ACCOUNTLOGON. It contains the client's password proof.

Format:

(UINT8)[20] Client Password Proof (M1)

func (*AuthAccountLogonProofReq) Deserialize

func (pkt *AuthAccountLogonProofReq) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthAccountLogonProofReq) Serialize

func (pkt *AuthAccountLogonProofReq) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthAccountLogonProofResp

type AuthAccountLogonProofResp struct {
	Result                LogonProofResult
	ServerPasswordProof   [20]byte
	AdditionalInformation string
}

AuthAccountLogonProofResp implements the [0x54] SID_AUTH_ACCOUNTLOGONPROOF packet (S -> C).

Status:

0x00: Logon successful.
0x02: Incorrect password.
0x06: Account closed.
0x0E: An email address should be registered for this account.
0x0F: Custom error. A string at the end of this message contains the error.

This message confirms the validity of the client password proof and supplies the server password proof.

Format:

(UINT32)     Status
 (UINT8)[20] Server Password Proof (M2)
(STRING)     Additional information

func (*AuthAccountLogonProofResp) Deserialize

func (pkt *AuthAccountLogonProofResp) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthAccountLogonProofResp) Serialize

func (pkt *AuthAccountLogonProofResp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthAccountLogonReq

type AuthAccountLogonReq struct {
	ClientKey [32]byte
	Username  string
}

AuthAccountLogonReq implements the [0x53] SID_AUTH_ACCOUNTLOGON packet (C -> S).

This message is sent to the server to initiate a logon. It consists of the client's public key and their Username.

The client's public key is a value calculated by the client and used for a single logon.

Format:

 (UINT8)[32] Client Key (A)
(STRING)     Username

func (*AuthAccountLogonReq) Deserialize

func (pkt *AuthAccountLogonReq) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthAccountLogonReq) Serialize

func (pkt *AuthAccountLogonReq) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthAccountLogonResp

type AuthAccountLogonResp struct {
	Result    LogonResult
	Salt      [32]byte
	ServerKey [32]byte
}

AuthAccountLogonResp implements the [0x53] SID_AUTH_ACCOUNTLOGON packet (S -> C).

Reports the success or failure of the logon request.

Possible status codes:

0x00: Logon accepted, requires proof.
0x01: Account doesn't exist.
0x05: Account requires upgrade.
Other: Unknown (failure).

Format:

(UINT32)     Status
 (UINT8)[32] Salt (s)
 (UINT8)[32] Server Key (B)

func (*AuthAccountLogonResp) Deserialize

func (pkt *AuthAccountLogonResp) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthAccountLogonResp) Serialize

func (pkt *AuthAccountLogonResp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthCheckReq

type AuthCheckReq struct {
	ClientToken    uint32
	ExeVersion     uint32
	ExeHash        uint32
	CDKeys         []CDKey
	ExeInformation string
	KeyOwnerName   string
}

AuthCheckReq implements the [0x51] SID_AUTH_CHECK packet (C -> S).

Contains the EXE Version and Hash as reported by `CheckRevision() and CDKey values.

The data that should be hashed for `Hashed Key Data` is:

* For 13/16 character keys (hashed using BSHA1):

  1. (UINT32) Client Token
  2. (UINT32) Server Token
  3. (UINT32) Key Product value (from decoded CD key)
  4. (UINT32) Key Public value (from decoded CD key)
  5. (UINT32) 0
  6. (UINT32) Key Private value (from decoded CD key)

* For 26 character keys (hashed using standard SHA1):

  1. (UINT32) Client Token
  2. (UINT32) Server Token
  3. (UINT32) Key Product value (from decoded CD key)
  4. (UINT32) Key Public value (from decoded CD key)
  5. (UINT8)[10] Key Private value (from decoded CD key)

The data that should be used for EXE Information should be separated by one space, in the format of: 1. EXE Name (ex. `war3.exe`) 2. Last Modified Date (ex. `08/16/09`) 3. Last Modified Time (ex. `19:21:59`) 4. Filesize in bytes (ex. `471040`)

An example of a valid string would be: `war3.exe 08/16/09 19:21:59 471040`

The CD Key owner name must be no greater than 15 characters, otherwise it becomes trimmed by Battle.net.

Spawn value can only be TRUE for STAR, JSTR, and W2BN. Any other game will cause unexpected results.

Format:

(UINT32) Client Token
(UINT32) EXE Version
(UINT32) EXE Hash
(UINT32) Number of CD-keys in this packet
(UINT32) Spawn Key (1 is TRUE, 0 is FALSE)

For each Key:
   (UINT32)     Key length
   (UINT32)     Key Product value
   (UINT32)     Key Public value
   (UINT32)     Unknown (0)
    (UINT8)[20] Hashed Key Data

(STRING) EXE Information
(STRING) Key owner name

func (*AuthCheckReq) Deserialize

func (pkt *AuthCheckReq) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthCheckReq) Serialize

func (pkt *AuthCheckReq) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthCheckResp

type AuthCheckResp struct {
	Result                AuthResult
	AdditionalInformation string
}

AuthCheckResp implements the [0x51] SID_AUTH_CHECK packet (S -> C).

Reports success or failure on the game key and version check.

Result:

0x000: Passed challenge
0x100: Old game version (Additional info field supplies patch MPQ filename)
0x101: Invalid version
0x102: Game version must be downgraded (Additional info field supplies patch MPQ filename)
0x0NN: (where NN is the version code supplied in SID_AUTH_INFO): Invalid version code (note that 0x100 is not set in this case).
0x200: Invalid CD key (If you receive this status, official Battle.net servers will IP ban you for 1 to 14 days. Before June 15, 2011, this used to exclusively be 14 days)
0x201: CD key in use (Additional info field supplies name of user)
0x202: Banned key
0x203: Wrong product

The last 4 codes also apply to the second CDKey, as indicated by a bitwise combination with `0x010`.

If a patch file cannot be found, additional info is set to 'non-existent'. If either the executable size/date or the version code is wrong, the server will typically return a failure status.

If the spawn flag was set to true in the client's request, and there is already a spawned key online, the result will be `0x201` with additional info set to `TOO MANY SPAWNS`.

Format:

(UINT32) Result
(STRING) Additional Information

func (*AuthCheckResp) Deserialize

func (pkt *AuthCheckResp) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthCheckResp) Serialize

func (pkt *AuthCheckResp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthInfoReq

type AuthInfoReq struct {
	PlatformCode        protocol.DWordString
	GameVersion         w3gs.GameVersion
	LanguageCode        protocol.DWordString
	LocalIP             net.IP
	TimeZoneBias        uint32
	MpqLocaleID         uint32
	UserLanguageID      uint32
	CountryAbbreviation string
	Country             string
}

AuthInfoReq implements the [0x50] SID_AUTH_INFO packet (C -> S).

Sends information about the client's product and locale to Battle.net.

Field descriptions:

Protocol ID: Battle.net's current Protocol ID is `0x00`. This field has only been seen with a value of `0x00`.
Platform code: Identifies the client's platform value.
Product code: Identifies the client's product value.
Version byte: Identifies the client's version number.
Language code: Identifies the client's language value.
Local IP: This is the local network IP of the client, in network byte (big-endian) order, for NAT compatibility. Can safely be set to `0.0.0.0`.
Timezone bias: Retrieve using [TIME_ZONE_INFORMATION](https://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx) structure returned from [GetTimeZoneInformation()](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724421(v=vs.85).aspx)
    Depending on whether the return value is `TIME_ZONE_ID_STANDARD` or `TIME_ZONE_ID_DAYLINE`, add `TZI.Bias + TZI.StandardBias` or `TZI.Bias + TZI.DaylightBias` to get the bias in minutes, where `TZI` is the returned `TIME_ZONE_INFORMATION` structure.
    Alternatively, you may use [GetSystemTime()](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724390(v=vs.85).aspx), [GetLocalTime()](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724338(v=vs.85).aspx), and [SystemTimeToFileTime()](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724948(v=vs.85).aspx): convert both system and local time to FILETIMEs, subtract local time from system time, and divide by 600,000,000 to get the bias in minutes.
MPQ locale ID: This field is part of Blizzard's multi-lingual MPQ system and is used to specify which version of an MPQ should be used when the MPQ is available in multiple languages. Can safely be set to `0x00`, but you may also use something like  [GetUserDefaultLCID()](https://msdn.microsoft.com/en-us/library/windows/desktop/dd318135(v=vs.85).aspx).
User language ID: Can be retrieved with [GetUserDefaultLangID()](https://msdn.microsoft.com/en-us/library/windows/desktop/dd318134(v=vs.85).aspx)
Abbreviated country name and country name: Can be retrived with [GetLocaleInfo()](https://msdn.microsoft.com/en-us/library/windows/desktop/dd318101(v=vs.85).aspx) with LCType set to `LOCALE_SABBREVCTRYNAME` (three-letter code) and `LOCALE_SENGLISHCOUNTRYNAME` (English country name) respectively.

Format:

(UINT32) Protocol ID
(UINT32) Platform code
(UINT32) Product code
(UINT32) Version byte
(UINT32) Language code
(UINT32) Local IP
(UINT32) Time zone bias
(UINT32) MPQ locale ID
(UINT32) User language ID
(STRING) Country abbreviation
(STRING) Country

func (*AuthInfoReq) Deserialize

func (pkt *AuthInfoReq) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthInfoReq) Serialize

func (pkt *AuthInfoReq) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthInfoResp

type AuthInfoResp struct {
	ServerToken     uint32
	Unknown1        uint32
	MpqFileTime     uint64
	MpqFileName     string
	ValueString     string
	ServerSignature [128]byte
}

AuthInfoResp implements the [0x50] SID_AUTH_INFO packet (S -> C).

Contains the Server Token, and the values used in CheckRevision.

Possible Logon type values:

`0x00`: Broken SHA-1 (STAR/SEXP/D2DV/D2XP)
`0x01`: NLS version 1 (War3Beta)
`0x02`: NLS Version 2 (WAR3/W3XP)

UDP value: No one really knows what this is, however, it is used in 2nd UINT32 of the UDP packet PKT_CONNTEST2. It is also the second part of MCP Chunk 1 in MCP_STARTUP.

128-byte Server signature: This field is used by Warcraft III to verify that the server its connected to is an official Blizzard server. More info available at http://liquipedia.net/starcraft/Blizzard_Weak_Digital_Signature.

Format:

  (UINT32) Logon type
  (UINT32) Server token
  (UINT32) UDP value
(FILETIME) MPQ int64
  (STRING) MPQ filename
  (STRING) ValueString

WAR3/W3XP Only:
   (UINT8)[128] Server signature

func (*AuthInfoResp) Deserialize

func (pkt *AuthInfoResp) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*AuthInfoResp) Serialize

func (pkt *AuthInfoResp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type AuthResult

type AuthResult uint32

AuthResult enum

const (
	AuthSuccess            AuthResult = 0x000 // Passed challenge
	AuthUpgradeRequired    AuthResult = 0x100 // Old game version (Additional info field supplies patch MPQ filename)
	AuthInvalidVersion     AuthResult = 0x101 // Invalid version
	AuthInvalidVersionMask AuthResult = 0x0FF // Invalid version (error code correlates to exact version)
	AuthDowngradeRequired  AuthResult = 0x102 // Game version must be downgraded (Additional info field supplies patch MPQ filename)
	AuthCDKeyInvalid       AuthResult = 0x200 // Invalid CD key (If you receive this status, official Battle.net servers will IP ban you for 1 to 14 days. Before June 15, 2011, this used to exclusively be 14 days)
	AuthCDKeyInUse         AuthResult = 0x201 // CD key in use (Additional info field supplies name of user)
	AuthCDKeyBanned        AuthResult = 0x202 // Banned key
	AuthWrongProduct       AuthResult = 0x203 // Wrong product
)

AuthCheck result

func (AuthResult) String

func (r AuthResult) String() string

type CDKey

type CDKey struct {
	KeyLength       uint32
	KeyProductValue uint32
	KeyPublicValue  uint32
	HashedKeyData   [20]byte
}

CDKey stores the CD key information.

Format:
  (UINT32)     Key length
  (UINT32)     Key Product value
  (UINT32)     Key Public value
  (UINT32)     Unknown (0)
   (UINT8)[20] Hashed Key Data

type ChatChannelFlags

type ChatChannelFlags uint32

ChatChannelFlags enum

const (
	ChatChannelFlagPublic      ChatChannelFlags = 0x00001 // Public Channel
	ChatChannelFlagModerated   ChatChannelFlags = 0x00002 // Moderated
	ChatChannelFlagRestricted  ChatChannelFlags = 0x00004 // Restricted
	ChatChannelFlagSilent      ChatChannelFlags = 0x00008 // Silent
	ChatChannelFlagSystem      ChatChannelFlags = 0x00010 // System
	ChatChannelFlagProduct     ChatChannelFlags = 0x00020 // Product-Specific
	ChatChannelFlagGlobal      ChatChannelFlags = 0x01000 // Globally Accessible
	ChatChannelFlagRedirected  ChatChannelFlags = 0x04000 // Redirected
	ChatChannelFlagChat        ChatChannelFlags = 0x08000 // Chat
	ChatChannelFlagTechSupport ChatChannelFlags = 0x10000 // Tech Support
)

ChatChannel Flags

func (ChatChannelFlags) String

func (f ChatChannelFlags) String() string

type ChatCommand

type ChatCommand struct {
	Text string
}

ChatCommand implements the [0x0E] SID_ChatCommand packet (C -> S).

Send text or a command to Battle.net using this packet.

For STAR/SEXP/SSHR/JSTR, Text is UTF-8 encoded (WIDESTRING).

It is generally accepted as unwise to send any character below a space (0x20): this includes line feeds, carriage returns & control characters. The maximum number of characters is 224 per message including the null-terminator (so really only 223 characters), any longer and it becomes trimmed by Battle.net.

If you send a line feed and/or a carriage return, Battle.net disconnects you and IP bans you for 5 minutes.

Format:

(STRING) Text

func (*ChatCommand) Deserialize

func (pkt *ChatCommand) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*ChatCommand) Serialize

func (pkt *ChatCommand) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type ChatEvent

type ChatEvent struct {
	Type         ChatEventType
	UserFlags    ChatUserFlags
	ChannelFlags ChatChannelFlags
	Ping         uint32
	Username     string
	Text         string
}

ChatEvent implements the [0x0F] SID_ChatEvent packet (S -> C).

Contains all chat events.

Text: For STAR/SEXP/SSHR/JSTR, this field is UTF-8 encoded. For all other clients, it is ISO 8859-1 encoded. It must also be no longer than 255 characters; official clients should only be able to send 224 characters (including the null-terminator).

Event IDs:

0x01 EID_SHOWUSER: User in channel
0x02 EID_JOIN: User joined channel
0x03 EID_LEAVE: User left channel
0x04 EID_WHISPER: Recieved whisper
0x05 EID_TALK: Chat text
0x06 EID_BROADCAST: Server broadcast
0x07 EID_CHANNEL: Channel information
0x09 EID_USERFLAGS: Flags update
0x0A EID_WHISPERSENT: Sent whisper
0x0D EID_CHANNELFULL: Channel full
0x0E EID_CHANNELDOESNOTEXIST: Channel doesn't exist
0x0F EID_CHANNELRESTRICTED: Channel is restricted
0x12 EID_INFO: Information
0x13 EID_ERROR: Error message
0x15 EID_IGNORE: Notifies that a user has been ignored (DEFUNCT)
0x16 EID_ACCEPT: Notifies that a user has been unignored (DEFUNCT)
0x17 EID_EMOTE: Emote

EID_SHOWUSER:

This is sent for each user who is already in a channel when you join it, as opposed to EID_JOIN, which is sent when a user joins a channel you have already joined. It is also sent when logged on using D2XP/D2DV and a user requires an update to their statstring - for example, by logging a different character onto a realm.

EID_JOIN:

This is sent when a user enters the channel you are currently in.

EID_LEAVE:

This is sent when a user exits the channel you are currently in.

EID_WHISPER:

This is sent when a user whispers you.

EID_TALK:

This is sent when a user (excluding self) in chat speaks.

EID_BROADCAST:

This is sent when a server announcement is being made globally.
The username supplied for this event is now always `Battle.net`. Historically, the username was the name of the Battle.net Administrator who sent the broadcast.

EID_CHANNEL:

The flags field for this event is used and indicates what special conditions exist for the channel in question.

EID_USERFLAGS:

This is sent to inform the client of an update to one or more user's flags.
Battle.net usually sends this event for every user in the channel, even if only one user's flags have changed. This behavior can be exploited to detect invisible users, by performing an action (such as an unsquelch) to provoke a flags update. Users included in the flags update whose presence has not been indicated by `EID_JOIN` or `EID_SHOWUSER` can then be added to the userlist as invisible. Care should be taken, however, to account for the possibility that an asynchronous send error has occurred. Should an `EID_JOIN` or `EID_SHOWUSER` event occur for an invisible user, they should be marked as a normal user, not readded to the userlist.

EID_WHISPERSENT:

The Flags and Ping fields in this packet is equal to the originating user - the one who sent the whisper. In other words, `EID_WHISPERSENT` contains your flags & ping, not those of the person you whispered.

EID_CHANNELDOESNOTEXIST:

See info on `NoCreate Join` in SID_JoinChannel.

EID_CHANNELRESTRICTED:

This is sent when attempting to join a channel which your client is not allowed to join.

EID_INFO:

This is information supplied by Battle.net. This text is usually displayed by clients in yellow.

EID_ERROR:

This is error information supplied by Battle.net. This text is usually displayed by clients in red.

EID_EMOTE:

This is sent when any user (including self) uses the emote feature in chat.

Format:

(UINT32) Event ID
(UINT32) User's Flags
(UINT32) Ping
(UINT32) IP Address             (defunct 0x00000000)
(UINT32) Account number         (defunct 0x00000000)
(UINT32) Registration Authority (defunct 0x00000000)
(STRING) Username
(STRING) Text

func (*ChatEvent) Deserialize

func (pkt *ChatEvent) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*ChatEvent) Serialize

func (pkt *ChatEvent) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type ChatEventType

type ChatEventType uint32

ChatEventType enum

const (
	ChatShowUser            ChatEventType = 0x01 // User in channel
	ChatJoin                ChatEventType = 0x02 // User joined channel
	ChatLeave               ChatEventType = 0x03 // User left channel
	ChatWhisper             ChatEventType = 0x04 // Recieved whisper
	ChatTalk                ChatEventType = 0x05 // Chat text
	ChatBroadcast           ChatEventType = 0x06 // Server broadcast
	ChatChannelInfo         ChatEventType = 0x07 // Channel information
	ChatUserFlagsUpdate     ChatEventType = 0x09 // Flags update
	ChatWhisperSent         ChatEventType = 0x0A // Sent whisper
	ChatChannelFull         ChatEventType = 0x0D // Channel full
	ChatChannelDoesNotExist ChatEventType = 0x0E // Channel doesn't exist
	ChatChannelRestricted   ChatEventType = 0x0F // Channel is restricted
	ChatInfo                ChatEventType = 0x12 // Information
	ChatError               ChatEventType = 0x13 // Error message
	ChatIgnore              ChatEventType = 0x15 // Notifies that a user has been ignored (DEFUNCT)
	ChatUnignore            ChatEventType = 0x16 // Notifies that a user has been unignored (DEFUNCT)
	ChatEmote               ChatEventType = 0x17 // Emote
)

Chat event types

func (ChatEventType) String

func (e ChatEventType) String() string

type ChatUserFlags

type ChatUserFlags uint32

ChatUserFlags enum

const (
	ChatUserFlagBlizzard  ChatUserFlags = 0x01 // Blizzard Representative
	ChatUserFlagOperator  ChatUserFlags = 0x02 // Channel Operator
	ChatUserFlagSpeaker   ChatUserFlags = 0x04 // Channel Speaker
	ChatUserFlagAdmin     ChatUserFlags = 0x08 // Battle.net Administrator
	ChatUserFlagSquelched ChatUserFlags = 0x20 // Squelched
)

ChatUser Flags

func (ChatUserFlags) String

func (f ChatUserFlags) String() string

type ClanInfo

type ClanInfo struct {
	Tag  protocol.DWordString
	Rank ClanRank
}

ClanInfo implements the [0x75] SID_CLANINFO packet (S -> C).

Received to declare that the client is a member of a clan.

It is received when you first join a clan or immediately after logging on to tell you what clan you are in.

Rank Values:

0x00: Initiate (Peon icon), in clan less than one week
0x01: Initiate (Peon icon)
0x02: Member (Grunt icon)
0x03: Officer (Shaman icon)
0x04: Leader (Chieftain icon)

Format:

 (UINT8) Unknown (0)
(UINT32) Clan tag
 (UINT8) Rank

func (*ClanInfo) Deserialize

func (pkt *ClanInfo) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*ClanInfo) Serialize

func (pkt *ClanInfo) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type ClanRank

type ClanRank uint8

ClanRank enum

const (
	ClanRankNew      ClanRank = 0x00 // Initiate (Peon icon), in clan less than one week
	ClanRankInitiate ClanRank = 0x01 // Initiate (Peon icon)
	ClanRankMember   ClanRank = 0x02 // Member (Grunt icon)
	ClanRankOfficer  ClanRank = 0x03 // Officer (Shaman icon)
	ClanRankLeader   ClanRank = 0x04 // Leader (Chieftain icon)
)

Clan rank

func (ClanRank) String

func (r ClanRank) String() string

type DeserializationBuffer

type DeserializationBuffer struct {
	Buffer [4096]byte
	// contains filtered or unexported fields
}

DeserializationBuffer is used by DeserializePacketWithBuffer to bring amortized allocs to 0 for repeated calls

type EnterChatReq

type EnterChatReq struct {
}

EnterChatReq implements the [0x0A] SID_EnterChat packet (C -> S).

Joins Chat.

Username: Null on WAR3/W3XP.

StatString: Null on CDKey Products, except for D2DV and D2XP when on realm characters..

Format:

(STRING) Username
(STRING) StatString

func (*EnterChatReq) Deserialize

func (pkt *EnterChatReq) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*EnterChatReq) Serialize

func (pkt *EnterChatReq) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type EnterChatResp

type EnterChatResp struct {
	UniqueName  string
	StatString  string
	AccountName string
}

EnterChatResp implements the [0x0A] SID_EnterChat packet (S -> C).

Contains Client product, realm, statstring, and is sent as the response when the client sends SID_EnterChat. Unique name is the users unique name in chat (Which may be Arta, Arta#2, Arta#3, etc). Account name is the users account name (Which in all 3 previous examples would be Arta).

Once you receive this packet, you are not in a channel, but can join/host games and join channels. Because you are not in a channel, you cannot send text messages yet (but you will not be disconnected if you do). See SID_JoinChannel.

Format:

(STRING) Unique name
(STRING) StatString
(STRING) Account name

func (*EnterChatResp) Deserialize

func (pkt *EnterChatResp) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*EnterChatResp) Serialize

func (pkt *EnterChatResp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type FloodDetected

type FloodDetected struct {
}

FloodDetected implements the [0x13] SID_FloodDetected packet (S -> C).

Sent prior to a disconnect along with SID_MessageBox to indicate that the client has flooded off.

Format:

[blank]

func (*FloodDetected) Deserialize

func (pkt *FloodDetected) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*FloodDetected) Serialize

func (pkt *FloodDetected) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type GameSettings

type GameSettings struct {
	SlotsFree    uint8
	HostCounter  uint32
	GameSettings w3gs.GameSettings
}

GameSettings stores the settings of a created game.

This field still conforms to being a null-terminated string by encoding the data such that there are no null characters within.
The first 9 `UINT8`s are characters representing hexadecimal integers (`0` through `9` and `a` through `f`).
After this, the rest of the data is encoded in a manner in order to contain nulls when decoded, but be stored within this null-terminated string.

Format:
 (CHAR)    Number of free slots (ex: `7` for 7 free slots)
 (CHAR)[8] Host counter (reversed hexadecimal integer, ex: `20000000` for second time this host has hosted during his session)
 Encoded data:
    (UINT32) Map flags (combine the below settings):
       Game speed (mask 0x00000003, unique):
           `0x00000000`: Slow
           `0x00000001`: Normal
           `0x00000002`: Fast
       Visibility setting (mask 0x00000F00, unique):
           `0x00000100`: Hide Terrain
           `0x00000200`: Map Explored
           `0x00000400`: Always Visible
           `0x00000800`: Default
       Observers setting (mask 0x40003000, unique):
           `0x00000000`: No Observers
           `0x00002000`: Observers on Defeat
           `0x00003000`: Full Observers
           `0x40000000`: Referees
       Other advanced host settings (mask 0x07064000, combinable):
           `0x00004000`: Teams Together (team members are placed at neighbored starting locations)
           `0x00060000`: Lock Teams
           `0x01000000`: Full Shared Unit Control
           `0x02000000`: Random Hero
           `0x04000000`: Random Races
    (UINT8) Map null 1
    (UINT8) Map width (playable area)
    (UINT8) Map null 2
    (UINT8) Map height (playable area)
    (UINT8) Map null 3
   (UINT32) Map CRC
   (STRING) Map path
   (STRING) Game host name
    (UINT8) Map unknown (possibly a STRING with just the null terminator)
    (UINT8)[20] Unknown (probably a SHA1 hash)

Format:

(UINT32)     Flags
(UINT16)     Map width
(UINT16)     Map height
(UINT32)     Map xoro
(STRING)     Map path
(STRING)     Host name
 (UINT8)[20] Map Sha1 hash

Encoded as a null terminated string where every even byte-value was incremented by 1. So all encoded bytes are odd. A control-byte stores the transformations for the next 7 bytes.

func (*GameSettings) Deserialize

func (gs *GameSettings) Deserialize(buf *protocol.Buffer) error

Deserialize GameSettings from StatString

func (*GameSettings) Serialize

func (gs *GameSettings) Serialize(buf *protocol.Buffer)

Serialize GameSettings into StatString

func (*GameSettings) Size

func (gs *GameSettings) Size() int

Size of Serialize()

type GameStateFlags

type GameStateFlags uint32

GameStateFlags enum

const (
	GameStateFlagPrivate    GameStateFlags = 0x01 // Game is private
	GameStateFlagFull       GameStateFlags = 0x02 // Game is full
	GameStateFlagHasPlayers GameStateFlags = 0x04 // Game contains players (other than creator)
	GameStateFlagInProgress GameStateFlags = 0x08 // Game is in progress
	GameStateFlagOpen       GameStateFlags = 0x10 // Game is open for players (?)
	GameStateFlagReplay     GameStateFlags = 0x80 // Game is a replay
)

GameState Flags

func (GameStateFlags) String

func (f GameStateFlags) String() string

type GetAdvListGame

type GetAdvListGame struct {
	GameFlags      w3gs.GameFlags
	LanguageID     uint32
	Addr           protocol.SockAddr
	GameStateFlags GameStateFlags
	UptimeSec      uint32
	GameName       string
	GameSettings   GameSettings
}

GetAdvListGame stores a game in GetAdvList.

Format:

(UINT32) Game settings
(UINT32) Language ID
(UINT16) Address Family (Always AF_INET)
(UINT16) Port
(UINT32) Host's IP
(UINT32) sin_zero (0)
(UINT32) sin_zero (0)
(UINT32) Game status
(UINT32) Elapsed time (in seconds)
(STRING) Game name
(STRING) Game password
(STRING) Game statstring

type GetAdvListReq

type GetAdvListReq struct {
	Filter        w3gs.GameFlags
	FilterMask    w3gs.GameFlags
	NumberOfGames uint32
	GameName      string
}

GetAdvListReq implements the [0x09] SID_GetAdvListEx packet (C -> S).

Retrieves a list of games.

Viewing Filter:

0xFFFF is used to use the combination of values in this packet.
0xFF80 is used to show all games.
For STAR/SEXP/SSHR/JSTR, viewing filter is set to 0x30.
For DRTL/DSHR, viewing filter is set to 0xFFFF by the game, but setting it to 0x00 will disable any viewing limitations, letting you view all games.

Reserved (0):

This value is hardcoded to 0x00 by all games.

Number of Games:

This is the number of games to list. For a full listing, it's safe to use 0xFF. By default, DRTL/DSHR sets this to 0x19.

Format:

(UINT16) Game Type
(UINT16) Sub Game Type
(UINT32) Viewing Filter
(UINT32) Reserved (0)
(UINT32) Number of Games
(STRING) Game Name
(STRING) Game Password
(STRING) Game Statstring

func (*GetAdvListReq) Deserialize

func (pkt *GetAdvListReq) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*GetAdvListReq) Serialize

func (pkt *GetAdvListReq) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type GetAdvListResp

type GetAdvListResp struct {
	Result AdvListResult    //If count is 0
	Games  []GetAdvListGame //Otherwise
}

GetAdvListResp implements the [0x09] SID_GetAdvListEx packet (S -> C).

Returns a list of available games and their information. Values vary depending on product.

The Game settings field is a combination of values.

WarCraft III (WAR3/W3XP): combine the below settings
   Game type (mask `0x000000FF`, unique)
      `0x00000001`: Custom
      `0x00000009`: Ladder
   Public/private (mask `0x00000800`, unique)
      `0x00000000`: Public game
      `0x00000800`: Private game
   Map author ID (mask `0x00006000`, combinable)
      `0x00002000`: Blizzard
      `0x00004000`: Custom
   Battle/scenario (mask `0x00018000`, unique)
      `0x00000000`: Battle
      `0x00010000`: Scenario
   Map size (mask `0x000E0000`, combinable)
      `0x00020000`: Small
      `0x00040000`: Medium
      `0x00080000`: Huge
   Observers (mask `0x00070000`, unique)
      `0x00100000`: Allowed observers ("Full Observers" and "Referees" options)
      `0x00200000`: Observers on defeat
      `0x00400000`: No observers

The Address Family, Port, Host's IP, and sin_zero fields form a sockaddr_in(https://msdn.microsoft.com/en-us/library/zx63b042.aspx) structure.

The Game status field varies by product.

WarCraft III (WAR3/W3XP):
   `0x00000010`: Public
   `0x00000011`: Private
  When there are no entries returned, the Status field uses this list of results, as well.
   `0x00000000`: OK
   `0x00000001`: Game doesn't exist
   `0x00000002`: Incorrect password
   `0x00000003`: Game full
   `0x00000004`: Game already started
   `0x00000005`: Spawned CD-Key not allowed
   `0x00000006`: Too many server requests

The Game name field is UTF-8 encoded.

The Game password field is always empty on WarCraft III.

The Game statstring field contains more information that is very specific to each product.

Format:

(UINT32) Number of games

If count is 0:
   (UINT32) Status

Otherwise, games are listed thus:
   For each list item:
      (UINT32) Game settings
      (UINT32) Language ID
      (UINT16) Address Family (Always AF_INET)
      (UINT16) Port
      (UINT32) Host's IP
      (UINT32) sin_zero (0)
      (UINT32) sin_zero (0)
      (UINT32) Game status
      (UINT32) Elapsed time (in seconds)
      (STRING) Game name
      (STRING) Game password
      (STRING) Game statstring

func (*GetAdvListResp) Deserialize

func (pkt *GetAdvListResp) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*GetAdvListResp) Serialize

func (pkt *GetAdvListResp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type JoinChannel

type JoinChannel struct {
	Flag    JoinChannelFlag
	Channel string
}

JoinChannel implements the [0x0C] SID_JoinChannel packet (C -> S).

Joins a channel after entering chat.

The Channel name must be no greater than 31 characters, otherwise it becomes trimmed by Battle.net.

The flags field may contain the following values:

0x00: NoCreate join
0x01: First join
0x02: Forced join
0x05: D2 first join

NoCreate Join:

This will only join the channel specified if it is not empty, and is used by clients when selecting a channel from the channels menu. If the channel is empty, Battle.net sends a SID_ChatEvent of type EID_CHANNELDOESNOTEXIST, upon which official clients prompt for confirmation that the user wishes to create the channel, in which case, it resends this packet with Flags set to Forced Join (0x02).

First Join:

Places user in a channel starting with their product and country, followed by a number, ie 'Brood War GBR-1'. Also automatically sends MOTD after entering the channel. When using this type, the Channel variable has no effect, but must be present anyway to avoid an IP ban. This is sent when first logging onto Battle.net

Forced Join:

This is sent when leaving a game, and joins the specified channel without an supplying an MOTD.

D2 First Join:

The same as First join, but is used for D2DV/D2XP clients.

Format:

(UINT32) Flags
(STRING) Channel

func (*JoinChannel) Deserialize

func (pkt *JoinChannel) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*JoinChannel) Serialize

func (pkt *JoinChannel) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type JoinChannelFlag

type JoinChannelFlag uint32

JoinChannelFlag enum

const (
	ChannelJoin         JoinChannelFlag = 0x00
	ChannelJoinFirst    JoinChannelFlag = 0x01
	ChannelJoinOrCreate JoinChannelFlag = 0x02
)

JoinChannel options

func (JoinChannelFlag) String

func (f JoinChannelFlag) String() string

type KeepAlive

type KeepAlive struct {
}

KeepAlive implements the [0x00] SID_Null packet (S -> C, C -> S).

Keeps the connection alive. This message should be sent to the server every 8 minutes (approximately).

The server will send this to you automatically, you do not have to reply to it. You should send this on your own never-ending timer for at least as often as Battle.net does (give or take a few seconds).

This packet is used to detect if your TCP connection has gone dead, to the point where you will never receive data from the server ever again until you reconnect your connection. A situation such as this can be created by unplugging your internet connection for a few minutes, or if your internet is dropped for whatever reason.

Format:

[blank]

func (*KeepAlive) Deserialize

func (pkt *KeepAlive) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*KeepAlive) Serialize

func (pkt *KeepAlive) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type LogonProofResult

type LogonProofResult uint32

LogonProofResult enum

const (
	LogonProofSuccess           LogonProofResult = 0x00 // Logon successful.
	LogonProofPasswordIncorrect LogonProofResult = 0x02 // Incorrect password.
	LogonProofAccountClosed     LogonProofResult = 0x06 // Account closed.
	LogonProofRequireEmail      LogonProofResult = 0x0E // An email address should be registered for this account.
	LogonProofCustomError       LogonProofResult = 0x0F // Custom error. A string at the end of this message contains the error.
)

AuthAccountLogonProof result

func (LogonProofResult) String

func (r LogonProofResult) String() string

type LogonResult

type LogonResult uint32

LogonResult enum

const (
	LogonSuccess         LogonResult = 0x00 // Logon accepted, requires proof.
	LogonInvalidAccount  LogonResult = 0x01 // Account doesn't exist.
	LogonUpgradeRequired LogonResult = 0x05 // Account requires upgrade.
)

AuthAccountLogon result

func (LogonResult) String

func (r LogonResult) String() string

type MessageBox

type MessageBox struct {
	Style   uint32
	Text    string
	Caption string
}

MessageBox implements the [0x19] SID_MessageBox packet (S -> C).

Displays a message to the user. This message's fields are used as parameters for the Win32 MessageBox API (http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx), and can be passed directly to it.

Format:

(UINT32) Style
(STRING) Text
(STRING) Caption

func (*MessageBox) Deserialize

func (pkt *MessageBox) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*MessageBox) Serialize

func (pkt *MessageBox) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type NetGamePort

type NetGamePort struct {
	Port uint16
}

NetGamePort implements the [0x45] SID_NetGamePort packet (C -> S).

Sets the port used by the client for hosting WAR3/W3XP games. This value is retreived from HKCU\Software\Blizzard Entertainment\Warcraft III\Gameplay\netgameport, and is sent after the user logs on.

Format:

(UINT16) Port

func (*NetGamePort) Deserialize

func (pkt *NetGamePort) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*NetGamePort) Serialize

func (pkt *NetGamePort) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type NotifyJoin

type NotifyJoin struct {
	GameVersion w3gs.GameVersion
	GameName    string
}

NotifyJoin implements the [0x22] SID_NotifyJoin packet (C -> S).

Notifies Battle.net that the client has joined a game. This is what causes you to receive "Your friend _ entered a _ game called _." from Battle.net if you are mutual friends with this client.

SID_LeaveChat (0x10) does not need to be sent after this, since this does what LeaveChat does but with an added notification.

ProductID: This can be any valid Product ID, even if you are not connected with that ID.

Format:

(UINT32) Product ID
(UINT32) Product version
(STRING) Game Name
(STRING) Game Password

func (*NotifyJoin) Deserialize

func (pkt *NotifyJoin) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*NotifyJoin) Serialize

func (pkt *NotifyJoin) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type Packet

type Packet interface {
	Serialize(buf *protocol.Buffer) error
	Deserialize(buf *protocol.Buffer) error
}

Packet interface.

func DeserializeClientPacket

func DeserializeClientPacket(r io.Reader) (Packet, int, error)

DeserializeClientPacket reads exactly one packet from r and returns it in the proper (deserialized) packet type.

func DeserializeClientPacketWithBuffer

func DeserializeClientPacketWithBuffer(r io.Reader, b *DeserializationBuffer) (Packet, int, error)

DeserializeClientPacketWithBuffer reads exactly one client packet from r and returns it in the proper (deserialized) packet type.

func DeserializeServerPacket

func DeserializeServerPacket(r io.Reader) (Packet, int, error)

DeserializeServerPacket reads exactly one packet from r and returns it in the proper (deserialized) packet type.

func DeserializeServerPacketWithBuffer

func DeserializeServerPacketWithBuffer(r io.Reader, b *DeserializationBuffer) (Packet, int, error)

DeserializeServerPacketWithBuffer reads exactly one server packet from r and returns it in the proper (deserialized) packet type.

type Ping

type Ping struct {
	Payload uint32
}

Ping implements the [0x25] SID_Ping packet (S -> C, C -> S).

Used to calculate Client's ping. The received UINT32 should be sent directly back to Battle.net.

The ping displayed when in chat can be artificially inflated by delaying before sending this packet, or deflated by responding before requested. Ping can be set to -1 (Strictly speaking, 0xFFFFFFFF, since ping is unsigned) by not responding to this packet at all.

The received UINT32 is not what determines your ping, but it is actually a cookie for the Battle.net server. You should never change the UINT32.

Format:

(UINT32) Ping Value

func (*Ping) Deserialize

func (pkt *Ping) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*Ping) Serialize

func (pkt *Ping) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type SerializationBuffer

type SerializationBuffer = protocol.Buffer

SerializationBuffer is used by SerializePacketWithBuffer to bring amortized allocs to 0 for repeated calls

type SetEmail

type SetEmail struct {
	EmailAddress string
}

SetEmail implements the [0x59] SID_SETEMAIL packet (C -> S).

Binds an email address to your account.

Sending this message is optional. However, you should only send it when you receive status 0x0E from SID_AUTH_ACCOUNTLOGONPROOF.

Format:

(STRING) Email Address

func (*SetEmail) Deserialize

func (pkt *SetEmail) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*SetEmail) Serialize

func (pkt *SetEmail) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type StartAdvex3Req

type StartAdvex3Req struct {
	GameStateFlags GameStateFlags
	UptimeSec      uint32
	GameFlags      w3gs.GameFlags
	Ladder         bool
	GameName       string
	GameSettings   GameSettings
}

StartAdvex3Req implements the [0x1C] SID_StartAdvex3 packet (C -> S).

Used by clients to inform the server that a game has been created, or that the state of a created game has changed.

Bitwise flags for `State`:

0x01: Game is private
0x02: Game is full
0x04: Game contains players (other than creator)
0x08: Game is in progress
0x80: Game is a replay

Possible values for `Game Type` (and `Sub Game Type`):

0x02: Melee
0x03: Free for All
0x04: 1 vs 1
0x05: Capture The Flag
0x06: Greed (Resources, 0x01: 2500, 0x02: 500, 0x03: 7500, 0x04: 10000)
0x07: Slaughter (Minutes, 0x01: 15, 0x02: 30, 0x03: 45, 0x04: 60)
0x08: Sudden Death
0x09: Ladder (Disconnects, 0x00: Not a loss, 0x01: Counts as a loss)
0x0A: Use Map Settings
0x0B: Team Melee (Number Of Teams, 0x01: 2 Teams, 0x02: 3 Teams, etc.)
0x0C: Team Free For All (Number Of Teams, 0x01: 2 Teams, 0x02: 3 Teams, etc.)
0x0D: Team Capture The Flag (Number Of Teams, 0x01: 2 Teams, 0x02: 3 Teams, etc.)
0x0F: Top vs. Bottom (Number Of Teams, 1-7 specifies the ratio of players belonging to both teams)
0x10: Iron Man Ladder (W2BN only)
0x20: PGL

`Provider Version Constant`: The current version of the game (1.16.1) uses `0xFF`, previous versions have used `0x1F`, but this may vary depending on game version.

Possible values for `Ladder`:

0x00: Game is Normal (Non-Ladder)
0x01: Game is Ladder
0x03: Game is Iron Man Ladder (W2BN only)

It could be that the `Ladder` is bitwise as well, and that `0x02` means Iron Man and `0x03` just means Iron Man + Ladder.

`Sub Game Type` appears to be `0x01` for all game types except Top vs Bottom, where it seems to depend on the size of each team. More research will be needed to confirm.

Format:

(UINT32) Game State
(UINT32) Game Uptime in seconds
(UINT16) Game Type
(UINT16) Sub Game Type
(UINT32) Provider Version Constant (0x03FF)
(UINT32) Ladder Type
(STRING) Game Name
(STRING) Game Password
(STRING) Game Statstring

func (*StartAdvex3Req) Deserialize

func (pkt *StartAdvex3Req) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*StartAdvex3Req) Serialize

func (pkt *StartAdvex3Req) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type StartAdvex3Resp

type StartAdvex3Resp struct {
	Failed bool
}

StartAdvex3Resp implements the [0x1C] SID_StartAdvex3 packet (S -> C).

Possible values for Status:

0x00: Ok
0x01: Failed

Format:

(UINT32) Status

func (*StartAdvex3Resp) Deserialize

func (pkt *StartAdvex3Resp) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*StartAdvex3Resp) Serialize

func (pkt *StartAdvex3Resp) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type StopAdv

type StopAdv struct {
}

StopAdv implements the [0x02] SID_StopAdv packet (C -> S).

This message is sent to inform the server that a game should no longer be advertised to other users. It is sent when a game starts, or when a game is aborted (the host leaves).

All Battle.snp clients (DRTL, DSHR, STAR/SEXP, JSTR, SSHR, and W2BN) always send this message when logging off, even if it not in a game.

Format:

[blank]

func (*StopAdv) Deserialize

func (pkt *StopAdv) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*StopAdv) Serialize

func (pkt *StopAdv) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

type UnknownPacket

type UnknownPacket struct {
	ID   byte
	Blob []byte
}

UnknownPacket is used to store unknown packets.

func (*UnknownPacket) Deserialize

func (pkt *UnknownPacket) Deserialize(buf *protocol.Buffer) error

Deserialize decodes the binary data generated by Serialize.

func (*UnknownPacket) Serialize

func (pkt *UnknownPacket) Serialize(buf *protocol.Buffer) error

Serialize encodes the struct into its binary form.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL