2020-06-13 18:32:09 -04:00
|
|
|
package d2server
|
|
|
|
|
|
|
|
import (
|
2020-06-26 17:12:19 -04:00
|
|
|
"bytes"
|
|
|
|
"compress/gzip"
|
2020-06-18 14:11:04 -04:00
|
|
|
"encoding/json"
|
2020-06-26 17:12:19 -04:00
|
|
|
"fmt"
|
|
|
|
"io"
|
2020-06-13 18:32:09 -04:00
|
|
|
"log"
|
2020-06-18 14:11:04 -04:00
|
|
|
"net"
|
2020-06-26 17:12:19 -04:00
|
|
|
"strings"
|
2020-06-22 20:31:42 -04:00
|
|
|
"sync"
|
2020-06-26 17:12:19 -04:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
2020-07-17 22:11:16 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2map/d2mapengine"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2map/d2mapgen"
|
2020-06-26 17:12:19 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2netpacket"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2netpacket/d2netpackettype"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2server/d2udpclientconnection"
|
2020-06-18 14:11:04 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2script"
|
2020-06-26 17:12:19 -04:00
|
|
|
"github.com/robertkrimen/otto"
|
2020-06-13 18:32:09 -04:00
|
|
|
)
|
|
|
|
|
2020-07-17 22:11:16 -04:00
|
|
|
const (
|
|
|
|
udpBufferSize = 4096
|
|
|
|
subtilesPerTile = 5
|
|
|
|
middleOfTileOffset = 3
|
|
|
|
)
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// GameServer owns the authoritative copy of the map and entities
|
|
|
|
// It accepts incoming connections from local (host) and remote
|
|
|
|
// clients.
|
2020-06-13 18:32:09 -04:00
|
|
|
type GameServer struct {
|
2020-06-22 20:31:42 -04:00
|
|
|
sync.RWMutex
|
2020-06-13 18:32:09 -04:00
|
|
|
clientConnections map[string]ClientConnection
|
2020-06-22 20:31:42 -04:00
|
|
|
manager *ConnectionManager
|
2020-06-26 17:12:19 -04:00
|
|
|
mapEngines []*d2mapengine.MapEngine
|
2020-06-18 14:11:04 -04:00
|
|
|
scriptEngine *d2script.ScriptEngine
|
|
|
|
udpConnection *net.UDPConn
|
|
|
|
seed int64
|
|
|
|
running bool
|
2020-06-13 18:32:09 -04:00
|
|
|
}
|
|
|
|
|
2020-07-17 22:11:16 -04:00
|
|
|
//nolint:gochecknoglobals // currently singleton by design
|
2020-06-26 17:12:19 -04:00
|
|
|
var singletonServer *GameServer
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// Create constructs a new GameServer and assigns it as a singleton. It
|
|
|
|
// also generates the initial map and entities for the server.
|
|
|
|
//
|
|
|
|
// If openNetworkServer is true, the GameServer starts listening for UDP
|
|
|
|
// packets.
|
2020-06-26 17:12:19 -04:00
|
|
|
func Create(openNetworkServer bool) {
|
|
|
|
log.Print("Creating GameServer")
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
if singletonServer != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
singletonServer = &GameServer{
|
|
|
|
clientConnections: make(map[string]ClientConnection),
|
|
|
|
mapEngines: make([]*d2mapengine.MapEngine, 0),
|
|
|
|
scriptEngine: d2script.CreateScriptEngine(),
|
|
|
|
seed: time.Now().UnixNano(),
|
|
|
|
}
|
|
|
|
|
|
|
|
singletonServer.manager = CreateConnectionManager(singletonServer)
|
|
|
|
|
|
|
|
mapEngine := d2mapengine.CreateMapEngine()
|
|
|
|
mapEngine.SetSeed(singletonServer.seed)
|
2020-07-17 22:11:16 -04:00
|
|
|
|
|
|
|
// TODO: Mapgen - Needs levels.txt stuff
|
|
|
|
mapEngine.ResetMap(d2enum.RegionAct1Town, 100, 100)
|
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
d2mapgen.GenerateAct1Overworld(mapEngine)
|
|
|
|
singletonServer.mapEngines = append(singletonServer.mapEngines, mapEngine)
|
2020-06-18 14:11:04 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
singletonServer.scriptEngine.AddFunction("getMapEngines", func(call otto.FunctionCall) otto.Value {
|
|
|
|
val, err := singletonServer.scriptEngine.ToValue(singletonServer.mapEngines)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Print(err.Error())
|
|
|
|
}
|
|
|
|
return val
|
|
|
|
})
|
2020-06-18 14:11:04 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
if openNetworkServer {
|
|
|
|
createNetworkServer()
|
|
|
|
}
|
2020-06-18 14:11:04 -04:00
|
|
|
}
|
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
func createNetworkServer() {
|
|
|
|
s, err := net.ResolveUDPAddr("udp4", "0.0.0.0:6669")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-06-18 14:11:04 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
singletonServer.udpConnection, err = net.ListenUDP("udp4", s)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
2020-06-18 14:11:04 -04:00
|
|
|
}
|
2020-07-17 22:11:16 -04:00
|
|
|
|
|
|
|
err = singletonServer.udpConnection.SetReadBuffer(udpBufferSize)
|
|
|
|
|
2020-06-30 20:01:51 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Print("GameServer: error setting UDP read buffer:", err)
|
|
|
|
}
|
2020-06-26 17:12:19 -04:00
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// runNetworkServer runs a while loop, reading from the GameServer's UDP
|
|
|
|
// connection.
|
2020-06-26 17:12:19 -04:00
|
|
|
func runNetworkServer() {
|
|
|
|
buffer := make([]byte, 4096)
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
for singletonServer.running {
|
2020-07-17 22:11:16 -04:00
|
|
|
_, addr, udpReadErr := singletonServer.udpConnection.ReadFromUDP(buffer)
|
|
|
|
if udpReadErr != nil {
|
|
|
|
fmt.Printf("Socket error: %s\n", udpReadErr)
|
2020-06-26 17:12:19 -04:00
|
|
|
continue
|
|
|
|
}
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
buff := bytes.NewBuffer(buffer)
|
2020-07-17 22:11:16 -04:00
|
|
|
|
|
|
|
packetTypeID, _ := buff.ReadByte()
|
|
|
|
packetType := d2netpackettype.NetPacketType(packetTypeID)
|
|
|
|
|
|
|
|
reader, _ := gzip.NewReader(buff)
|
2020-06-26 17:12:19 -04:00
|
|
|
sb := new(strings.Builder)
|
2020-07-02 16:29:28 -04:00
|
|
|
|
|
|
|
// This will throw errors where packets are not compressed. This doesn't
|
|
|
|
// break anything, so the gzip.ErrHeader error, is currently ignored to
|
|
|
|
// avoid noisy logging.
|
2020-07-17 22:11:16 -04:00
|
|
|
written, copyErr := io.Copy(sb, reader)
|
2020-07-02 16:29:28 -04:00
|
|
|
|
2020-07-17 22:11:16 -04:00
|
|
|
if copyErr != nil && copyErr != gzip.ErrHeader {
|
|
|
|
log.Printf("GameServer: error copying bytes from %v packet: %s", packetType, copyErr)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-30 20:01:51 -04:00
|
|
|
if written == 0 {
|
|
|
|
log.Printf("GameServer: empty packet %v packet received", packetType)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
stringData := sb.String()
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
switch packetType {
|
|
|
|
case d2netpackettype.PlayerConnectionRequest:
|
2020-07-17 22:11:16 -04:00
|
|
|
if err := handlePlayerConnectionRequest(addr, stringData); err != nil {
|
|
|
|
log.Printf("GameServer error: %v", err)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-06-26 17:12:19 -04:00
|
|
|
case d2netpackettype.MovePlayer:
|
2020-07-17 22:11:16 -04:00
|
|
|
if err := handleMovePlayer(packetType, stringData); err != nil {
|
|
|
|
log.Printf("GameServer error: %v", err)
|
2020-06-26 17:12:19 -04:00
|
|
|
}
|
|
|
|
case d2netpackettype.Pong:
|
2020-07-17 22:11:16 -04:00
|
|
|
if err := handlePingPong(stringData); err != nil {
|
|
|
|
log.Printf("GameServer error: %v", err)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-06-26 17:12:19 -04:00
|
|
|
case d2netpackettype.ServerClosed:
|
|
|
|
singletonServer.manager.Shutdown()
|
|
|
|
case d2netpackettype.PlayerDisconnectionNotification:
|
2020-07-17 22:11:16 -04:00
|
|
|
if err := handlePlayerDisconnectNotification(stringData); err != nil {
|
|
|
|
log.Printf("GameServer error: %v", err)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-06-26 17:12:19 -04:00
|
|
|
}
|
2020-06-18 14:11:04 -04:00
|
|
|
}
|
2020-06-13 18:32:09 -04:00
|
|
|
}
|
|
|
|
|
2020-07-17 22:11:16 -04:00
|
|
|
func handlePlayerConnectionRequest(addr *net.UDPAddr, stringData string) error {
|
|
|
|
packetData := d2netpacket.PlayerConnectionRequestPacket{}
|
|
|
|
err := json.Unmarshal([]byte(stringData), &packetData)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("GameServer: error unmarshalling packet of type %T: %s", packetData, err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
clientConnection := d2udpclientconnection.CreateUDPClientConnection(singletonServer.udpConnection, packetData.ID, addr)
|
|
|
|
|
|
|
|
clientConnection.SetPlayerState(packetData.PlayerState)
|
|
|
|
OnClientConnected(clientConnection)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func handleMovePlayer(packetType d2netpackettype.NetPacketType, stringData string) error {
|
|
|
|
packetData := d2netpacket.MovePlayerPacket{}
|
|
|
|
err := json.Unmarshal([]byte(stringData), &packetData)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("GameServer: error unmarshalling %T: %s", packetData, err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
netPacket := d2netpacket.NetPacket{
|
|
|
|
PacketType: packetType,
|
|
|
|
PacketData: packetData,
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, player := range singletonServer.clientConnections {
|
|
|
|
err = player.SendPacketToClient(netPacket)
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("GameServer: error sending %T to client %s: %s", packetData, player.GetUniqueID(), err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func handlePingPong(stringData string) error {
|
|
|
|
packetData := d2netpacket.PlayerConnectionRequestPacket{}
|
|
|
|
err := json.Unmarshal([]byte(stringData), &packetData)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("GameServer: error unmarshalling packet of type %T: %s", packetData, err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
singletonServer.manager.Recv(packetData.ID)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func handlePlayerDisconnectNotification(stringData string) error {
|
|
|
|
var packet d2netpacket.PlayerDisconnectRequestPacket
|
|
|
|
err := json.Unmarshal([]byte(stringData), &packet)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("GameServer: error unmarshalling packet of type %T: %s", packet, err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("Received disconnect: %s", packet.ID)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// Run sets GameServer.running to true and call runNetworkServer
|
|
|
|
// in a goroutine.
|
2020-06-26 17:12:19 -04:00
|
|
|
func Run() {
|
|
|
|
log.Print("Starting GameServer")
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
singletonServer.running = true
|
2020-06-30 20:01:51 -04:00
|
|
|
_, err := singletonServer.scriptEngine.RunScript("scripts/server/server.js")
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-30 20:01:51 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Printf("GameServer: error initializing debug script: %s", err)
|
|
|
|
}
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
if singletonServer.udpConnection != nil {
|
|
|
|
go runNetworkServer()
|
|
|
|
}
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
log.Print("Network server has been started")
|
2020-06-13 18:32:09 -04:00
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// Stop sets GameServer.running to false and closes the
|
|
|
|
// GameServer's UDP connection.
|
2020-06-26 17:12:19 -04:00
|
|
|
func Stop() {
|
|
|
|
log.Print("Stopping GameServer")
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
singletonServer.running = false
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
if singletonServer.udpConnection != nil {
|
2020-06-30 20:01:51 -04:00
|
|
|
err := singletonServer.udpConnection.Close()
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("GameServer: error when trying to close UDP connection: %s", err)
|
|
|
|
}
|
2020-06-26 17:12:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// Destroy calls Stop() if the server exists.
|
2020-06-26 17:12:19 -04:00
|
|
|
func Destroy() {
|
|
|
|
if singletonServer == nil {
|
|
|
|
return
|
|
|
|
}
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
log.Print("Destroying GameServer")
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
Stop()
|
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// OnClientConnected initializes the given ClientConnection. It sends the
|
|
|
|
// following packets to the newly connected client: UpdateServerInfoPacket,
|
|
|
|
// GenerateMapPacket, AddPlayerPacket.
|
|
|
|
//
|
|
|
|
// It also sends AddPlayerPackets for each other player entity to the new
|
|
|
|
// player and vice versa, so all player entities exist on all clients.
|
|
|
|
//
|
|
|
|
// For more information, see d2networking.d2netpacket.
|
2020-06-26 17:12:19 -04:00
|
|
|
func OnClientConnected(client ClientConnection) {
|
|
|
|
// Temporary position hack --------------------------------------------
|
|
|
|
sx, sy := singletonServer.mapEngines[0].GetStartPosition() // TODO: Another temporary hack
|
|
|
|
clientPlayerState := client.GetPlayerState()
|
|
|
|
clientPlayerState.X = sx
|
|
|
|
clientPlayerState.Y = sy
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
2020-07-17 22:11:16 -04:00
|
|
|
log.Printf("Client connected with an id of %s", client.GetUniqueID())
|
|
|
|
singletonServer.clientConnections[client.GetUniqueID()] = client
|
|
|
|
err := client.SendPacketToClient(d2netpacket.CreateUpdateServerInfoPacket(singletonServer.seed, client.GetUniqueID()))
|
|
|
|
|
2020-06-30 20:01:51 -04:00
|
|
|
if err != nil {
|
2020-07-17 22:11:16 -04:00
|
|
|
log.Printf("GameServer: error sending UpdateServerInfoPacket to client %s: %s", client.GetUniqueID(), err)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-30 20:01:51 -04:00
|
|
|
err = client.SendPacketToClient(d2netpacket.CreateGenerateMapPacket(d2enum.RegionAct1Town))
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-30 20:01:51 -04:00
|
|
|
if err != nil {
|
2020-07-17 22:11:16 -04:00
|
|
|
log.Printf("GameServer: error sending GenerateMapPacket to client %s: %s", client.GetUniqueID(), err)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-06-26 17:12:19 -04:00
|
|
|
|
|
|
|
playerState := client.GetPlayerState()
|
2020-07-17 22:11:16 -04:00
|
|
|
|
|
|
|
// these are in subtiles
|
|
|
|
playerX := int(sx*subtilesPerTile) + middleOfTileOffset
|
|
|
|
playerY := int(sy*subtilesPerTile) + middleOfTileOffset
|
|
|
|
|
|
|
|
createPlayerPacket := d2netpacket.CreateAddPlayerPacket(client.GetUniqueID(),
|
|
|
|
playerState.HeroName, playerX, playerY,
|
|
|
|
playerState.HeroType, playerState.Stats, playerState.Equipment)
|
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
for _, connection := range singletonServer.clientConnections {
|
2020-06-30 20:01:51 -04:00
|
|
|
err := connection.SendPacketToClient(createPlayerPacket)
|
|
|
|
if err != nil {
|
2020-07-17 22:11:16 -04:00
|
|
|
log.Printf("GameServer: error sending %T to client %s: %s", createPlayerPacket, connection.GetUniqueID(), err)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-07-17 22:11:16 -04:00
|
|
|
|
|
|
|
if connection.GetUniqueID() == client.GetUniqueID() {
|
2020-06-26 17:12:19 -04:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
conPlayerState := connection.GetPlayerState()
|
2020-07-17 22:11:16 -04:00
|
|
|
playerX := int(conPlayerState.X*subtilesPerTile) + middleOfTileOffset
|
|
|
|
playerY := int(conPlayerState.Y*subtilesPerTile) + middleOfTileOffset
|
|
|
|
err = client.SendPacketToClient(d2netpacket.CreateAddPlayerPacket(
|
|
|
|
connection.GetUniqueID(),
|
|
|
|
conPlayerState.HeroName,
|
|
|
|
playerX, playerY,
|
|
|
|
conPlayerState.HeroType,
|
|
|
|
conPlayerState.Stats, conPlayerState.Equipment),
|
|
|
|
)
|
|
|
|
|
2020-06-30 20:01:51 -04:00
|
|
|
if err != nil {
|
2020-07-17 22:11:16 -04:00
|
|
|
log.Printf("GameServer: error sending CreateAddPlayerPacket to client %s: %s", connection.GetUniqueID(), err)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-06-26 17:12:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// OnClientDisconnected removes the given client from the list
|
|
|
|
// of client connections.
|
2020-06-26 17:12:19 -04:00
|
|
|
func OnClientDisconnected(client ClientConnection) {
|
2020-07-17 22:11:16 -04:00
|
|
|
log.Printf("Client disconnected with an id of %s", client.GetUniqueID())
|
|
|
|
delete(singletonServer.clientConnections, client.GetUniqueID())
|
2020-06-26 17:12:19 -04:00
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// OnPacketReceived is called by the local client to 'send' a packet to the server.
|
2020-06-26 17:12:19 -04:00
|
|
|
func OnPacketReceived(client ClientConnection, packet d2netpacket.NetPacket) error {
|
|
|
|
switch packet.PacketType {
|
|
|
|
case d2netpackettype.MovePlayer:
|
|
|
|
// TODO: This needs to be verified on the server (here) before sending to other clients....
|
|
|
|
// TODO: Hacky, this should be updated in realtime ----------------
|
|
|
|
// TODO: Verify player id
|
2020-07-17 22:11:16 -04:00
|
|
|
playerState := singletonServer.clientConnections[client.GetUniqueID()].GetPlayerState()
|
2020-06-26 17:12:19 -04:00
|
|
|
playerState.X = packet.PacketData.(d2netpacket.MovePlayerPacket).DestX
|
|
|
|
playerState.Y = packet.PacketData.(d2netpacket.MovePlayerPacket).DestY
|
|
|
|
// ----------------------------------------------------------------
|
|
|
|
for _, player := range singletonServer.clientConnections {
|
2020-06-30 20:01:51 -04:00
|
|
|
err := player.SendPacketToClient(packet)
|
|
|
|
if err != nil {
|
2020-07-17 22:11:16 -04:00
|
|
|
log.Printf("GameServer: error sending %T to client %s: %s", packet, player.GetUniqueID(), err)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-06-26 17:12:19 -04:00
|
|
|
}
|
2020-06-26 20:03:00 -04:00
|
|
|
case d2netpackettype.CastSkill:
|
|
|
|
for _, player := range singletonServer.clientConnections {
|
2020-06-30 20:01:51 -04:00
|
|
|
err := player.SendPacketToClient(packet)
|
|
|
|
if err != nil {
|
2020-07-17 22:11:16 -04:00
|
|
|
log.Printf("GameServer: error sending %T to client %s: %s", packet, player.GetUniqueID(), err)
|
2020-06-30 20:01:51 -04:00
|
|
|
}
|
2020-06-26 20:03:00 -04:00
|
|
|
}
|
2020-06-26 17:12:19 -04:00
|
|
|
}
|
2020-07-17 22:11:16 -04:00
|
|
|
|
2020-06-26 17:12:19 -04:00
|
|
|
return nil
|
2020-06-13 18:32:09 -04:00
|
|
|
}
|