Documentation ¶
Overview ¶
Package d2netpacket provides all of the different types of packets
Index ¶
- func InspectPacketType(b []byte) (d2netpackettype.NetPacketType, error)
- func MarshalPacket(packet interface{}) ([]byte, error)
- type AddPlayerPacket
- type CastPacket
- type GenerateMapPacket
- type MovePlayerPacket
- type NetPacket
- func CreateAddPlayerPacket(id, name string, x, y int, heroType d2enum.Hero, stats *d2hero.HeroStatsState, ...) (NetPacket, error)
- func CreateCastPacket(entityID string, skillID int, targetX, targetY float64) (NetPacket, error)
- func CreateGenerateMapPacket(regionType d2enum.RegionIdType) (NetPacket, error)
- func CreateMovePlayerPacket(playerID string, startX, startY, destX, destY float64) (NetPacket, error)
- func CreatePingPacket() (NetPacket, error)
- func CreatePlayerConnectionRequestPacket(id string, playerState *d2hero.HeroState) (NetPacket, error)
- func CreatePlayerDisconnectRequestPacket(id string) (NetPacket, error)
- func CreatePongPacket(id string) (NetPacket, error)
- func CreateSavePlayerPacket(playerState *d2mapentity.Player, difficulty d2enum.DifficultyType) (NetPacket, error)
- func CreateServerClosedPacket() (NetPacket, error)
- func CreateServerFullPacket() (NetPacket, error)
- func CreateSpawnItemPacket(x, y int, codes ...string) (NetPacket, error)
- func CreateUpdateServerInfoPacket(seed int64, playerID string) (NetPacket, error)
- func UnmarshalNetPacket(packet []byte) (NetPacket, error)
- type PingPacket
- type PlayerConnectionRequestPacket
- type PlayerDisconnectRequestPacket
- type PongPacket
- type SavePlayerPacket
- type ServerClosedPacket
- type ServerFullPacket
- type SpawnItemPacket
- type UpdateServerInfoPacket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InspectPacketType ¶
func InspectPacketType(b []byte) (d2netpackettype.NetPacketType, error)
InspectPacketType determines the packet type from the given data
func MarshalPacket ¶
MarshalPacket is a quick helper function to Marshal very anything UNSAFELY, meaning the error is not checked before sending.
Types ¶
type AddPlayerPacket ¶
type AddPlayerPacket struct { ID string `json:"id"` Name string `json:"name"` X int `json:"x"` Y int `json:"y"` HeroType d2enum.Hero `json:"hero"` Equipment d2inventory.CharacterEquipment `json:"equipment"` Stats *d2hero.HeroStatsState `json:"heroStats"` Skills map[int]*d2hero.HeroSkill `json:"heroSkills"` LeftSkill int `json:"leftSkill"` RightSkill int `json:"rightSkill"` Gold int }
AddPlayerPacket contains the data required to create a Player entity. It is sent by the server to create the entity for a newly connected player on a client.
func UnmarshalAddPlayer ¶
func UnmarshalAddPlayer(packet []byte) (AddPlayerPacket, error)
UnmarshalAddPlayer unmarshals the packet data into an AddPlayerPacket struct
type CastPacket ¶
type CastPacket struct { SourceEntityID string `json:"sourceEntityId"` SkillID int `json:"skillId"` TargetX float64 `json:"targetX"` TargetY float64 `json:"targetY"` TargetEntityID string `json:"targetEntityId"` }
CastPacket contains a cast command for an entity. It is sent by the server and instructs the client to trigger the use of the given skill on the given entity.
func UnmarshalCast ¶
func UnmarshalCast(packet []byte) (CastPacket, error)
UnmarshalCast unmarshals the given data to a CastPacket struct
type GenerateMapPacket ¶
type GenerateMapPacket struct {
RegionType d2enum.RegionIdType `json:"regionType"`
}
GenerateMapPacket contains an enumerable representing a region. It is sent by the server to generate the map for the given region on a client.
func UnmarshalGenerateMap ¶
func UnmarshalGenerateMap(packet []byte) (GenerateMapPacket, error)
UnmarshalGenerateMap unmarshals the given packet data into a GenerateMapPacket struct
type MovePlayerPacket ¶
type MovePlayerPacket struct { PlayerID string `json:"playerId"` StartX float64 `json:"startX"` StartY float64 `json:"startY"` DestX float64 `json:"destX"` DestY float64 `json:"destY"` }
MovePlayerPacket contains a movement command for a specific player entity. It is sent by the server to move a player entity on a client. https://github.com/OpenDiablo2/OpenDiablo2/issues/825
func UnmarshalMovePlayer ¶
func UnmarshalMovePlayer(packet []byte) (MovePlayerPacket, error)
UnmarshalMovePlayer unmarshals the given data to a MovePlayerPacket struct
type NetPacket ¶
type NetPacket struct { PacketType d2netpackettype.NetPacketType `json:"packetType"` PacketData json.RawMessage `json:"packetData"` }
NetPacket is used to wrap and send all packet types under d2netpacket. When decoding a packet: First the PacketType byte is read, then the PacketData is unmarshalled to a struct of the type associated with PacketType.
func CreateAddPlayerPacket ¶
func CreateAddPlayerPacket( id, name string, x, y int, heroType d2enum.Hero, stats *d2hero.HeroStatsState, skills map[int]*d2hero.HeroSkill, equipment d2inventory.CharacterEquipment, leftSkill, rightSkill, gold int) (NetPacket, error)
CreateAddPlayerPacket returns a NetPacket which declares an AddPlayerPacket with the data in given parameters.
func CreateCastPacket ¶
CreateCastPacket returns a NetPacket which declares a CastPacket with the given skill command.
func CreateGenerateMapPacket ¶
func CreateGenerateMapPacket(regionType d2enum.RegionIdType) (NetPacket, error)
CreateGenerateMapPacket returns a NetPacket which declares a GenerateMapPacket with the given regionType.
func CreateMovePlayerPacket ¶
func CreateMovePlayerPacket(playerID string, startX, startY, destX, destY float64) (NetPacket, error)
CreateMovePlayerPacket returns a NetPacket which declares a MovePlayerPacket with the given ID and movement command.
func CreatePingPacket ¶
CreatePingPacket returns a NetPacket which declares a GenerateMapPacket with the the current time.
func CreatePlayerConnectionRequestPacket ¶
func CreatePlayerConnectionRequestPacket(id string, playerState *d2hero.HeroState) (NetPacket, error)
CreatePlayerConnectionRequestPacket returns a NetPacket which defines a PlayerConnectionRequestPacket with the given ID and game state.
func CreatePlayerDisconnectRequestPacket ¶
CreatePlayerDisconnectRequestPacket returns a NetPacket which defines a PlayerDisconnectRequestPacket with the given ID.
func CreatePongPacket ¶
CreatePongPacket returns a NetPacket which declares a PongPacket with the current time and given ID.
func CreateSavePlayerPacket ¶
func CreateSavePlayerPacket(playerState *d2mapentity.Player, difficulty d2enum.DifficultyType) (NetPacket, error)
CreateSavePlayerPacket sends a packet which instructs the server to save the Player
func CreateServerClosedPacket ¶
CreateServerClosedPacket returns a NetPacket which declares a ServerClosedPacket with the current time.
func CreateServerFullPacket ¶
CreateServerFullPacket returns a NetPacket which declares a ServerFullPacket.
func CreateSpawnItemPacket ¶
CreateSpawnItemPacket returns a NetPacket which declares a SpawnItemPacket with the data in given parameters.
func CreateUpdateServerInfoPacket ¶
CreateUpdateServerInfoPacket returns a NetPacket which declares an UpdateServerInfoPacket with the given player ID and map seed.
func UnmarshalNetPacket ¶
UnmarshalNetPacket unmarshals the byte slice into a NetPacket struct
type PingPacket ¶
PingPacket contains the time at which it was sent. It is sent by the server and instructs the client to respond with a Pong packet.
func UnmarshalPing ¶
func UnmarshalPing(packet []byte) (PingPacket, error)
UnmarshalPing unmarshals the given data to a PingPacket struct
type PlayerConnectionRequestPacket ¶
type PlayerConnectionRequestPacket struct { ID string `json:"id"` PlayerState *d2hero.HeroState `json:"gameState"` }
PlayerConnectionRequestPacket contains a player ID and game state. It is sent by a remote client to initiate a connection (join a game).
func UnmarshalPlayerConnectionRequest ¶
func UnmarshalPlayerConnectionRequest(packet []byte) (PlayerConnectionRequestPacket, error)
UnmarshalPlayerConnectionRequest unmarshals the given data to a PlayerConnectionRequestPacket struct
type PlayerDisconnectRequestPacket ¶
type PlayerDisconnectRequestPacket struct { ID string `json:"id"` PlayerState *d2hero.HeroState `json:"gameState"` }
PlayerDisconnectRequestPacket contains a player ID and game state. It is sent by a remote client to close the connection (leave a game).
func UnmarshalPlayerDisconnectionRequest ¶
func UnmarshalPlayerDisconnectionRequest(packet []byte) (PlayerDisconnectRequestPacket, error)
UnmarshalPlayerDisconnectionRequest unmarshals the given data to a PlayerDisconnectRequestPacket struct
type PongPacket ¶
PongPacket contains the time at which it was sent and the ID of the client. It is sent by the client in response to a Pong packet.
func UnmarshalPong ¶
func UnmarshalPong(packet []byte) (PongPacket, error)
UnmarshalPong unmarshals the given data to a PongPacket struct
type SavePlayerPacket ¶
type SavePlayerPacket struct { Player *d2mapentity.Player `json:"Player"` Difficulty d2enum.DifficultyType `json:"Difficulty"` }
SavePlayerPacket has the actual selected left and right skill the Server has to check if these skills are actually allowed for the Player
func UnmarshalSavePlayer ¶
func UnmarshalSavePlayer(packet []byte) (SavePlayerPacket, error)
UnmarshalSavePlayer unmarshalls the given data to a SavePlayerPacket struct
type ServerClosedPacket ¶
ServerClosedPacket contains the current time. It is sent by the server to inform a client that the server has shut down.
func UnmarshalServerClosed ¶
func UnmarshalServerClosed(packet []byte) (ServerClosedPacket, error)
UnmarshalServerClosed unmarshals the given data to a ServerClosedPacket struct
type ServerFullPacket ¶
type ServerFullPacket struct{}
ServerFullPacket is sent by the server to inform a client that the server has reached the max number of allowed connections.
func UnmarshalServerFull ¶
func UnmarshalServerFull(packet []byte) (ServerFullPacket, error)
UnmarshalServerFull unmarshalls the given data to a ServerFullPacket struct
type SpawnItemPacket ¶
SpawnItemPacket contains the data required to create a Item entity
func UnmarshalSpawnItem ¶
func UnmarshalSpawnItem(packet []byte) (SpawnItemPacket, error)
UnmarshalSpawnItem unmarshals the given data to a SpawnItemPacket struct
type UpdateServerInfoPacket ¶
UpdateServerInfoPacket contains the ID for a player and the map seed. It is sent by the server to synchronize these values on the client.
func UnmarshalUpdateServerInfo ¶
func UnmarshalUpdateServerInfo(packet []byte) (UpdateServerInfoPacket, error)
UnmarshalUpdateServerInfo unmarshals the data to a UpdateServerInfoPacket struct
Source Files ¶
- doc.go
- net_packet.go
- packet_add_player.go
- packet_generate_map.go
- packet_item_spawn.go
- packet_move_player.go
- packet_ping.go
- packet_player_cast.go
- packet_player_connection_request.go
- packet_player_disconnect_request.go
- packet_pong.go
- packet_save_player.go
- packet_server_closed.go
- packet_server_full.go
- packet_update_server_info.go
Directories ¶
Path | Synopsis |
---|---|
Package d2netpackettype defines types which are encoded to JSON and sent in network packet payloads.
|
Package d2netpackettype defines types which are encoded to JSON and sent in network packet payloads. |