mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-14 12:00:05 +00:00
CPunch
1f66acfd25
started out as me making a service abstraction.. - db.Player exists again, and entity.Player uses it as an embedded struct - chunk.ForEachEntity() lets you add/remove entities during iteration now - removed account related fields from CNPeer - protocol/pool has been merged with protocol. use protocol.GetBuffer() and protocol.PutBuffer(). - new protocol/internal/service! service.Service is an abstraction layer to handle multiple CNPeer* connections and allows you to associate each with an interface{} uData. In the future it might also handle a task queue for jobs that modify/interact with the player's uData, called from service.handleEvents() - PacketHandler callback type has a new param! uData is passed as well now - much of loginserver/shardserver is now handled by the shared service abstraction - SHARD: NPC_ENTER packets are now sent on player loading complete rather than on enter.
22 lines
350 B
Go
22 lines
350 B
Go
package protocol
|
|
|
|
import (
|
|
"bytes"
|
|
"sync"
|
|
)
|
|
|
|
var allocator = &sync.Pool{
|
|
New: func() any { return new(bytes.Buffer) },
|
|
}
|
|
|
|
// grabs a *bytes.Buffer from the pool
|
|
func GetBuffer() *bytes.Buffer {
|
|
return allocator.Get().(*bytes.Buffer)
|
|
}
|
|
|
|
// returns a *bytes.Buffer to the pool
|
|
func PutBuffer(buf *bytes.Buffer) {
|
|
buf.Reset()
|
|
allocator.Put(buf)
|
|
}
|