src/ai/api/ai_station.cpp
branchnoai
changeset 9696 4384ed3de1f0
parent 9670 820b77e19bb3
child 9723 eee46cb39750
equal deleted inserted replaced
9695:708f1e3cc4c4 9696:4384ed3de1f0
     6 #include "ai_cargo.hpp"
     6 #include "ai_cargo.hpp"
     7 #include "../../debug.h"
     7 #include "../../debug.h"
     8 #include "../../station.h"
     8 #include "../../station.h"
     9 #include "../../station_map.h"
     9 #include "../../station_map.h"
    10 #include "../../variables.h"
    10 #include "../../variables.h"
       
    11 #include "../../strings.h"
       
    12 #include "table/strings.h"
    11 
    13 
    12 /* static */ bool AIStation::IsValidStation(StationID station_id)
    14 /* static */ bool AIStation::IsValidStation(StationID station_id)
    13 {
    15 {
    14 	return ::IsValidStationID(station_id) && ::GetStation(station_id)->owner == _current_player;
    16 	return ::IsValidStationID(station_id) && ::GetStation(station_id)->owner == _current_player;
    15 }
    17 }
    16 
    18 
    17 /* static */ StationID AIStation::GetStationID(TileIndex tile)
    19 /* static */ StationID AIStation::GetStationID(TileIndex tile)
    18 {
    20 {
    19 	if (!::IsTileType(tile, MP_STATION)) return INVALID_STATION;
    21 	if (!::IsTileType(tile, MP_STATION)) return INVALID_STATION;
    20 	return ::GetStationIndex(tile);
    22 	return ::GetStationIndex(tile);
       
    23 }
       
    24 
       
    25 /* static */ char *AIStation::GetName(StationID station_id)
       
    26 {
       
    27 	if (!AIStation::IsValidStation(station_id)) return NULL;
       
    28 
       
    29 	static const int len = 64;
       
    30 	char *station_name = MallocT<char>(len);
       
    31 
       
    32 	SetDParam(0, GetStation(station_id)->index);
       
    33 	GetString(station_name, STR_STATION, &station_name[len - 1]);
       
    34 	return station_name;
    21 }
    35 }
    22 
    36 
    23 /* static */ TileIndex AIStation::GetLocation(StationID station_id)
    37 /* static */ TileIndex AIStation::GetLocation(StationID station_id)
    24 {
    38 {
    25 	if (!AIStation::IsValidStation(station_id)) return INVALID_TILE;
    39 	if (!AIStation::IsValidStation(station_id)) return INVALID_TILE;