This commit is contained in:
2026-09-10 14:44:20 +07:00
parent 07576ee5fd
commit 27812c3781
4 changed files with 12 additions and 1 deletions
Binary file not shown.
+6
View File
@@ -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]
+5
View File
@@ -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
}
+1 -1
View File
@@ -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