1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-02 14:46:28 -05:00

d2networking: fix all fieldalignments

This commit is contained in:
gucio321 2021-06-13 17:52:16 +02:00
parent cbfd8efce8
commit 9c87bd775e
14 changed files with 43 additions and 48 deletions

View File

@ -16,15 +16,14 @@ import (
// LocalClientConnection is the implementation of ClientConnection
// for a local client.
type LocalClientConnection struct {
clientListener d2networking.ClientListener
asset *d2asset.AssetManager
heroState *d2hero.HeroStateFactory
clientListener d2networking.ClientListener // The game client
uniqueID string // Unique ID generated on construction
openNetworkServer bool // True if this is a server
playerState *d2hero.HeroState // Local player state
gameServer *d2server.GameServer // Game Server
logLevel d2util.LogLevel
playerState *d2hero.HeroState
gameServer *d2server.GameServer
uniqueID string
logLevel d2util.LogLevel
openNetworkServer bool
}
// GetUniqueID returns LocalClientConnection.uniqueID.

View File

@ -23,14 +23,13 @@ const logPrefix = "Remote Client"
// RemoteClientConnection is the implementation of ClientConnection
// for a remote client.
type RemoteClientConnection struct {
clientListener d2networking.ClientListener
asset *d2asset.AssetManager
heroState *d2hero.HeroStateFactory
clientListener d2networking.ClientListener // The GameClient
uniqueID string // Unique ID generated on construction
tcpConnection *net.TCPConn // UDP connection to the server
active bool // The connection is currently open
tcpConnection *net.TCPConn
*d2util.Logger
uniqueID string
active bool
}
// Create constructs a new RemoteClientConnection

View File

@ -35,19 +35,18 @@ const (
// GameClient manages a connection to d2server.GameServer
// and keeps a synchronized copy of the map and entities.
type GameClient struct {
clientConnection ServerConnection // Abstract local/remote connection
connectionType d2clientconnectiontype.ClientConnectionType // Type of connection (local or remote)
clientConnection ServerConnection
asset *d2asset.AssetManager
scriptEngine *d2script.ScriptEngine
GameState *d2hero.HeroState // local player state
MapEngine *d2mapengine.MapEngine // Map and entities
mapGen *d2mapgen.MapGenerator // map generator
PlayerID string // ID of the local player
Players map[string]*d2mapentity.Player // IDs of the other players
Seed int64 // Map seed
RegenMap bool // Regenerate tile cache on render (map has changed)
GameState *d2hero.HeroState
MapEngine *d2mapengine.MapEngine
mapGen *d2mapgen.MapGenerator
Players map[string]*d2mapentity.Player
*d2util.Logger
PlayerID string
connectionType d2clientconnectiontype.ClientConnectionType
Seed int64
RegenMap bool
}
// Create constructs a new GameClient and returns a pointer to it.

View File

@ -11,8 +11,8 @@ import (
// PacketData is unmarshalled to a struct of the type associated with
// PacketType.
type NetPacket struct {
PacketType d2netpackettype.NetPacketType `json:"packetType"`
PacketData json.RawMessage `json:"packetData"`
PacketType d2netpackettype.NetPacketType `json:"packetType"`
}
// InspectPacketType determines the packet type from the given data

View File

@ -13,14 +13,14 @@ import (
// It is sent by the server to create the entity for a newly connected
// player on a client.
type AddPlayerPacket struct {
Equipment d2inventory.CharacterEquipment `json:"equipment"`
Stats *d2hero.HeroStatsState `json:"heroStats"`
Skills map[int]*d2hero.HeroSkill `json:"heroSkills"`
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

View File

@ -8,9 +8,9 @@ import (
// SpawnItemPacket contains the data required to create a Item entity
type SpawnItemPacket struct {
Codes []string `json:"codes"`
X int `json:"x"`
Y int `json:"y"`
Codes []string `json:"codes"`
}
// CreateSpawnItemPacket returns a NetPacket which declares a

View File

@ -11,10 +11,10 @@ import (
// entity.
type CastPacket struct {
SourceEntityID string `json:"sourceEntityId"`
TargetEntityID string `json:"targetEntityId"`
SkillID int `json:"skillId"`
TargetX float64 `json:"targetX"`
TargetY float64 `json:"targetY"`
TargetEntityID string `json:"targetEntityId"`
}
// CreateCastPacket returns a NetPacket which declares a CastPacket with the

View File

@ -11,8 +11,8 @@ import (
// PlayerConnectionRequestPacket contains a player ID and game state.
// It is sent by a remote client to initiate a connection (join a game).
type PlayerConnectionRequestPacket struct {
ID string `json:"id"`
PlayerState *d2hero.HeroState `json:"gameState"`
ID string `json:"id"`
}
// CreatePlayerConnectionRequestPacket returns a NetPacket which defines a

View File

@ -11,8 +11,8 @@ import (
// PlayerDisconnectRequestPacket contains a player ID and game state.
// It is sent by a remote client to close the connection (leave a game).
type PlayerDisconnectRequestPacket struct {
ID string `json:"id"`
PlayerState *d2hero.HeroState `json:"gameState"`
ID string `json:"id"`
}
// CreatePlayerDisconnectRequestPacket returns a NetPacket which defines a

View File

@ -10,8 +10,8 @@ import (
// 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.
type PongPacket struct {
ID string `json:"id"`
TS time.Time `json:"ts"`
ID string `json:"id"`
}
// CreatePongPacket returns a NetPacket which declares a PongPacket with

View File

@ -9,8 +9,8 @@ import (
// UpdateServerInfoPacket contains the ID for a player and the map seed.
// It is sent by the server to synchronize these values on the client.
type UpdateServerInfoPacket struct {
Seed int64 `json:"seed"`
PlayerID string `json:"playerId"`
Seed int64 `json:"seed"`
}
// CreateUpdateServerInfoPacket returns a NetPacket which declares an

View File

@ -13,9 +13,9 @@ import (
// TCPClientConnection represents a client connection over TCP
type TCPClientConnection struct {
id string
tcpConnection net.Conn
playerState *d2hero.HeroState
id string
}
// CreateTCPClientConnection creates a new tcp client connection instance

View File

@ -23,12 +23,11 @@ const logPrefix = "UDP Connection"
// d2server.ClientConnection interface to represent remote client from the
// server perspective.
type UDPClientConnection struct {
id string // ID of the associated RemoteClientConnection
address *net.UDPAddr // IP address of the associated RemoteClientConnection
udpConnection *net.UDPConn // Server's UDP Connection
playerState *d2hero.HeroState // Client's game state
address *net.UDPAddr
udpConnection *net.UDPConn
playerState *d2hero.HeroState
*d2util.Logger
id string
}
// CreateUDPClientConnection constructs a new UDPClientConnection and

View File

@ -41,21 +41,20 @@ var (
// GameServer manages a copy of the map and entities as well as manages packet routing and connections.
// It can accept connections from localhost as well remote clients. It can also be started in a standalone mode.
type GameServer struct {
sync.RWMutex
connections map[string]ClientConnection
listener net.Listener
networkServer bool
ctx context.Context
packetManagerChan chan ReceivedPacket
connections map[string]ClientConnection
heroStateFactory *d2hero.HeroStateFactory
cancel context.CancelFunc
asset *d2asset.AssetManager
mapEngines []*d2mapengine.MapEngine
scriptEngine *d2script.ScriptEngine
seed int64
maxConnections int
packetManagerChan chan ReceivedPacket
heroStateFactory *d2hero.HeroStateFactory
*d2util.Logger
scriptEngine *d2script.ScriptEngine
mapEngines []*d2mapengine.MapEngine
maxConnections int
seed int64
sync.RWMutex
networkServer bool
}
// ReceivedPacket encapsulates the data necessary for the packet manager goroutine to process data from clients.