Documentation ¶
Overview ¶
Package gameworld provides a gameworld protocol server.
Index ¶
- Constants
- Variables
- type ChaseMode
- type Creature
- type CreatureID
- type CreatureType
- type FightMode
- type GameworldConnection
- func (c *GameworldConnection) PlayerID() (CreatureID, error)
- func (c *GameworldConnection) TestOnly_InitialAppearMap(outMap *tnet.Message) error
- func (c *GameworldConnection) TestOnly_PlayerMoveNorthImpl(outMove *tnet.Message) error
- func (c *GameworldConnection) TestOnly_Setter(clientVersion uint16, gws *GameworldServer, id GameworldConnectionID)
- type GameworldConnectionID
- type GameworldServer
- type InventorySlot
- type MapDataSource
- type MapItem
- type MapTile
- type MapTileEventSubscriber
- type Skill
- Bugs
Constants ¶
const ( // The ID of this creature determines it to be a player. // // Same in OT and TFS: https://github.com/otland/forgottenserver/blob/973855c3e0a60461117b55f248ad14bab6630780/src/player.cpp#L40 CreatureTypePlayer = CreatureType(0x10000000) // The ID of this creature determines it to be an NPC. // // Not in OT, value 0x20000000 in TFS: https://github.com/otland/forgottenserver/blob/973855c3e0a60461117b55f248ad14bab6630780/src/npc.cpp#L15 // // TFS v1.2 from 2016 used 0x80000000: https://github.com/otland/forgottenserver/blob/afeea42cee45a176aeccb330733a606e3bdcb64a/src/npc.cpp#L29C27-L29C37 CreatureTypeNPC = CreatureType(0x20000000) // The ID of this creature determines it to be a monster. // // Not using TFS value 0x21000000 in monster.cpp, choosing value in OT // and in TFS v1.2: https://github.com/opentibia/server/blob/33a81ef95a9b407533e0a7ce48aff12204b4f3b1/src/actor.h#L68 CreatureTypeMonster = CreatureType(0x40000000) )
Note: wrong constants may affect client behavior (right click options etc). The behavior with various values should be validated against various clients.
const ( //nightAmbient = color.RGBA{0, 0, 20, 240} //nightAmbient = color.RGBA{20, 20, 40, 240} NightAmbient = dat.DatasetColor(0xD7) NightAmbientLevel = uint8(40) DayAmbient = dat.DatasetColor(0xD7) DayAmbientLevel = uint8(250) )
Variables ¶
var ( ItemNotFound error // In case an item is not found, this error is returned. CreatureNotFound error // In case a creature is not found, this error is returned. )
Functions ¶
This section is empty.
Types ¶
type ChaseMode ¶
type ChaseMode uint8
ChaseMode encapsulates the player's requested behavior when it comes to chasing the targeted creature.
type Creature ¶
func BakeTestOnlyCreature ¶ added in v0.0.10
func BakeTestOnlyCreature(id CreatureID, pos tnet.Position, dir things.CreatureDirection, look uint16, col [4]things.OutfitColor) Creature
type CreatureID ¶
type CreatureID = gwmap.CreatureID
func NewCreatureID ¶
func NewCreatureID(kind CreatureType) CreatureID
NewCreatureID creates a new creature ID, unique across all data sources, and determinable to be a player, NPC, or monster.
BUG(ivucica): Move this to map data source
type CreatureType ¶ added in v0.0.3
type CreatureType uint32
Creature types are bits that determine what is the type of a particular creature. These flags need to be consistent between all data sources. Currently they are flags, but they might need to be ranges in the future.
They are used in creature IDs and *affect client behavior*.
Creature IDs within a range might be used for routing RPCs in the future.
BUG(ivucica): The creature type "NPC" has a different value between OT and TFS.
BUG(ivucica): The Forgotten Client has ranges < 0x400000000 for players, < 0x80000000 for monsters and everything else for NPCs. It also says that for >= 9.10 a creature will get a server-assigned type: 0 for players, 1 for monsters, 2 for NPCs and 3 for summoned creatures (3 is presumed and needs to be checked in servers); and on >= 11.21 a summoned creature will have the owner's ID determined and will client-side get the assigned type of 4. https://github.com/opentibiabr/The-Forgotten-Client/blob/8b7979619ea76bc29581122440d09f241afc175d/src/protocolgame.cpp#L8492-L8509
func (CreatureType) String ¶ added in v0.0.9
func (ct CreatureType) String() string
String implements the stringer type, returning all types that this creature satisfies. Usually this should be just one type.
type FightMode ¶
type FightMode uint8
FightMode encapsulates an individual player's intended requested fight stance.
type GameworldConnection ¶
type GameworldConnection struct {
// contains filtered or unexported fields
}
GameworldConnection encapsulates a single active connection (not necessarily a session, if we introduce such a concept).
func (*GameworldConnection) PlayerID ¶
func (c *GameworldConnection) PlayerID() (CreatureID, error)
PlayerID returns the player ID for this connection.
Currently it is the same as the creature ID of the player.
func (*GameworldConnection) TestOnly_InitialAppearMap ¶ added in v0.0.10
func (c *GameworldConnection) TestOnly_InitialAppearMap(outMap *tnet.Message) error
func (*GameworldConnection) TestOnly_PlayerMoveNorthImpl ¶ added in v0.0.10
func (c *GameworldConnection) TestOnly_PlayerMoveNorthImpl(outMove *tnet.Message) error
TestOnly_PlayerMoveNorthImpl is a test-only function that allows testing the playerMoveNorthImpl function. It is not meant to be exported, and is only used for testing.
func (*GameworldConnection) TestOnly_Setter ¶ added in v0.0.10
func (c *GameworldConnection) TestOnly_Setter(clientVersion uint16, gws *GameworldServer, id GameworldConnectionID)
type GameworldConnectionID ¶
type GameworldConnectionID CreatureID
GameworldConnectionID is the ID of this connection, and at this time will match the player ID. This can change in the future.
type GameworldServer ¶
type GameworldServer struct { LameDuckText string // error to serve during lame duck mode // contains filtered or unexported fields }
GameworldServer encapsulates a single gameworld server with all of the active connections. This particular implementation does not enable scaling the frontends, since all the connections are stored in a single local non-distributed map. This implementation also allows only a single map data source.
The actual gameworld protocol implementation is currently in this type, not in individual connections; the connections just store the metadata for a particular network connection from a player.
func NewServer ¶
func NewServer(pk *rsa.PrivateKey) (*GameworldServer, error)
NewServer creates a new GameworldServer which decodes the initial login message using the passed private key.
func (*GameworldServer) Serve ¶
Serve begins serving the gameworld protocol on the accepted network connection.
User of this method needs to bring their own listening schema and accept the connection, then pass on the control to this method.
User also needs to transmit the initial gameworld message which the server sends.
func (*GameworldServer) SetMapDataSource ¶
func (c *GameworldServer) SetMapDataSource(ds MapDataSource) error
SetMapDataSource sets the data source for map information such as tiles, items on tiles, creatures present, etc.
func (*GameworldServer) SetThings ¶
func (c *GameworldServer) SetThings(t *things.Things) error
SetThings sets the thing registry to the passed value. It's used to refer to a combination of items.otb, Tibia.dat and Tibia.spr from the gameworld.
It's not constructed by GameworldServer as the same registry may be used for other servers (such as a web server).
type InventorySlot ¶
type InventorySlot byte
InventorySlot is an enum type describing one of the slots where a player can directly insert an item onto the character.
const ( InventorySlotUnknown InventorySlot = iota // 0 InventorySlotHead // 1 InventorySlotNecklace // 2 InventorySlotBackpack // 3 InventorySlotArmor // 4 InventorySlotRight // 5 InventorySlotLeft // 6 InventorySlotLegs // 7 InventorySlotFeet // 8 InventorySlotRing // 9 InventorySlotAmmo // A InventorySlotFirst = InventorySlotHead InventorySlotLast = InventorySlotAmmo )
type MapDataSource ¶
type MapDataSource = gwmap.MapDataSource
Ideally this block would be empty.
Ideally in Go, we would define types as locally as possible, but this is in a separate package to allow sharing with OTBM loader and its tests.
func NewMapDataSource ¶
func NewMapDataSource() MapDataSource
NewMapDataSource returns a new procedural map data source, good for testing.
type MapItem ¶
Ideally this block would be empty.
Ideally in Go, we would define types as locally as possible, but this is in a separate package to allow sharing with OTBM loader and its tests.
type MapTile ¶
Ideally this block would be empty.
Ideally in Go, we would define types as locally as possible, but this is in a separate package to allow sharing with OTBM loader and its tests.
type MapTileEventSubscriber ¶
type MapTileEventSubscriber = gwmap.MapTileEventSubscriber
Ideally this block would be empty.
Ideally in Go, we would define types as locally as possible, but this is in a separate package to allow sharing with OTBM loader and its tests.
Notes ¶
Bugs ¶
The creature type "NPC" has a different value between OT and TFS.
The Forgotten Client has ranges < 0x400000000 for players, < 0x80000000 for monsters and everything else for NPCs. It also says that for >= 9.10 a creature will get a server-assigned type: 0 for players, 1 for monsters, 2 for NPCs and 3 for summoned creatures (3 is presumed and needs to be checked in servers); and on >= 11.21 a summoned creature will have the owner's ID determined and will client-side get the assigned type of 4. https://github.com/opentibiabr/The-Forgotten-Client/blob/8b7979619ea76bc29581122440d09f241afc175d/src/protocolgame.cpp#L8492-L8509
Move this to map data source