Skip to content

Commit

Permalink
Parse protos in QuestStrategy.py when fetching it from MitmMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Grennith committed Apr 5, 2024
1 parent 0ff677a commit a763dd3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mapadroid/worker/strategy/quest/QuestStrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
from abc import ABC, abstractmethod
from datetime import timedelta
from enum import Enum
from typing import Dict, List, Optional, Set, Tuple, Union, Any
from typing import Any, Dict, List, Optional, Set, Tuple, Union

from google.protobuf.internal.containers import RepeatedCompositeFieldContainer
from loguru import logger
from s2sphere import CellId
from sqlalchemy import exc
from sqlalchemy.ext.asyncio import AsyncSession

import mapadroid.mitm_receiver.protos.Rpc_pb2 as pogoprotos
from mapadroid.data_handler.mitm_data.AbstractMitmMapper import \
AbstractMitmMapper
from mapadroid.data_handler.mitm_data.holder.latest_mitm_data.LatestMitmDataEntry import \
Expand Down Expand Up @@ -50,7 +51,6 @@
from mapadroid.worker.strategy.AbstractMitmBaseStrategy import \
AbstractMitmBaseStrategy
from mapadroid.worker.WorkerState import WorkerState
import mapadroid.mitm_receiver.protos.Rpc_pb2 as pogoprotos

# The diff to lat/lng values to consider that the worker is standing on top of the stop
S2_GMO_CELL_LEVEL = 15
Expand Down Expand Up @@ -578,11 +578,10 @@ async def _ensure_stop_present(self, timestamp: float) -> PositionStopType:
async def _current_position_has_spinnable_stop(self, timestamp: float) -> PositionStopType:
type_received, data_received, time_received = await self._wait_for_data_after_moving(timestamp,
ProtoIdentifier.GMO, 35)
if (type_received != ReceivedType.GMO or data_received is None
or not isinstance(data_received, pogoprotos.GetMapObjectsOutProto)):
if type_received != ReceivedType.GMO or data_received is None:
await self._spinnable_data_failure()
return PositionStopType.GMO_NOT_AVAILABLE
latest_proto: pogoprotos.GetMapObjectsOutProto = data_received
latest_proto: pogoprotos.GetMapObjectsOutProto = ProtoHelper.parse(ProtoIdentifier.GMO, data_received)

if not latest_proto.map_cell:
logger.warning("Can't spin stop - no map info in GMO!")
Expand Down

0 comments on commit a763dd3

Please sign in to comment.