Skip to content

Commit

Permalink
fix transfer file access error
Browse files Browse the repository at this point in the history
  • Loading branch information
olebeck committed Jul 31, 2024
1 parent 4bec00f commit 1f9f939
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
10 changes: 9 additions & 1 deletion handlers/worlds/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ func (w *worldsHandler) onBlobs(blobs []proxy.BlobResp, fromCache bool) (err err
}
}

w.worldStateLock.Lock()
defer w.worldStateLock.Unlock()
for pos, biome := range biomes {
ch, ok, err := w.currentWorld.LoadChunk(world.ChunkPos{pos[0], pos[2]})
wpos := world.ChunkPos{pos[0], pos[2]}
ch, ok, err := w.currentWorld.LoadChunk(wpos)
if err != nil {
return err
}
Expand All @@ -151,6 +154,11 @@ func (w *worldsHandler) onBlobs(blobs []proxy.BlobResp, fromCache bool) (err err
if err != nil {
return err
}

err = w.currentWorld.StoreChunk(wpos, ch, nil)
if err != nil {
return err
}
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions handlers/worlds/packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ func (w *worldsHandler) packetCB(_pk packet.Packet, toServer bool, timeReceived

// player
case *packet.AddPlayer:
w.currentWorld.AddPlayer(pk)
w.addPlayer(pk)
//w.currentWorld.AddPlayer(pk)
//w.addPlayer(pk)
case *packet.PlayerList:
if pk.ActionType == packet.PlayerListActionAdd { // remove
for _, player := range pk.Entries {
Expand Down
4 changes: 4 additions & 0 deletions utils/proxy/blobcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func blobKey(h uint64) []byte {
return k
}

func (b *Blobcache) Close() error {
return b.db.Close()
}

func (b *Blobcache) loadBlob(blobHash uint64) ([]byte, error) {
blob, err := b.db.Get(blobKey(blobHash), nil)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions utils/proxy/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (s *Session) Run(ctx context.Context, connect *utils.ConnectInfo) error {
return err
}
s.blobCache.OnBlobs = s.handlers.OnBlobs
defer s.blobCache.Close()

if connect.Replay != "" {
replay, err := CreateReplayConnector(ctx, connect.Replay, s.packetFunc, rpHandler)
Expand Down

0 comments on commit 1f9f939

Please sign in to comment.