generated from VLADIMIR/template
fixes
This commit is contained in:
Binary file not shown.
@@ -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]
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user