#ifndef CTP_API_H__ #define CTP_API_H__ #include "player.h" //CH I have gone to great pains here to prevent the API from having any externally-available // functions or data that should not be accessible from a user of the API. Unfortunately, this // results in the ridiculous "friendliness" of the classes. Perhaps this could be done a better // way? //CH Note that as the API currently stands, you can get information and provide commands for any // player. Before this is used, we will need to make it possible to do most of these things // only for the current player. (Perhaps a Player superclass and Me subclass with most of the // functionality? /** @file * A header file that declares all of CTP_API. * Originally written by Ushhan Gundevia, with modifications by Chad Hogg, and * Joe Souto both under the supervision of Dr. Hector Munoz-Avila, all of Lehigh * University. This software has been developed as part of the * DARPA-funded Transfer Learning Project. * * The most recent version of this file should be available at * www.cse.lehigh.edu/~munoz/projects/CTP2TieltIntegration/CTP2Integration.html */ /** * A namespace containing all data types and functions in our API. * To use the API, either prefix every use with "CTP_API::" or use * "using namespace CTP_API;" within the block where the API is being * used (or directly after including this file). * * This API is designed such that the user should be able to control an AI * player in a Call To Power II game using only the types and functions * within this API and the C++ standard library. Currently, this has not * been successful and at least an API_Player variable must be created * from Call To Power II's internal variables. */ namespace CTP_API { // Forward declarations of CTP_API stuff. class API_Player; class API_Army; class API_City; class API_Location; /** * Directions from one point on the map to another. * This seems to be roughly equivalent to the internal WORLD_DIRECTION. */ enum API_Direction { API_DIR_NORTH = 0, API_DIR_NORTHEAST = 1, API_DIR_EAST = 2, API_DIR_SOUTHEAST = 3, API_DIR_SOUTH = 4, API_DIR_SOUTHWEST = 5, API_DIR_WEST = 6, API_DIR_NORTHWEST = 7, API_DIR_INVALID = 8 }; /** * Units in the game. * These values correspond to those in ctp2_data\default\gamedata\Units.txt. * Note that not all units are included here, only a subset that our * API works with at the moment. * Note that these may have different meanings if the text files are altered * for a custom scenario or mod. */ enum API_UnitType { //API_UNIT_ABOLITIONIST = 0, //API_UNIT_AIRCRAFT_CARRIER = 1, API_UNIT_ARCHER = 2, //API_UNIT_ARTILLERY = 3, //API_UNIT_BATTLESHIP = 4, //API_UNIT_BOMBER = 5, //API_UNIT_CANNON = 6, //API_UNIT_CARAVAN = 7, //API_UNIT_CARGO_HELICOPTER = 8, //API_UNIT_CARRACK = 9, //API_UNIT_CATAMARAN = 10, //API_UNIT_CATAPULT = 11, //API_UNIT_CAVALRY = 12, //API_UNIT_CITY = 13, //API_UNIT_CLERIC = 14, //API_UNIT_CORPORATE_BRANCH = 15, //API_UNIT_CRAWLER = 16, //API_UNIT_CRUISE_MISSILE = 17, //API_UNIT_CYBER_NINJA = 18, //API_UNIT_DESTROYER = 19, API_UNIT_DIPLOMAT = 20, //API_UNIT_DREADNAUGHT = 21, //API_UNIT_ECO_RANGER = 22, //API_UNIT_ECO_TERRORIST = 23, //API_UNIT_EMPATHIC_DIPLOMAT = 24, //API_UNIT_FASCIST = 25, //API_UNIT_FIGHTER = 26, //API_UNIT_FIRE_TRIREME = 27, //API_UNIT_FRIGATE = 28, //API_UNIT_FUSION_TANK = 29, API_UNIT_HOPLITE = 30, //API_UNIT_HOVER_INFANTRY = 31, //API_UNIT_INFANTRYMAN = 32, //API_UNIT_INFECTOR = 33, //API_UNIT_INTERCEPTOR = 34, //API_UNIT_IRONCLAD = 35, //API_UNIT_KNIGHT = 36, //API_UNIT_KRAKEN = 37, //API_UNIT_LAWYER = 38, //API_UNIT_LEVIATHON = 39, //API_UNIT_LONGSHIP = 40, //API_UNIT_MACHINE_GUNNER = 41, //API_UNIT_MARINE = 42, //API_UNIT_MOBILE_SAM = 43, //API_UNIT_MOREY_STRIKER = 44, //API_UNIT_MOUNTED_ARCHER = 45, //API_UNIT_NUCLEAR_SUBMARINE = 46, //API_UNIT_NUKE = 47, //API_UNIT_OCEAN_CITY = 48, //API_UNIT_PARATROOPER = 49, //API_UNIT_PIKEMEN = 50, //API_UNIT_PLASMA_DESTROYER = 51, //API_UNIT_SCOUT_SUB = 52, //API_UNIT_SEA_ENGINEER = 53, API_UNIT_SETTLER = 54, //API_UNIT_SHIP_OF_THE_LINE = 55, //API_UNIT_SLAVER = 56, //API_UNIT_SPACE_CITY = 57, //API_UNIT_SPACE_PLANE = 58, //API_UNIT_SPY = 59, //API_UNIT_SPY_PLANE = 60, //API_UNIT_STEALTH_BOMBER = 61, //API_UNIT_STEALTH_FIGHTER = 62, //API_UNIT_SUBMARINE = 63, //API_UNIT_SWORDSMAN = 64, //API_UNIT_TANK = 65, //API_UNIT_TELEVANGELIST = 66, //API_UNIT_TROOP_SHIP = 67, //API_UNIT_URBAN_PLANNER = 68, //API_UNIT_WAR_WALKER = 69, API_UNIT_WARRIOR = 70 //API_UNIT_Z_FREIGHT_TRANSPORT = 71 }; /** * City improvements in the game. * These values correspond to the order of entries in * ctp2_data\default\gamedata\buildings.txt. This is suspicious, however, * because that file does not actually contain a numbering system. Note * that not all city improvements are included here, only a subset that * our API works with at the moment. * Note that these may have different meanings if the text files are altered * for a custom scenario or mod. */ enum API_CityImprovementType { //API_IMPROVE_ACADMEY = 0, //API_IMPROVE_AIRPORT = 1, //API_IMPROVE_ANTI_BALLISTIC_MISSILES = 2, //API_IMPROVE_AQUA_FILTER = 3, //API_IMPROVE_AQUEDUCT = 4, //API_IMPROVE_ARCOLOGIES = 5, //API_IMPROVE_ARENA = 6, API_IMPROVE_BALLISTA_TOWERS = 7, //API_IMPROVE_BANK = 8, //API_IMPROVE_BASILICA = 9, //API_IMPROVE_BATTLEMENTS = 10, API_IMPROVE_BAZAAR = 11, //API_IMPROVE_BEHAVIORAL_MOD_CENTER = 12, //API_IMPROVE_BODY_EXCHANGE = 13, //API_IMPROVE_BROKERAGE = 14, //API_IMPROVE_CAPITOL = 15, //API_IMPROVE_CITY_WALLS = 16, //API_IMPROVE_COMPUTER_CENTER = 17, //API_IMPROVE_CORNUCOPIC_VAT = 18, //API_IMPROVE_CORRECTIONAL_FACILITY = 19, //API_IMPROVE_COURTHOUSE = 20, //API_IMPROVE_DRUG_STORE = 21, //API_IMPROVE_E_BANK = 22, //API_IMPROVE_ECO_TRANSIT = 23, //API_IMPROVE_FACTORY = 24, //API_IMPROVE_FLAK_TOWERS = 25, //API_IMPROVE_FOOD_SILO = 26, //API_IMPROVE_FORCEFIELD = 27, //API_IMPROVE_FUSION_PLANT = 28, //API_IMPROVE_GAIA_COMPUTER = 29, API_IMPROVE_GRANARY = 30, //API_IMPROVE_HOSPITAL = 31, //API_IMPROVE_INCUBATION_CENTER = 32, //API_IMPROVE_MATTER_DECOMPILER = 33, //API_IMPROVE_MICRO_DEFENSE = 34, //API_IMPROVE_MILL = 35, //API_IMPROVE_MOVIE_PALACE = 36, //API_IMPROVE_NANITE_FACTORY = 37, //API_IMPROVE_NUCLEAR_PLANT = 38, //API_IMPROVE_OIL_REFINERY = 39, //API_IMPROVE_ORBITAL_LABORATORY = 40, //API_IMPROVE_POWER_SATELLITE = 41, //API_IMPROVE_PUBLIC_TRANSPORTATION = 42, //API_IMPROVE_PUBLISHING_HOUSE = 43, //API_IMPROVE_RECYCLING_PLANT = 44, //API_IMPROVE_ROBOTIC_PLANT = 45, //API_IMPROVE_SECURITY_MONITOR = 46, API_IMPROVE_SHRINE = 47 //API_IMPROVE_TELEVISION = 48, //API_IMPROVE_THEATER = 49, //API_IMPROVE_UNIVERSITY = 50, //API_IMPROVE_VR_AMUSEMENT_PARK = 51 }; enum API_AttackResult { API_ATK_NOT_POSSIBLE, API_ATK_MOVED_TOWARDS, API_ATK_HIT_AND_DIED, API_ATK_HIT_AND_WON }; /** * A class representing a player in a CTPII game. * This currently just stores the information for accessing a player but * should probably be a wrapper around the internal Player class. */ class API_Player { public: /** * Construct from an index into a global player array. * @param p_iIndex [in] The index of this player. */ API_Player( const PLAYER_INDEX p_iIndex ); /** * Copy constructor. * Because this just stores an accessor, it is a shallow copy. * @param p_pOther [in] The existing API_Player to be copied. */ API_Player( const API_Player & p_pOther ); /** * Destructor. * Currently does nothing. */ ~API_Player(); /** * Get the amount of money (gold) currently owned by the player. */ sint32 GetGold() const; /** * Provide the array index of the player in g_player[]. */ PLAYER_INDEX GetIndex() const; private: /** * Retrieve a pointer to the internal Player class. * The API functions need this because most internal calls require a * Player pointer. */ const Player * GetInternalPlayerPtr() const; /** * An index into the global player array. * ( PLAYER_INDEX is just a signed 32-bit integer ) */ PLAYER_INDEX m_iIndex; // Friendships friend API_Direction MoveArmy( API_Army p_aArmy, const API_Direction p_iDirection ); friend bool Settle( API_Army p_aArmy ); friend bool CityBuild( API_City p_cCity, const API_UnitType p_iUnitType ); friend bool CityImprove( API_City p_cCity, const API_CityImprovementType p_iImproveType ); friend bool MoveArmyTo( API_Army p_aArmy, const API_Location p_lDestination ); friend API_AttackResult AttackEnemyPosWithArmy( API_Army p_aArmy, const API_Location p_lDestination ); friend API_AttackResult AttackCityPosWithArmy( API_Army p_aArmy, const API_Location p_lDestination ); friend bool ArmyToDefend( API_Army p_aArmy ); friend bool FindEnemyUnit( API_Army p_aArmy, const int p_iVisionRange, DynamicArray * p_pEnemyList ); friend bool FindEnemyCity( API_Army p_aArmy, const int p_iVisionRange, DynamicArray * p_pCityList ); friend bool FindUnexplored( const API_Army p_aArmy, API_Location & p_lUnexplored ); friend bool ArmyCanReach( const API_Army p_aArmy, const API_Location p_lCheck ); friend API_Army; friend API_City; friend bool StopDefending( API_Army p_aArmy ); /* Friends for query function(s) -JS */ friend bool QueryCityBuildable( API_Army p_aArmy ); friend bool QueryMoveable( API_Army p_aArmy, API_Location p_lLocation ); friend bool QueryUnitBuildable( int unit_type, API_City p_cCity ); friend bool QueryImprovementBuildable( int improvement_type, API_City p_cCity ); friend bool QueryGarrison( API_Army p_aArmy ); friend bool QueryUngarrison( API_Army p_aArmy ); friend bool QueryUnitAttackable( API_Army p_aArmy, API_Location p_lLocation ); friend bool QueryCityAttackable( API_Army p_aArmy, API_Location p_lLocation ); }; /** * A class representing an army in a CTPII game. * The army is the primary way of referencing things in the game. Each * army contains one or more units. For now this contains information * on how to lookup an army, but should eventually become a wrapper * for the internal Army class. */ class API_Army { public: /** * Construct an API_Army from internal game objects. * This should eventually become private, but currently needs to be * accessible to clients. * @param p_pPlayer [in] The player who owns this army. * @param p_iArmyId [in] An index into that player's army list. */ API_Army( const API_Player p_pPlayer, const sint32 p_iArmyId ); /** * Constructor that also allows the unit type to be set. * NOTE: nothing currently uses this constructor * @param p_pPlayer [in] The player who owns this army. * @param p_iArmyId [in] An index into that player's army list. * @param p_iUnitType [in] The integer type of this army */ API_Army( const API_Player p_pPlayer, const sint32 p_iArmyId, const int p_iUnitType ); /** * Destruct an API_Army. */ ~API_Army(); /** * Provide the current location of the army. */ API_Location GetLocation() const; /** * Provide the array index of the army. */ sint32 GetIndex() const; private: /** * The player who owns this army. */ API_Player m_pPlayer; /** * An index into this player's army list. */ sint32 m_iArmyId; /** * Integer representation of the type of unit * Note that nothing currently uses this member. * The standard constructor will initialize this to -1 so you can check * if it has been assigned yet */ int unit_type; // Friends friend API_Direction MoveArmy( API_Army p_aArmy, const API_Direction p_iDirection ); friend bool Settle( API_Army p_aArmy ); friend bool MoveArmyTo( API_Army p_aArmy, const API_Location p_lDestination ); friend API_AttackResult AttackEnemyPosWithArmy( API_Army p_aArmy, const API_Location p_lDestination ); friend API_AttackResult AttackCityPosWithArmy( API_Army p_aArmy, const API_Location p_lDestination ); friend bool ArmyToDefend( API_Army p_aArmy ); friend bool FindEnemyUnit( API_Army p_aArmy, const int p_iVisionRange, DynamicArray * p_pEnemyList ); friend bool FindEnemyCity( API_Army p_aArmy, const int p_iVisionRange, DynamicArray * p_pCityList ); friend bool FindUnexplored( const API_Army p_aArmy, API_Location & p_lUnexplored ); friend bool ArmyCanReach( const API_Army p_aArmy, const API_Location p_lCheck ); friend bool StopDefending( API_Army p_aArmy ); /* Friends for query function(s) -JS */ friend bool QueryCityBuildable( API_Army p_aArmy ); friend bool QueryMoveable( API_Army p_aArmy, API_Location p_lLocation ); friend bool QueryGarrison( API_Army p_aArmy ); friend bool QueryUngarrison( API_Army p_aArmy ); friend bool QueryUnitAttackable( API_Army p_aArmy, API_Location p_lLocation ); friend bool QueryCityAttackable( API_Army p_aArmy, API_Location p_lLocation ); }; /** * A class representing a city in a CTPII game. * This is currently just accessor information, but will probably become * a wrapper around the internal City class. */ class API_City { public: /** * Construct a new API_City from internal game objects. * In the future, this should never be called by clients. * @param p_pPlayer [in] The player to whom this city belongs. * @param p_iCityId [in] An index into the player's city list. */ API_City( const API_Player p_pPlayer, const sint32 p_iCityId ); /** * Destruct an API_City. */ ~API_City(); /** * Provide the location of the city. */ API_Location GetLocation() const; /** * Provide the array index of the city in Player::m_all_cities. */ sint32 GetIndex() const; private: /** * The player to whom this city belongs. */ API_Player m_pPlayer; /** * An index into the player's city list. */ sint32 m_iCityId; // Friends friend bool CityBuild( API_City p_cCity, const API_UnitType p_iUnitType ); friend bool CityImprove( API_City p_cCity, const API_CityImprovementType p_iImproveType ); /* Friends for query functions */ friend bool QueryUnitBuildable( int unit_type, API_City p_cCity ); friend bool QueryImprovementBuildable( int improvement_type, API_City p_cCity ); }; /** * A class representing a location in a CTPII game. * This is currently just a wrapper around the internal MapPoint class. */ class API_Location { public: /** * Construct a new API_Location from internal game objects. * In the future, this should never be called by clients. * @param p_pPoint [in] The point on the map corresponding to this location. */ API_Location( const MapPoint p_pPoint ); /** * Construct a new API_Location from coordinates. * @param p_iXCoord [in] The x-coordinate of this location. * @param p_iYCoord [in] The y-coordinate of this location. */ API_Location( const sint16 p_iXCoord, const sint16 p_iYCoord ); /** * Copy constructor. * This depends on the copy constructor of MapPoint being defined correctly. * @param p_lOther [in] The API_Location to copy. */ API_Location( const API_Location & p_lOther ); /** * Destruct an API_Location. * Currently, this does nothing. */ ~API_Location(); sint16 GetXCoord(); sint16 GetYCoord(); private: /** * The x-coordinate of this location. */ sint16 m_iXCoord; /** * The y-coordinate of this location. */ sint16 m_iYCoord; /** * Get an internal location class from this. */ MapPoint GetMapPoint() const; // Friends friend bool MoveArmyTo( API_Army p_aArmy, const API_Location p_lDestination ); friend API_AttackResult AttackEnemyPosWithArmy( API_Army p_aArmy, const API_Location p_lDestination ); friend API_AttackResult AttackCityPosWithArmy( API_Army p_aArmy, const API_Location p_lDestination ); friend bool FindUnexplored( const API_Army p_aArmy, API_Location & p_lUnexplored ); friend bool ArmyCanReach( const API_Army p_aArmy, const API_Location p_lCheck ); /* Friends for query functions -JS */ friend bool QueryMoveable( API_Army p_aArmy, API_Location p_lLocation ); friend bool QueryUnitAttackable( API_Army p_aArmy, API_Location p_lLocation ); friend bool QueryCityAttackable( API_Army p_aArmy, API_Location p_lLocation ); }; /** * Move an army one space in one of 8 directions. * This function will attempt to move in the specified direction, but if * that is not possible it will try the next direction in clockwise * order until legal movement is found. * @param p_aArmy [in] The army to be moved. * @param p_iDirection [in] The direction in which the army should be moved. * @return The direction the army actually moved, or * CTP_API::API_Direction::INVALID if movement was not possible. */ API_Direction MoveArmy( API_Army p_aArmy, const API_Direction p_iDirection ); /** * Have an army settle its current location. * Obviously, this only works for settler units (or sea equivalents). * @param p_aArmy [in] The army including a settler unit. * @return Whether or not it was possible to settle. */ bool Settle( API_Army p_aArmy ); /** * Instruct a city to start building a unit of the specified type. * This is only effective if the build queue for the city is empty. * @param p_cCity [in] The city to start the production. * @param p_iUnitType [in] The type of unit to start producing. * @return Whether or not the city build plans were successfully changed. */ bool CityBuild( API_City p_cCity, const API_UnitType p_iUnitType ); /** * Instruct a city to start building a city improvement of the specified type. * This is only effective if the build queue for the city is empty. * @param p_cCity [in] The city to start the production. * @param p_iImproveType [in] The type of city improvement to start building. * @return Whether or not the city build plans were successfully changed. */ bool CityImprove( API_City p_cCity, const API_CityImprovementType p_iImproveType ); /** * Instruct an army to start moving towards a specific destination. * The path followed is currently deterministic and determined by A*. * @param p_aArmy [in] The army to be moved. * @param p_lDestination [in] The location to which the army should be moved. * @return Whether or not a path to the destination was found. */ bool MoveArmyTo( API_Army p_aArmy, const API_Location p_lDestination ); /** * Instruct an army to attack an enemy-occupied location. * If the enemy is not within range, this moves closer to it instead. * There is a bug where units with high movement rates will not be able to * move and attack in the same turn unless this is called more than once. * @param p_aArmy [in] The army to do the attack. * @param p_lDestination [in] The enemy-occupied location to attack. * @return Whether the attack could be performed. */ API_AttackResult AttackEnemyPosWithArmy( API_Army p_aArmy, const API_Location p_lDestination ); /** * Instruct an army to attack a location where there is an enemy-controlled city. * If the city is not within range, this moves closer to it instead. * There is a bug where units with high movement rates will not be able to * move and attack in the same turn unless this is called more than once. * @param p_aArmy [in] The army to make the attack. * @param p_lDestination [in] The location containing the city to be attacked. * @return Whether the attack could be performed. */ API_AttackResult AttackCityPosWithArmy( API_Army p_aArmy, const API_Location p_lDestination ); /** * Instruct an army to fortify its current location. * @param p_aArmy [in] The army to entrench. * @return Whether or not it was possible to entrench the unit. */ bool ArmyToDefend( API_Army p_aArmy ); /** * Instruct an army to stop fortifying its current location * @param p_aArmy [in] The army to detrench * @return Whether or not it was possible to detrench the unit. */ bool StopDefending( API_Army p_aArmy ); /** * Search for enemy units visible from one of your own units. * This function finds all enemy units that are visible from one of your units. * It does not prioritize their order by distance. Only vision ranges of * 1 and 2 are currently implemented. Vision range should be determined by * the unit type to prevent cheating. * @param p_aArmy [in] The army that is doing the "looking". * @param p_iVisionRange [in] The vision style of the army, either 1 or 2. * @param p_pEnemyList [out] A list of enemy units that the army sees. * @return Whether or not any units were found. */ bool FindEnemyUnit( API_Army p_aArmy, const int p_iVisionRange, DynamicArray * p_pEnemyList ); /** * Search for enemy cities visible from one of your own units. * See CTP_API::FindEnemyUnit( API_Army, const int, DynamicArracy * ), * which should really be merged with this. * @param p_aArmy [in] The army that is doing the "looking". * @param p_iVisionRange [in] The vision style of the army, either 1 or 2. * @param p_pCityList [out] A list of enemy cities that the army sees. * @return Whether or not any cities were found. */ bool FindEnemyCity( API_Army p_aArmy, const int p_iVisionRange, DynamicArray * p_pCityList ); /** * Search for the closest unexplored territory an army can reach. * This actually uses the army's pathfinding such that it cannot cheat * to know whether or not it can get somewhere. This has not been * tested for water or air units, and probably does not work for them. * This currently searches in a clockwise fashion around concentric squares * and returns the first thing found. An improved algorithm would choose * a random initial direction. It would also be reasonable to expect this * to make the move that exposes the maximal amount of unexplored territory, * which it currently does not do. This will only search out to as far as * 100 locations away from the army. * @param p_aArmy [in] The army that is searching for unexplored territory. * @param p_lUnexplored [out] The first reachable unexplored territory found. * @return Whether or not any territory was found. */ bool FindUnexplored( API_Army p_aArmy, API_Location & p_lUnexplored ); /** * Determine whether or not there is a known path from an army to a location. * The path is not retained, although that might be more efficient in some cases. * @param p_aArmy [in] The army to consider moving. * @param p_lCheck [in] The location the army might try moving to. * @return Whether or not there is a legal, known path between them. */ bool ArmyCanReach( const API_Army p_aArmy, const API_Location p_lCheck ); /** * Convert an integer into a direction. * @param p_iDirection The direction, 0-7 for a value or other for invalid. * @return The enumerated direction type for this direction. */ API_Direction DirFromInt( const int p_iDirection ); /** * Query if a unit can build a city at its current location * @param p_aArmy [in] The army including a settler unit. * @return Whether or not it is possible to settle on its location */ bool QueryCityBuildable( API_Army p_aArmy ); /** * Query if a unit can move to a given location on the map * @param p_aArmy [in] The army to move to another location * @param p_lLocation [in] The desired location to move the army to * @return Whether or not it is possible to move the army towards that destination */ bool QueryMoveable( API_Army p_aArmy, API_Location p_lLocation ); /** * Query if a unit can be produced in a given city you control (ie: you are far enough in the tech tree) * There are currently 5 types of units that can be built: * Settler = 54 --builds cities * Warrior = 70 --basic military unit * Hoplite = 30 --defensive unit * Archer = 2 --ranged military unit, requires ballistics, agriculture, and tool making advances * Diplomat = 20 --diplomatic unit, requires beauracracy advance (which requires a lot of other advances, see the Great Library in the game) * @param unit_type [in] the integer representation of the unit type you wish to build * @param p_cCity [in] the city to produce the new unit * @return Whether or not it is possible to produce that unit type in that city */ bool QueryUnitBuildable( int unit_type, API_City p_cCity ); /** * Query if an improvement can be built in a given city you control (ie: you are far enough in the tech tree) * There are currently 4 types of city improvements that can be built: * Ballista Towers = 7 --defensive improvement, requires tool making, agriculture, and ballistics advances * Bazaar = 11 --gives gold bonus, requires writing, jurisprudence, agriculture, and trade advances * Granary = 30 --gives food bonus * Shrine = 47 --gives happiness bonus * @param improvement_type [in] the integer representation of the improvement type you wish to build * @param p_cCity [in] the city to build the improvement * @return Whether or not it is possible to build that improvement in that city */ bool QueryImprovementBuildable( int improvement_type, API_City p_cCity ); /** * Query if a unit can garrison its current location * @param p_aArmy [in] the unit to garrison its current location * @return Whether or not it is possible to garrison at the current location */ bool QueryGarrison( API_Army p_aArmy ); /** * Query if a unit can stop garrisoning its current location * @param p_aArmy [in] the unit to stop garrisoning its current location * @return Whether or not it is possible to ungarrison */ bool QueryUngarrison( API_Army p_aArmy ); /** * Query if a unit can attack an enemy unit on a given location * @param p_aArmy [in] the unit to perform the attack * @param p_lLocation [in] the location with the unit you want to attack * @return Whether or not it is possible to attack that unit */ bool QueryUnitAttackable( API_Army p_aArmy, API_Location p_lDestination ); /** * Query if a unit can attack an enemy city on a given location * @param p_aArmy [in] the unit to perform the attack * @param p_lLocation [in] the location with the city you want to attack * @return Whether or not it is possible to attack that city */ bool QueryCityAttackable( API_Army p_aArmy, API_Location p_lDestination ); /** * Load a saved game * Note that this calls g_slicEngine's SetLoadGame, which eventaully triggers the * LoadSavedGame function defined in civapp.cpp * @param name [in] name of the game to be loaded * @returns true */ bool LoadGame(char name[]); /** * Save the current game * This wraps the Save function defined in fileio\GameFile.cpp * @param name [in] name of the game to save (full path must be specified, ie: C:\...\...\gamename) * @return 0 on success, >0 on failure */ int SaveGame(char name[]); /** * The index of the API-controlled player. */ extern PLAYER_INDEX g_Me; #ifdef TIELT /** * Whether or not the thread that listens for messages from TIELT should be active. * I have made my own synchronization routine here because none of the typical * methods (mutex, semaphore, critical section, etc) really seem to fit this * paradigm. Whether or not this thread should run is completely controlled * by the execution of a different thread. */ extern bool g_bTIELTShouldListen; #endif//TIELT } #endif//CTP_API_H__