mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Avoid sending landmap data for Falklands.
This is too damn slow. A possible solution is explained in the comment, but we shouldn't tackle that until we're sure the rest of the game runs okay.
This commit is contained in:
parent
0cb61ea778
commit
e4d780cb61
@ -20,6 +20,10 @@ class MapZonesJs(BaseModel):
|
|||||||
class Config:
|
class Config:
|
||||||
title = "MapZones"
|
title = "MapZones"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def empty(cls) -> MapZonesJs:
|
||||||
|
return MapZonesJs(inclusion=[], exclusion=[], sea=[])
|
||||||
|
|
||||||
|
|
||||||
class UnculledZoneJs(BaseModel):
|
class UnculledZoneJs(BaseModel):
|
||||||
position: LeafletPoint
|
position: LeafletPoint
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
|
||||||
from game import Game
|
from game import Game
|
||||||
@ -10,6 +12,20 @@ router: APIRouter = APIRouter(prefix="/map-zones")
|
|||||||
|
|
||||||
@router.get("/terrain", operation_id="get_terrain_zones", response_model=MapZonesJs)
|
@router.get("/terrain", operation_id="get_terrain_zones", response_model=MapZonesJs)
|
||||||
def get_terrain(game: Game = Depends(GameContext.require)) -> MapZonesJs:
|
def get_terrain(game: Game = Depends(GameContext.require)) -> MapZonesJs:
|
||||||
|
if game.theater.terrain.name == "Falklands":
|
||||||
|
# The new high fidelity landmap is far too expensive to send to the UI.
|
||||||
|
# Converting all the points from DCS X/Y to lat/lng and then serializing all
|
||||||
|
# that data takes minutes and gigabytes (!!) of RAM.
|
||||||
|
#
|
||||||
|
# It's not clear how much the rest of Liberation is affected by the landmap
|
||||||
|
# complexity yet. If the rest of the game is tolerable we will need to start
|
||||||
|
# baking images of the landmap that can be used as an overlay in the UI rather
|
||||||
|
# than drawing it from each point.
|
||||||
|
logging.debug(
|
||||||
|
"Not sending landmap to the UI for Falklands because it's too slow"
|
||||||
|
)
|
||||||
|
return MapZonesJs.empty()
|
||||||
|
|
||||||
zones = game.theater.landmap
|
zones = game.theater.landmap
|
||||||
if zones is None:
|
if zones is None:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user