Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: Docker Exit Code 139 when rotating the map #77

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion maps4fs/generator/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def fit_polygon_into_bounds(
offset = (self.map_size / 2) - (self.map_rotated_size / 2)
self.logger.debug("Translating the polygon by %s", offset)
polygon = translate(polygon, xoff=offset, yoff=offset)
self.logger.debug("Rotated and translated polygon.")

if margin:
polygon = polygon.buffer(margin, join_style="mitre")
Expand All @@ -367,12 +368,16 @@ def fit_polygon_into_bounds(

# Intersect the polygon with the bounds to fit it within the map
fitted_polygon = polygon.intersection(bounds)
self.logger.debug("Fitted the polygon into the bounds: %s", bounds)

if not isinstance(fitted_polygon, Polygon):
raise ValueError("The fitted polygon is not a valid polygon.")

# Return the fitted polygon points
return list(fitted_polygon.exterior.coords)
as_list = list(fitted_polygon.exterior.coords)
if not as_list:
raise ValueError("The fitted polygon has no points.")
return as_list

def get_infolayer_path(self, layer_name: str) -> str | None:
"""Returns the path to the info layer file.
Expand Down
11 changes: 11 additions & 0 deletions maps4fs/generator/grle.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def _add_farmlands(self) -> None:
self.game.weights_dir_path(self.map_directory), "infoLayer_farmlands.png"
)

self.logger.info(
"Adding farmlands to the InfoLayer PNG file: %s.", info_layer_farmlands_path
)

if not os.path.isfile(info_layer_farmlands_path):
self.logger.warning("InfoLayer PNG file %s not found.", info_layer_farmlands_path)
return
Expand Down Expand Up @@ -139,12 +143,19 @@ def _add_farmlands(self) -> None:
)
continue

self.logger.debug("Fitted field %s contains %s points.", farmland_id, len(fitted_field))

field_np = np.array(fitted_field, np.int32)
field_np = field_np.reshape((-1, 1, 2))

self.logger.debug(
"Created a numpy array and reshaped it. Number of points: %s", len(field_np)
)

# Infolayer image is 1/2 of the size of the map image, that's why we need to divide
# the coordinates by 2.
field_np = field_np // 2
self.logger.debug("Divided the coordinates by 2.")

# pylint: disable=no-member
try:
Expand Down
1 change: 1 addition & 0 deletions maps4fs/generator/i3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def _add_fields(self) -> None:
return

self.logger.info("Found %s fields in textures info layer.", len(fields))
self.logger.debug("Starging to add fields to the I3D file.")

root = tree.getroot()
gameplay_node = root.find(".//TransformGroup[@name='gameplay']")
Expand Down
Loading