diff --git a/bin/evening_detective_server b/bin/evening_detective_server index d7b72d1..5bfa59c 100755 Binary files a/bin/evening_detective_server and b/bin/evening_detective_server differ diff --git a/internal/app/server.go b/internal/app/server.go index 23dea8e..7fc9514 100644 --- a/internal/app/server.go +++ b/internal/app/server.go @@ -230,6 +230,12 @@ func (s *server) GetGameMap(ctx context.Context, req *proto.GetGameMapReq) (*pro } result := make([]*proto.MapItem, 0, len(items)) for _, item := range items { + if item.Kind == "screen" && screenStates[item.ItemID] == nil { + if err := s.mapRepo.Delete(ctx, item); err != nil { + return nil, status.Error(codes.Internal, "не удалось обновить карту") + } + continue + } mapped := &proto.MapItem{Kind: item.Kind, ItemId: int32(item.ItemID), X: int32(item.X), Y: int32(item.Y), Hidden: item.Hidden} if item.Kind == "team" { mapped.Label = teamNames[item.ItemID] diff --git a/internal/repos/game_map_repo/repo.go b/internal/repos/game_map_repo/repo.go index 13fb50c..fc27a19 100644 --- a/internal/repos/game_map_repo/repo.go +++ b/internal/repos/game_map_repo/repo.go @@ -60,3 +60,8 @@ func (r *Repo) Update(ctx context.Context, item Item) error { } return nil } + +func (r *Repo) Delete(ctx context.Context, item Item) error { + _, err := r.pool.Exec(ctx, `DELETE FROM game_map_items WHERE game_id = $1 AND kind = $2 AND item_id = $3`, item.GameID, item.Kind, item.ItemID) + return err +} diff --git a/internal/repos/screen_sessions_repo/repo.go b/internal/repos/screen_sessions_repo/repo.go index 366aa1c..c52895b 100644 --- a/internal/repos/screen_sessions_repo/repo.go +++ b/internal/repos/screen_sessions_repo/repo.go @@ -115,7 +115,7 @@ func (r *ScreenSessionsRepo) Bind(ctx context.Context, id, gameID int, tokenHash func (r *ScreenSessionsRepo) Unbind(ctx context.Context, id int) error { result, err := r.pool.Exec(ctx, ` UPDATE screen_sessions - SET game_id = NULL, updated_at = NOW() + SET game_id = NULL, mode = 1, command = 0, position_ms = 0, state_version = state_version + 1, updated_at = NOW() WHERE id = $1`, id) if err != nil { return err