MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / pathExists

Method pathExists

source/gamemap/GameMap.cpp:1384–1433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1382}
1383
1384bool GameMap::pathExists(const Creature* creature, Tile* tileStart, Tile* tileEnd)
1385{
1386 // If floodfill is not enabled, we cannot check if the path exists so we return true
1387 if(!mFloodFillEnabled)
1388 return true;
1389
1390 // We check if the tile we are heading to is walkable. We don't do the same for the start tile because it might
1391 //not be the case if a creature is on a door tile while it is closed
1392 if(creature == nullptr)
1393 return false;
1394
1395 FloodFillType floodFill = FloodFillType::ground;
1396 if((creature->getMoveSpeedGround() > 0.0) &&
1397 (creature->getMoveSpeedWater() > 0.0) &&
1398 (creature->getMoveSpeedLava() > 0.0))
1399 {
1400 floodFill = FloodFillType::groundWaterLava;
1401 }
1402 if((creature->getMoveSpeedGround() > 0.0) &&
1403 (creature->getMoveSpeedWater() > 0.0))
1404 {
1405 floodFill = FloodFillType::groundWater;
1406 }
1407 if((creature->getMoveSpeedGround() > 0.0) &&
1408 (creature->getMoveSpeedLava() > 0.0))
1409 {
1410 floodFill = FloodFillType::groundLava;
1411 }
1412
1413 if(creature->getDefinition()->isWorker())
1414 {
1415 // Workers can go on a tile if and only if the path is open for any creature. If it is closed, that
1416 // means that a door is closed
1417 for(Seat* seat : mSeats)
1418 {
1419 if(tileStart->isSameFloodFill(seat, floodFill, tileEnd))
1420 continue;
1421
1422 return false;
1423 }
1424
1425 return true;
1426 }
1427 else
1428 {
1429 // For fighters, we can test their seat only because if they reach a closed enemy door, they
1430 // will attack it
1431 return tileStart->isSameFloodFill(creature->getSeat(), floodFill, tileEnd);
1432 }
1433}
1434
1435std::list<Tile*> GameMap::path(int x1, int y1, int x2, int y2, const Creature* creature, Seat* seat, bool throughDiggableTiles)
1436{

Callers 15

handleSearchFoodMethod · 0.80
handleSearchJobMethod · 0.80
handleClaimWallTileMethod · 0.80
handleStealFreeGoldMethod · 0.80
handleSearchTileToDigMethod · 0.80
handleFindHomeMethod · 0.80
handleGetFeeMethod · 0.80
handleDigTileMethod · 0.80
handleSearchFoeMethod · 0.80

Calls 7

isWorkerMethod · 0.80
getDefinitionMethod · 0.80
isSameFloodFillMethod · 0.80
getMoveSpeedGroundMethod · 0.45
getMoveSpeedWaterMethod · 0.45
getMoveSpeedLavaMethod · 0.45
getSeatMethod · 0.45

Tested by

no test coverage detected