From ae6da19b4882000ec5555f321b86ee940854a044 Mon Sep 17 00:00:00 2001
From: Emil <emil.brynielsson.jobb@gmail.com>
Date: Fri, 30 Jul 2021 14:16:16 +0200
Subject: [PATCH] Fixed a comment in code and added a Note in the docs that
 size of addons can be wrong and to use another function instead

---
 python-api-src/lib_building_placer.cpp | 4 ++--
 src/BuildingPlacer.cpp                 | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/python-api-src/lib_building_placer.cpp b/python-api-src/lib_building_placer.cpp
index ab5c827e9..8b4525cb8 100644
--- a/python-api-src/lib_building_placer.cpp
+++ b/python-api-src/lib_building_placer.cpp
@@ -5,9 +5,9 @@ namespace py = pybind11;
 void define_building_placer(py::module & m)
 {
     py::class_<BuildingPlacer>(m, "BuildingPlacer")
-        .def("can_build_here", &BuildingPlacer::canBuildHere, "x"_a, "y"_a, "unit_type"_a)
+        .def("can_build_here", &BuildingPlacer::canBuildHere, "x"_a, "y"_a, "unit_type"_a, "Returns if the provided unittype it possible to be built at the location. Note: This function uses the width and height of the unit and this is not correct for addonds. So to check addons please use can_build_here_with_size with a hardcoded size instead.")
 		.def("can_build_here_with_size", &BuildingPlacer::canBuildHereWithSize, "x"_a, "y"_a, "width"_a, "height"_a, "Checks if it is possible to build something with the provided width and height at the provided coordinates. Note: False if the it overlaps with a baselocation")
-        .def("can_build_here_with_spaces", &BuildingPlacer::canBuildHereWithSpace, "Creates a square with the help of x, y, distance_to_building and the size of the unit_type. Good approach if we later gonna make a addon to the building. Note: Does not reserve those extra tiles given by distance_to_building for the future!", "x"_a, "y"_a, "unit_type"_a, "distance_to_building"_a)
+        .def("can_build_here_with_spaces", &BuildingPlacer::canBuildHereWithSpace, "Creates a square with the help of x, y, distance_to_building and the size of the unit_type. Good approach if we later gonna make a addon to the building. Note: Does not reserve those extra tiles given by distance_to_building for the future! Note: This function uses the width and height of the unit and this is not correct for addonds. So to check addons please use can_build_here_with_size with a hardcoded size instead.", "x"_a, "y"_a, "unit_type"_a, "distance_to_building"_a)
         .def("get_build_location_near", &BuildingPlacer::getBuildLocationNear, "The search_count is how many building we should check (nearby buildings, instead of i < size, we can switch size to search_count). distance_to_building is the distance to the closest building.", "point2di"_a, "unit_type"_a, "distance_to_building"_a = 2, "search_count"_a = 1000)
         .def("reserve_tiles", &BuildingPlacer::reserveTiles, "It's possible to reserve tiles, which makes it impossible to build at the position given by x and y.", "x"_a, "y"_a, "width"_a, "height"_a)
         .def("free_tiles", &BuildingPlacer::freeTiles,"Free the tile (x, y) from reservation", "x"_a, "y"_a, "width"_a, "height"_a);
diff --git a/src/BuildingPlacer.cpp b/src/BuildingPlacer.cpp
index 05a22a809..8ecf79790 100644
--- a/src/BuildingPlacer.cpp
+++ b/src/BuildingPlacer.cpp
@@ -112,7 +112,7 @@ bool BuildingPlacer::canBuildHereWithSize(int bx, int by, int width, int height)
 		// conditions for non-overlap are easy
 		bool noOverlap = (tx2 < bx1) || (tx1 > bx2) || (ty2 < by1) || (ty1 > by2);
 
-		// if the reverse is true, return true
+		// If there is overlap, return false
 		if (!noOverlap)
 		{
 			return false;
-- 
GitLab