mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-06 19:44:15 -04:00
* fixed lint error in d2app/app.go * go fmt entire project * adding doc.go for d2records * fixed lint issues in d2core/d2map * fixed lint error in d2interface/palette.go * fixed lint error in d2core/d2hero/hero_state_factory.go * adding dov.go to d2common/d2geom * fixing lint errors in d2common/d2loader * adding doc.go to d2common/d2cache * adding doc files for d2datautils, d2util, d2path * adding package doc strings for mapgen, in-geam help screen, and tcp client connection * removed all cuddling lint errors * changed stamina equality check to '<=' instead of '<'
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package d2netpacket
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2netpacket/d2netpackettype"
|
|
)
|
|
|
|
// GenerateMapPacket contains an enumerable representing a region. It
|
|
// is sent by the server to generate the map for the given region on
|
|
// a client.
|
|
type GenerateMapPacket struct {
|
|
RegionType d2enum.RegionIdType `json:"regionType"`
|
|
}
|
|
|
|
// CreateGenerateMapPacket returns a NetPacket which declares a
|
|
// GenerateMapPacket with the given regionType.
|
|
func CreateGenerateMapPacket(regionType d2enum.RegionIdType) NetPacket {
|
|
generateMapPacket := GenerateMapPacket{
|
|
RegionType: regionType,
|
|
}
|
|
|
|
b, err := json.Marshal(generateMapPacket)
|
|
if err != nil {
|
|
log.Print(err)
|
|
}
|
|
|
|
return NetPacket{
|
|
PacketType: d2netpackettype.GenerateMap,
|
|
PacketData: b,
|
|
}
|
|
}
|
|
|
|
func UnmarshalGenerateMap(packet []byte) (GenerateMapPacket, error) {
|
|
var p GenerateMapPacket
|
|
if err := json.Unmarshal(packet, &p); err != nil {
|
|
return p, err
|
|
}
|
|
|
|
return p, nil
|
|
}
|