예제 #1
0
/// Gets the next direction the caravane has to take
unsigned char TradeRoute::GetNextDir()
{
    if(curPos == path.goal)
        return REACHED_GOAL;

    if(curRouteIdx >= path.route.size())
        return INVALID_DIR;

    Direction nextDir;
    // Check if the route is still valid
    if(gwg.CheckTradeRoute(curPos, path.route, curRouteIdx, player))
        nextDir = path.route[curRouteIdx];
    else
    {
        // If not, recalc it
        uint8_t calculatedNextDir = RecalcRoute();
        // Check if we found a valid direction
        if(calculatedNextDir >= 6)
            return calculatedNextDir; // If not, bail out
        nextDir = Direction::fromInt(calculatedNextDir);
    }

    RTTR_Assert(nextDir == path.route[curRouteIdx]);
    curRouteIdx++;
    curPos = gwg.GetNeighbour(curPos, nextDir);
    return nextDir.toUInt();
}
예제 #2
0
unsigned short World::GetSeaId(const unsigned harborId, const Direction dir) const
{
    RTTR_Assert(harborId);
    return harbor_pos[harborId].cps[dir.toUInt()].seaId;
}
예제 #3
0
void SetLeftTerrain(GameWorldGame& world, const MapPoint& pt, Direction dir, TerrainType t)
{
    SetRightTerrain(world, pt, Direction(dir.toUInt() + 6 - 1), t);
}