movement.go: added support for basic movement packets

you should be able to view other players and jump around together,
although while testing locally one of the clients would always trigger
the "Some irregularities have been found with your connection to the
server, so your game will be closed" speed check for some reason ???

really not sure, might just be my machine

chunking uhhh works ? kind of, not tested for more than a few seconds
before one of the clients disconnects
This commit is contained in:
2023-06-25 04:27:42 -05:00
parent f6ab7a9b5d
commit 8f00a0c492
7 changed files with 119 additions and 19 deletions

View File

@@ -122,7 +122,7 @@ const (
)
func (db *DBHandler) readPlayer(rows *sql.Rows) (*entity.Player, error) {
plr := entity.Player{ActiveNanoSlotNum: -1}
plr := entity.Player{ActiveNanoSlotNum: 0}
if err := rows.Scan(
&plr.PlayerID, &plr.AccountID, &plr.Slot, &plr.PCStyle.SzFirstName, &plr.PCStyle.SzLastName,

View File

@@ -28,11 +28,16 @@ func (c *Chunk) RemoveEntity(entity Entity) {
// send packet to all peers in this chunk and kill each peer if error
func (c *Chunk) SendPacket(typeID uint32, pkt ...interface{}) {
c.SendPacketExclude(nil, typeID, pkt...)
}
func (c *Chunk) SendPacketExclude(exclude Entity, typeID uint32, pkt ...interface{}) {
c.lock.Lock()
defer c.lock.Unlock()
for entity := range c.Entities {
if entity.GetKind() != ENTITY_KIND_PLAYER {
// only send to players, and exclude the player that sent the packet
if entity.GetKind() != ENTITY_KIND_PLAYER || entity == exclude {
continue
}

View File

@@ -122,6 +122,6 @@ func (plr *Player) GetAppearanceData() protocol.SPCAppearanceData {
PCStyle: plr.PCStyle,
IPCState: plr.IPCState,
ItemEquip: plr.Equip,
Nano: protocol.SNano{}, //plr.Nanos[plr.ActiveNanoSlotNum],
Nano: plr.Nanos[plr.ActiveNanoSlotNum],
}
}