diff --git a/CMakeLists.txt b/CMakeLists.txt index 210c3205eca5ae729ef6d98118d3fd2f9528887f..f92edcefc95300fa7136682acc7fea669f1044cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,15 @@ if (MSVC) set_target_properties(sc2renderer PROPERTIES COMPILE_FLAGS "/W4") set_target_properties(sc2utils PROPERTIES COMPILE_FLAGS "/W3") set_target_properties(sc2protocol PROPERTIES COMPILE_FLAGS "/W0") + set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT CommandCenter) endif (MSVC) -set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT CommandCenter) +if(UNIX AND NOT APPLE) + set_target_properties(libprotobuf PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties(sc2api PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties(sc2lib PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties(sc2renderer PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties(sc2utils PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties(sc2protocol PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties(civetweb-c-library PROPERTIES POSITION_INDEPENDENT_CODE ON) +endif() diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp index 16fa386f68d2587d5d667abf1d610e259b85a16f..2f3a8e37d8d560ca7e7993ec1f6bc4390beec0b7 100644 --- a/python-api-src/library.cpp +++ b/python-api-src/library.cpp @@ -60,9 +60,9 @@ PYBIND11_MODULE(library, m) .def("get_my_units", &IDABot::GetMyUnits) .def("get_player_race", &IDABot::GetPlayerRace) .def_property_readonly("base_location_manager", &IDABot::Bases) - .def_property_readonly("tech_tree", &IDABot::TechTree) + .def_property_readonly("tech_tree", &IDABot::GetTechTree) .def_property_readonly("map_tools", &IDABot::Map) - .def_property_readonly("building_placer", &IDABot::BuildingPlacer) + .def_property_readonly("building_placer", &IDABot::GetBuildingPlacer) .def_property_readonly("start_location", &IDABot::GetStartLocation) .def_property_readonly("minerals", &IDABot::GetMinerals) .def_property_readonly("current_supply", &IDABot::GetCurrentSupply) diff --git a/python-api-src/library.h b/python-api-src/library.h index d6f451fffe47d7c0954ea3c0f33e0d9563f978e9..7d11d4d80c130702695dabc001c50df8318aa10d 100644 --- a/python-api-src/library.h +++ b/python-api-src/library.h @@ -57,4 +57,4 @@ void define_point(pybind11::module &m); void define_base_location(pybind11::module & m); void define_tech_tree(pybind11::module & m); void define_map_tools(pybind11::module & m); -void define_building_placer(pybind11::module & m); \ No newline at end of file +void define_building_placer(pybind11::module & m); diff --git a/src/IDABot.cpp b/src/IDABot.cpp index afd09029fe09be3d2decfa44a984de120e78dda4..f61dc8329e06685f6078df8c859dd01619207af1 100644 --- a/src/IDABot.cpp +++ b/src/IDABot.cpp @@ -124,7 +124,7 @@ int IDABot::GetCurrentFrame() const return (int)Observation()->GetGameLoop(); } -const TechTree & IDABot::TechTree() const +const TechTree & IDABot::GetTechTree() const { return m_techTree; } @@ -194,7 +194,7 @@ void IDABot::OnError(const std::vector<sc2::ClientError> & client_errors, const // This is called when the sc2api (Google's API) has an error. } -BuildingPlacer & IDABot::BuildingPlacer() +BuildingPlacer & IDABot::GetBuildingPlacer() { return m_buildingPlacer; } diff --git a/src/IDABot.h b/src/IDABot.h index 94c7621dcc55e1b365711dd41dd9efbade8dfecc..eca954f01a1857bf31747ae128a239b86dc19e88 100644 --- a/src/IDABot.h +++ b/src/IDABot.h @@ -38,13 +38,13 @@ public: /* API for students */ - const TechTree & TechTree() const; + const TechTree & GetTechTree() const; const BaseLocationManager & Bases() const; const MapTools & Map() const; const UnitInfoManager & UnitInfo() const; CCRace GetPlayerRace(int player) const; CCPosition GetStartLocation() const; - BuildingPlacer & BuildingPlacer(); + BuildingPlacer & GetBuildingPlacer(); int GetCurrentFrame() const; int GetMinerals() const; @@ -62,4 +62,4 @@ public: const TypeData & Data(const CCUpgrade & type) const; const TypeData & Data(const MetaType & type) const; const TypeData & Data(const Unit & unit) const; -}; \ No newline at end of file +}; diff --git a/src/MyAgent.cpp b/src/MyAgent.cpp index 4fd66e698d0d266fce9a4a14bc081d99c44fb812..5a6ac87e45c757fb31ccef89412253f72e58d331 100644 --- a/src/MyAgent.cpp +++ b/src/MyAgent.cpp @@ -85,7 +85,7 @@ void MyAgent::manageBuilding(std::vector<UnitType> & build_plan) BuildStatus status{ type, position }; currently_building[worker] = status; // Reserve the location - BuildingPlacer().reserveTiles(position.x, position.y, type.tileWidth(), type.tileHeight()); + GetBuildingPlacer().reserveTiles(position.x, position.y, type.tileWidth(), type.tileHeight()); // Update economy book-keeping if (type.isRefinery() || type.isResourceDepot()) @@ -303,7 +303,7 @@ void MyAgent::manageWorkers(std::vector<UnitType> & build_plan) if (worker.isIdle()) { BuildStatus status = currently_building[worker]; - BuildingPlacer().freeTiles(status.position.x, status.position.y, status.type.tileWidth(), status.type.tileHeight()); + GetBuildingPlacer().freeTiles(status.position.x, status.position.y, status.type.tileWidth(), status.type.tileHeight()); currently_building.erase(worker); assignWork(worker, Assignment::Mineral); } @@ -415,7 +415,7 @@ CCTilePosition MyAgent::getBuildPosition(UnitType & building) else { CCPosition position = Bases().getPlayerStartingBaseLocation(Players::Self)->getPosition(); - tile_position = BuildingPlacer().getBuildLocationNear(Util::GetTilePosition(position), building, 1); + tile_position = GetBuildingPlacer().getBuildLocationNear(Util::GetTilePosition(position), building, 1); } return tile_position; }