uod

package
v0.0.0-...-b0deb01 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2023 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSaveFileExists = errors.New("refusing to truncate existing save file")

File truncation error

View Source
var ErrSaveFileLocked = errors.New("the save file is currently locked")

File lock error

View Source
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

func Find[T game.Object](id uo.Serial) T

Find returns the object with the given serial, or nil if it is not found in the game data store.

func GameServerMain

func GameServerMain(wg *sync.WaitGroup)

func GlobalChat

func GlobalChat(hue uo.Hue, who, text string)

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

func LoginServerMain(wg *sync.WaitGroup)

LoginServerMain is the entry point for the login server.

func Main

func Main()

Main is the entry point for uod.

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.

func (*Blacklist) Match

func (b *Blacklist) Match(a net.IP) bool

Match returns true if the given IP matches any of the patterns. This function is concurrent safe.

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.

func (BlacklistPattern) Match

func (p BlacklistPattern) Match(a net.IP) bool

Match returns true if there is a match between the pattern and the passed address.

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.

func (*Cron) Main

func (c *Cron) Main(wg *sync.WaitGroup)

Main is the main loop for the Cron daemon.

func (*Cron) Stop

func (c *Cron) Stop()

Stop stops the cron daemon process.

type NetState

type NetState struct {
	// contains filtered or unexported fields
}

NetState manages the network state of a single connection.

func NewNetState

func NewNetState(conn *net.TCPConn) *NetState

NewNetState constructs a new NetState object.

func (*NetState) Account

func (n *NetState) Account() *game.Account

Account returns the account associated with this NetState.

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) Cliloc

func (n *NetState) Cliloc(speaker game.Object, cliloc uo.Cliloc, args ...string)

Cliloc sends a localized client message packet to the attached client.

func (*NetState) CloseGump

func (n *NetState) CloseGump(gump uo.Serial)

CloseGump closes the named gump on the client

func (*NetState) ContainerClose

func (n *NetState) ContainerClose(c game.Container)

ContainerClose implements the game.ContainerObserver interface

func (*NetState) ContainerIsObserving

func (n *NetState) ContainerIsObserving(o game.Object) bool

ContainerIsObserving implements the game.ContainerObserver interface

func (*NetState) ContainerItemAdded

func (n *NetState) ContainerItemAdded(c game.Container, item game.Item)

ContainerItemAdded implements the game.ContainerObserver interface

func (*NetState) ContainerItemOPLChanged

func (n *NetState) ContainerItemOPLChanged(c game.Container, item game.Item)

ContainerItemOPLChanged implements the game.ContainerObserver interface.

func (*NetState) ContainerItemRemoved

func (n *NetState) ContainerItemRemoved(c game.Container, item game.Item)

ContainerItemRemoved implements the game.ContainerObserver interface

func (*NetState) ContainerOpen

func (n *NetState) ContainerOpen(c game.Container)

ContainerOpen implements the game.ContainerObserver interface

func (*NetState) ContainerRangeCheck

func (n *NetState) ContainerRangeCheck()

ContainerRangeCheck implements the game.ContainerObserver interface

func (*NetState) Disconnect

func (n *NetState) Disconnect()

Disconnect disconnects the NetState.

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) GUMP

func (n *NetState) GUMP(gi any, target, param game.Object)

GUMP sends a generic GUMP to the client.

func (*NetState) GUMPReply

func (n *NetState) GUMPReply(s uo.Serial, p *clientpacket.GUMPReply)

GUMPReply dispatches a GUMP reply

func (*NetState) GetGUMPByID

func (n *NetState) GetGUMPByID(s uo.Serial) any

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) GetText

func (n *NetState) GetText(value, description string, max int, fn func(string))

GetText sends a GUMP for text entry.

func (*NetState) HandleGUMPTextReply

func (n *NetState) HandleGUMPTextReply(value string)

HandleGUMPTextReply handles text GUMP reply packets.

func (*NetState) Mobile

func (n *NetState) Mobile() game.Mobile

Mobile returns the mobile associated with the state if any.

func (*NetState) MoveMobile

func (n *NetState) MoveMobile(mob game.Mobile)

MoveMobile implements the game.NetState interface.

func (*NetState) Music

func (n *NetState) Music(song uo.Music)

Music makes the client play a song.

func (*NetState) OpenPaperDoll

func (n *NetState) OpenPaperDoll(m game.Mobile)

OpenPaperDoll implements the game.NetState interface

func (*NetState) RefreshGUMP

func (n *NetState) RefreshGUMP(gi any)

RefreshGUMP refreshes the passed GUMP on the client side.

func (*NetState) RemoveObject

func (n *NetState) RemoveObject(o game.Object)

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

func (n *NetState) SendObject(o game.Object)

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) Sound

func (n *NetState) Sound(which uo.Sound, from uo.Location)

Sound makes the client play a sound.

func (*NetState) Speech

func (n *NetState) Speech(speaker game.Object, fmtstr string, args ...interface{})

Speech sends a speech packet to the attached client.

func (*NetState) TakeAction

func (n *NetState) TakeAction() bool

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

func (n *NetState) UpdateObject(o game.Object)

UpdateObject implements the game.NetState interface.

func (*NetState) UpdateSkill

func (n *NetState) UpdateSkill(which uo.Skill, lock uo.SkillLock, value int)

UpdateSkill implements the game.NetState interface.

func (*NetState) WornItem

func (n *NetState) WornItem(wearable game.Wearable, wearer game.Mobile)

WornItem sends the WornItem packet to the given mobile

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

func (w *World) Accounts() []*game.Account

Accounts returns a slice of pointers to all accounts on the server for admin purposes.

func (*World) AuthenticateAccount

func (w *World) AuthenticateAccount(username, passwordHash string) *game.Account

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

func (w *World) BroadcastMessage(speaker game.Object, fmtstr string, args ...interface{})

BroadcastMessage implements the game.World interface.

func (*World) BroadcastPacket

func (w *World) BroadcastPacket(p serverpacket.Packet)

BroadcastPacket implements the game.World interface.

func (*World) Delete

func (w *World) Delete(o game.Object)

Delete implements the game.World interface.

func (*World) Find

func (w *World) Find(id uo.Serial) game.Object

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

func (w *World) Insert(o game.Object)

Insert inserts the object into the world's datastores blindly. Used during unmarshalling.

func (*World) LatestSavePath

func (w *World) LatestSavePath() string

LatestSavePath returns the path to the most recent save file or directory

func (*World) Main

func (w *World) Main(wg *sync.WaitGroup)

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) Map

func (w *World) Map() *game.Map

Map returns the map the world is using.

func (*World) Marshal

func (w *World) Marshal() (*sync.WaitGroup, error)

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

func (w *World) ServerTime() time.Time

ServerTime implements the game.World interface.

func (*World) Stop

func (w *World) Stop()

Stop attempts to gracefully shut down the world process.

func (*World) Time

func (w *World) Time() uo.Time

Time implements the game.World interface.

func (*World) Unmarshal

func (w *World) Unmarshal() error

Unmarshal reads in all of the data stores we are responsible for.

func (*World) Update

func (w *World) Update(o game.Object)

Update implements the game.World interface.

func (*World) UpdateOPLInfo

func (w *World) UpdateOPLInfo(o game.Object)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL