Documentation ¶
Index ¶
- Variables
- func Broadcast(format string, args ...interface{})
- func BroadcastPacket(p serverpacket.Packet)
- func Find[T game.Object](id uo.Serial) T
- func GameServerMain(wg *sync.WaitGroup)
- func GlobalChat(hue uo.Hue, who, text string)
- func InitializeCron() error
- func LoginServerMain(wg *sync.WaitGroup)
- func Main()
- func StopGameService()
- func StopLoginService()
- func UpdateNetStates(group int)
- type BaseWorldRequest
- type Blacklist
- type BlacklistPattern
- type BlacklistPatternOctet
- type CharacterLoginRequest
- type CharacterLogoutRequest
- type ClientPacketRequest
- type Cron
- type NetState
- func (n *NetState) Account() *game.Account
- func (n *NetState) Animate(mob game.Mobile, at uo.AnimationType, aa uo.AnimationAction)
- func (n *NetState) Cliloc(speaker game.Object, cliloc uo.Cliloc, args ...string)
- func (n *NetState) CloseGump(gump uo.Serial)
- func (n *NetState) ContainerClose(c game.Container)
- func (n *NetState) ContainerIsObserving(o game.Object) bool
- func (n *NetState) ContainerItemAdded(c game.Container, item game.Item)
- func (n *NetState) ContainerItemOPLChanged(c game.Container, item game.Item)
- func (n *NetState) ContainerItemRemoved(c game.Container, item game.Item)
- func (n *NetState) ContainerOpen(c game.Container)
- func (n *NetState) ContainerRangeCheck()
- func (n *NetState) Disconnect()
- func (n *NetState) DragItem(item game.Item, srcMob game.Mobile, srcLoc uo.Location, destMob game.Mobile, ...)
- func (n *NetState) DrawPlayer()
- func (n *NetState) DropReject(reason uo.MoveItemRejectReason)
- func (n *NetState) GUMP(gi any, target, param game.Object)
- func (n *NetState) GUMPReply(s uo.Serial, p *clientpacket.GUMPReply)
- func (n *NetState) GetGUMPByID(s uo.Serial) any
- func (n *NetState) GetText(value, description string, max int, fn func(string))
- func (n *NetState) HandleGUMPTextReply(value string)
- func (n *NetState) Mobile() game.Mobile
- func (n *NetState) MoveMobile(mob game.Mobile)
- func (n *NetState) Music(song uo.Music)
- func (n *NetState) OpenPaperDoll(m game.Mobile)
- func (n *NetState) RefreshGUMP(gi any)
- func (n *NetState) RemoveObject(o game.Object)
- func (n *NetState) Send(sp serverpacket.Packet) bool
- func (n *NetState) SendAllSkills()
- func (n *NetState) SendObject(o game.Object)
- func (n *NetState) SendService()
- func (n *NetState) Service()
- func (n *NetState) Sound(which uo.Sound, from uo.Location)
- func (n *NetState) Speech(speaker game.Object, fmtstr string, args ...interface{})
- func (n *NetState) TakeAction() bool
- func (n *NetState) TargetResponse(r *clientpacket.TargetResponse)
- func (n *NetState) TargetSendCursor(ttype uo.TargetType, fn func(*clientpacket.TargetResponse))
- func (n *NetState) Update()
- func (n *NetState) UpdateObject(o game.Object)
- func (n *NetState) UpdateSkill(which uo.Skill, lock uo.SkillLock, value int)
- func (n *NetState) WornItem(wearable game.Wearable, wearer game.Mobile)
- type World
- func (w *World) Accounts() []*game.Account
- func (w *World) AuthenticateAccount(username, passwordHash string) *game.Account
- func (w *World) BroadcastMessage(speaker game.Object, fmtstr string, args ...interface{})
- func (w *World) BroadcastPacket(p serverpacket.Packet)
- func (w *World) Delete(o game.Object)
- func (w *World) Find(id uo.Serial) game.Object
- func (w *World) GetItemDefinition(g uo.Graphic) *uo.StaticDefinition
- func (w *World) Insert(o game.Object)
- func (w *World) LatestSavePath() string
- func (w *World) Main(wg *sync.WaitGroup)
- func (w *World) Map() *game.Map
- func (w *World) Marshal() (*sync.WaitGroup, error)
- func (w *World) Random() uo.RandomSource
- func (w *World) SendRequest(cmd WorldRequest) (closed bool)
- func (w *World) ServerTime() time.Time
- func (w *World) Stop()
- func (w *World) Time() uo.Time
- func (w *World) Unmarshal() error
- func (w *World) Update(o game.Object)
- func (w *World) UpdateOPLInfo(o game.Object)
- type WorldRequest
Constants ¶
This section is empty.
Variables ¶
var ErrSaveFileExists = errors.New("refusing to truncate existing save file")
File truncation error
var ErrSaveFileLocked = errors.New("the save file is currently locked")
File lock error
var ErrWrongPacket = errors.New("wrong packet")
ErrWrongPacket is the error logged when the client sends an unexpected packet during character login.
Functions ¶
func Broadcast ¶
func Broadcast(format string, args ...interface{})
Broadcast sends a system-wide broadcast message to all connected clients.
func BroadcastPacket ¶
func BroadcastPacket(p serverpacket.Packet)
BroadcastPacket sends a packet to every connected net state with an attached mobile.
func Find ¶
Find returns the object with the given serial, or nil if it is not found in the game data store.
func GameServerMain ¶
func GlobalChat ¶
GlobalChat sends a global chat message to all connected clients.
func InitializeCron ¶
func InitializeCron() error
InitializeCron loads the crontab into the global cron object.
func LoginServerMain ¶
LoginServerMain is the entry point for the login server.
func StopGameService ¶
func StopGameService()
StopGameService attempts to gracefully shut down the game service
func StopLoginService ¶
func StopLoginService()
StopLoginService attempts to gracefully stop the login service.
func UpdateNetStates ¶
func UpdateNetStates(group int)
Executes the update method on all net states in the numbered update group.
Types ¶
type BaseWorldRequest ¶
type BaseWorldRequest struct { // The net state associated with the command, if any. System commands tend // not to have associated net states. NetState *NetState }
BaseWorldRequest provides the base implementation of WorldRequest except for Execute and GetID to force includers to provide their own.
func (*BaseWorldRequest) GetNetState ¶
func (r *BaseWorldRequest) GetNetState() *NetState
GetNetState implements the WorldRequest interface
type Blacklist ¶
type Blacklist struct {
// contains filtered or unexported fields
}
Blacklist is a collection of patterns that can be queried as a whole.
type BlacklistPattern ¶
type BlacklistPattern []BlacklistPatternOctet
BlacklistPattern is a pattern of IPv4 address octet search parameters.
func NewBlacklistPattern ¶
func NewBlacklistPattern(s string) BlacklistPattern
NewBlacklist parses a string into a BlacklistPattern.
type BlacklistPatternOctet ¶
type BlacklistPatternOctet uint16
BlacklistPatternOctet represents one octet pattern for IPv4.
const BlacklistPatternOctetAll BlacklistPatternOctet = 0xFFFF // Match any value.
type CharacterLoginRequest ¶
type CharacterLoginRequest struct {
BaseWorldRequest
}
CharacterLoginRequest is sent by the server accepting a character login
func (*CharacterLoginRequest) Execute ¶
func (r *CharacterLoginRequest) Execute() error
Execute implements the WorldRequest interface
type CharacterLogoutRequest ¶
type CharacterLogoutRequest struct { BaseWorldRequest // Mobile is the mobile of the player logging out Mobile game.Mobile }
CharacterLogoutRequest is sent when the client's network connection ends for any reason.
func (*CharacterLogoutRequest) Execute ¶
func (r *CharacterLogoutRequest) Execute() error
Execute implements the WorldRequest interface
type ClientPacketRequest ¶
type ClientPacketRequest struct { BaseWorldRequest // The client or system packet associated with this command. Packet clientpacket.Packet }
ClientPacketRequest is sent by the NetState for packets that should be addressed directly in the world goroutine.
func (*ClientPacketRequest) Execute ¶
func (r *ClientPacketRequest) Execute() error
Execute implements the WorldRequest interface
type Cron ¶
type Cron struct {
// contains filtered or unexported fields
}
Cron reads the crontab file and executes commands at the prescribed time.
type NetState ¶
type NetState struct {
// contains filtered or unexported fields
}
NetState manages the network state of a single connection.
func NewNetState ¶
NewNetState constructs a new NetState object.
func (*NetState) Animate ¶
func (n *NetState) Animate(mob game.Mobile, at uo.AnimationType, aa uo.AnimationAction)
Animate animates a mobile on the client side
func (*NetState) ContainerClose ¶
ContainerClose implements the game.ContainerObserver interface
func (*NetState) ContainerIsObserving ¶
ContainerIsObserving implements the game.ContainerObserver interface
func (*NetState) ContainerItemAdded ¶
ContainerItemAdded implements the game.ContainerObserver interface
func (*NetState) ContainerItemOPLChanged ¶
ContainerItemOPLChanged implements the game.ContainerObserver interface.
func (*NetState) ContainerItemRemoved ¶
ContainerItemRemoved implements the game.ContainerObserver interface
func (*NetState) ContainerOpen ¶
ContainerOpen implements the game.ContainerObserver interface
func (*NetState) ContainerRangeCheck ¶
func (n *NetState) ContainerRangeCheck()
ContainerRangeCheck implements the game.ContainerObserver interface
func (*NetState) DragItem ¶
func (n *NetState) DragItem(item game.Item, srcMob game.Mobile, srcLoc uo.Location, destMob game.Mobile, destLoc uo.Location)
DragItem sends the DragItem packet to the given mobile
func (*NetState) DrawPlayer ¶
func (n *NetState) DrawPlayer()
DrawPlayer implements the game.NetState interface.
func (*NetState) DropReject ¶
func (n *NetState) DropReject(reason uo.MoveItemRejectReason)
DropReject sends an item move reject packet
func (*NetState) GUMPReply ¶
func (n *NetState) GUMPReply(s uo.Serial, p *clientpacket.GUMPReply)
GUMPReply dispatches a GUMP reply
func (*NetState) GetGUMPByID ¶
GetGUMPByID returns a pointer to the identified GUMP or nil if the state does not currently have a GUMP of that type open.
func (*NetState) HandleGUMPTextReply ¶
HandleGUMPTextReply handles text GUMP reply packets.
func (*NetState) MoveMobile ¶
MoveMobile implements the game.NetState interface.
func (*NetState) OpenPaperDoll ¶
OpenPaperDoll implements the game.NetState interface
func (*NetState) RefreshGUMP ¶
RefreshGUMP refreshes the passed GUMP on the client side.
func (*NetState) RemoveObject ¶
RemoveObject implements the game.NetState interface.
func (*NetState) Send ¶
func (n *NetState) Send(sp serverpacket.Packet) bool
Send attempts to add a packet to the client's send queue and returns false if the queue is full.
func (*NetState) SendAllSkills ¶
func (n *NetState) SendAllSkills()
SendAllSkills sends all skill values and lock states to the client.
func (*NetState) SendObject ¶
SendObject implements the game.NetState interface.
func (*NetState) SendService ¶
func (n *NetState) SendService()
SendService is the goroutine that services the send queue.
func (*NetState) Service ¶
func (n *NetState) Service()
Service is the goroutine that services the netstate.
func (*NetState) TakeAction ¶
TakeAction returns true if an action is allowed at this time. Examples of actions are double-clicking basically anything or lifting an item. This method assumes that the action will be taken after this call and sets internal states to limit action speed.
func (*NetState) TargetResponse ¶
func (n *NetState) TargetResponse(r *clientpacket.TargetResponse)
TargetResponse handles the target response
func (*NetState) TargetSendCursor ¶
func (n *NetState) TargetSendCursor(ttype uo.TargetType, fn func(*clientpacket.TargetResponse))
TargetSendCursor implements the game.NetState interface
func (*NetState) Update ¶
func (n *NetState) Update()
Update should be called once per real-world second to search for stale net states, expired targeting cursors, etc.
func (*NetState) UpdateObject ¶
UpdateObject implements the game.NetState interface.
func (*NetState) UpdateSkill ¶
UpdateSkill implements the game.NetState interface.
type World ¶
type World struct {
// contains filtered or unexported fields
}
World encapsulates all of the data for the world and the goroutine that manipulates it.
func NewWorld ¶
func NewWorld(savePath string, rng uo.RandomSource) *World
NewWorld creates a new, empty world
func (*World) Accounts ¶
Accounts returns a slice of pointers to all accounts on the server for admin purposes.
func (*World) AuthenticateAccount ¶
AuthenticateAccount attempts to authenticate an account by username and password hash. If no account exists for that username, a new one will be created for the user. If an account is found but the password hashes do not match nil is returned. Otherwise the account is returned. If no accounts exist in the accounts datastore at all, the newly created account will have super-user permissions and a message will be logged.
func (*World) BroadcastMessage ¶
BroadcastMessage implements the game.World interface.
func (*World) BroadcastPacket ¶
func (w *World) BroadcastPacket(p serverpacket.Packet)
BroadcastPacket implements the game.World interface.
func (*World) Find ¶
Find returns the object with the given serial, or nil if it is not found in the game data store.
func (*World) GetItemDefinition ¶
func (w *World) GetItemDefinition(g uo.Graphic) *uo.StaticDefinition
GetItemDefinition returns the uo.StaticDefinition that holds the static data for a given item graphic.
func (*World) Insert ¶
Insert inserts the object into the world's datastores blindly. Used during unmarshalling.
func (*World) LatestSavePath ¶
LatestSavePath returns the path to the most recent save file or directory
func (*World) Main ¶
Main is the goroutine that services the command queue and is the only goroutine allowed to interact with the contents of the world.
func (*World) Marshal ¶
Marshal writes all of the data stores that the world is responsible for. A WaitGroup is returned to wait for the file to be written to disk.
func (*World) Random ¶
func (w *World) Random() uo.RandomSource
Random returns the uo.RandomSource the world is using for sync operations
func (*World) SendRequest ¶
func (w *World) SendRequest(cmd WorldRequest) (closed bool)
SendRequest sends a WorldRequest to the world's goroutine. Returns true if the command was successfully queued. This never blocks.
func (*World) ServerTime ¶
ServerTime implements the game.World interface.
func (*World) Stop ¶
func (w *World) Stop()
Stop attempts to gracefully shut down the world process.
func (*World) UpdateOPLInfo ¶
UpdateOPLInfo adds the object to the list of objects that must have their OPL data updated client-side.
type WorldRequest ¶
type WorldRequest interface { // Returns the NetState associated with this request, if any GetNetState() *NetState // Execute executes the request Execute() error }
WorldRequest is used to send client and system packets to the world's goroutine.