Skip to content
Permalink
Browse files

Fix landscape placement functions (#1820, #1821)

  • Loading branch information
SvenTwo committed Sep 15, 2016
1 parent 61b1ab0 commit 22af9f0e8c57f65fda50607cf9e4dfda8a054a30
@@ -14,7 +14,7 @@ public func Place(int amount, proplist rectangle)
if (!amount) amount = 1;
if (!rectangle) rectangle = Rectangle(0,0, LandscapeWidth(), LandscapeHeight());

var trees = FindObjects(Find_InRect(rectangle.x, rectangle.y, rectangle.w, rectangle.h), Find_OCF(OCF_Fullcon), Find_Func("IsTree"), Find_Func("IsStanding"));
var trees = FindObjects(Find_InRect(rectangle.x, rectangle.y, rectangle.wdt, rectangle.hgt), Find_OCF(OCF_Fullcon), Find_Func("IsTree"), Find_Func("IsStanding"));
var hives = CreateArray(), hive;
while (amount)
{
@@ -75,8 +75,8 @@ protected func FxIntRockfallControlTimer(object target, proplist effect, int tim
var y = 0;
if (effect.area)
{
x = effect.area.x + Random(effect.area.w);
y = effect.area.y + Random(effect.area.h);
x = effect.area.x + Random(effect.area.wdt);
y = effect.area.y + Random(effect.area.hgt);
}
if (effect.spawn_distance)
{
@@ -49,7 +49,7 @@ public func IsFulfilled()
{
var winner=NO_OWNER, winners, winner_teams;
if (has_winner) return true;
for (var ruby in FindObjects(Find_InRect(goal_rect.x, goal_rect.y, goal_rect.w, goal_rect.h), Find_ID(Ruby)))
for (var ruby in FindObjects(Find_InRect(goal_rect.x, goal_rect.y, goal_rect.wdt, goal_rect.hgt), Find_ID(Ruby)))
{
if (ruby->Contained()) winner = ruby->Contained()->GetOwner();
if (winner==NO_OWNER) winner = ruby->GetController();
@@ -53,7 +53,7 @@ public func Place(int amount, proplist area, proplist settings)
var plants = CreateArray(), plant;
for (var i = 0 ; i < amount ; i++)
{
plant = PlaceVegetation(this, rectangle.x, rectangle.y, rectangle.w, rectangle.h, settings.growth, area);
plant = PlaceVegetation(this, rectangle.x, rectangle.y, rectangle.wdt, rectangle.hgt, settings.growth, area);
if (plant)
{
plants[GetLength(plants)] = plant;
@@ -205,7 +205,7 @@ private func DoSeed()
// Quick-check if intersection to confinement yields an empty area
// to avoid unnecessery search by PlaceVegetation
area = confined_area->GetBoundingRectangle();
if (area.w <= 0 || area.h <= 0) return;
if (area.wdt <= 0 || area.hgt <= 0) return;
}
else
{
@@ -135,7 +135,7 @@ private func BaseIntersection_GetBoundingRectangle()
// first bounds determine area
if (!result)
{
result = new Shape.BaseRectangle {x = rt.x, y = rt.y, w = rt.wdt, h = rt.hgt};
result = new Shape.BaseRectangle {x = rt.x, y = rt.y, wdt = rt.wdt, hgt = rt.hgt};
}
else
{
@@ -221,7 +221,7 @@ private func BaseCombination_GetBoundingRectangle()
// first bounds determine area
if (!result)
{
result = new Shape.BaseRectangle {x = rt.x, y = rt.y, w = rt.wdt, h = rt.hgt};
result = new Shape.BaseRectangle {x = rt.x, y = rt.y, wdt = rt.wdt, hgt = rt.hgt};
}
else
{
@@ -389,5 +389,5 @@ global func Rectangle(int x2, int y2, int w2, int h2)
y2 += h2;
h2 = - h2;
}
return new Shape.BaseRectangle {x = x2, y = y2, w = w2, h = h2};
return new Shape.BaseRectangle {x = x2, y = y2, wdt = w2, hgt = h2};
}
@@ -36,9 +36,9 @@ public func BlockRectangle(proplist rect)

public func HasCoordinatesInControlArea(int x, int y)
{
if (!Inside(x, lib_block_area.rectangle.x, lib_block_area.rectangle.x + lib_block_area.rectangle.w))
if (!Inside(x, lib_block_area.rectangle.x, lib_block_area.rectangle.x + lib_block_area.rectangle.wdt))
return false;
if (!Inside(y, lib_block_area.rectangle.y, lib_block_area.rectangle.y + lib_block_area.rectangle.h))
if (!Inside(y, lib_block_area.rectangle.y, lib_block_area.rectangle.y + lib_block_area.rectangle.hgt))
return false;
return true;
}
@@ -74,27 +74,27 @@ public func UpdateMarkers()
{
var step_size = 30;
var min_amount = 3;
var x_amount = Max(min_amount, lib_block_area.rectangle.w / step_size);
var y_amount = Max(min_amount, lib_block_area.rectangle.h / step_size);
var x_amount = Max(min_amount, lib_block_area.rectangle.wdt / step_size);
var y_amount = Max(min_amount, lib_block_area.rectangle.hgt / step_size);
var marker_positions = [];
// Construct sides.
for (var index = 1; index < x_amount; index++)
{
var x = lib_block_area.rectangle.x - GetX() + index * lib_block_area.rectangle.w / x_amount;
var x = lib_block_area.rectangle.x - GetX() + index * lib_block_area.rectangle.wdt / x_amount;
PushBack(marker_positions, {x = x, y = lib_block_area.rectangle.y - GetY(), r = 0});
PushBack(marker_positions, {x = x, y = lib_block_area.rectangle.y + lib_block_area.rectangle.h - GetY(), r = 180});
PushBack(marker_positions, {x = x, y = lib_block_area.rectangle.y + lib_block_area.rectangle.hgt - GetY(), r = 180});
}
for (var index = 1; index < y_amount; index++)
{
var y = lib_block_area.rectangle.y - GetY() + index * lib_block_area.rectangle.h / y_amount;
var y = lib_block_area.rectangle.y - GetY() + index * lib_block_area.rectangle.hgt / y_amount;
PushBack(marker_positions, {x = lib_block_area.rectangle.x - GetX(), y = y, r = -90});
PushBack(marker_positions, {x = lib_block_area.rectangle.x + lib_block_area.rectangle.w - GetX(), y = y, r = 90});
PushBack(marker_positions, {x = lib_block_area.rectangle.x + lib_block_area.rectangle.wdt - GetX(), y = y, r = 90});
}
// Construct edges.
PushBack(marker_positions, {x = lib_block_area.rectangle.x - GetX(), y = lib_block_area.rectangle.y - GetY(), r = -45});
PushBack(marker_positions, {x = lib_block_area.rectangle.x + lib_block_area.rectangle.w - GetX(), y = lib_block_area.rectangle.y - GetY(), r = 45});
PushBack(marker_positions, {x = lib_block_area.rectangle.x - GetX() - GetX(), y = lib_block_area.rectangle.y + lib_block_area.rectangle.h - GetY(), r = -135});
PushBack(marker_positions, {x = lib_block_area.rectangle.x + lib_block_area.rectangle.w - GetX(), y = lib_block_area.rectangle.y + lib_block_area.rectangle.h - GetY(), r = 135});
PushBack(marker_positions, {x = lib_block_area.rectangle.x + lib_block_area.rectangle.wdt - GetX(), y = lib_block_area.rectangle.y - GetY(), r = 45});
PushBack(marker_positions, {x = lib_block_area.rectangle.x - GetX() - GetX(), y = lib_block_area.rectangle.y + lib_block_area.rectangle.hgt - GetY(), r = -135});
PushBack(marker_positions, {x = lib_block_area.rectangle.x + lib_block_area.rectangle.wdt - GetX(), y = lib_block_area.rectangle.y + lib_block_area.rectangle.hgt - GetY(), r = 135});
for (var marker_pos in marker_positions)
{
var other_flag = GetFlagpoleForPosition(marker_pos.x + GetX(), marker_pos.y + GetY());
@@ -708,10 +708,10 @@ private func Drilling()
{
rect.x = Min(rect.x, partner->GetX() - 12);
rect.y = Min(rect.y, partner->GetY() - 13 - additional_y);
rect.w = Max(rect.w, partner->GetX() + 12);
rect.h = Max(rect.h, partner->GetY() + 13 + additional_y);
rect.wdt = Max(rect.wdt, partner->GetX() + 12);
rect.hgt = Max(rect.hgt, partner->GetY() + 13 + additional_y);
}
DigFreeRect(rect.x, rect.y, rect.w - rect.x, rect.h - rect.y);
DigFreeRect(rect.x, rect.y, rect.wdt - rect.x, rect.hgt - rect.y);
}

public func DigOutObject(object obj)
@@ -44,9 +44,9 @@ public func Place(int amount, proplist area)
rectangle = area->GetBoundingRectangle();

var grass_list = [];
for (var x = rectangle.x; x <= rectangle.x + rectangle.w; x += 9)
for (var x = rectangle.x; x <= rectangle.x + rectangle.wdt; x += 9)
{
for (var y = rectangle.y; y <= rectangle.y + rectangle.h; y += 3)
for (var y = rectangle.y; y <= rectangle.y + rectangle.hgt; y += 3)
{
if (GetMaterial(AbsX(x), AbsY(y)) == Material("Sky") && GetMaterial(AbsX(x), AbsY(y + 3)) == Material("Earth"))
{
@@ -182,9 +182,9 @@ private func InitVegetation(int map_size, int difficulty)
// Place some cocont trees and cave mushrooms for wood.
for (var i = 0; i < 16 + Random(6); i++)
{
PlaceVegetation(Tree_Coconut, top.x, top.y, top.w, top.h, 1000 * (61 + Random(40)));
PlaceVegetation(Tree_Coconut, middle.x, middle.y, middle.w, middle.h, 1000 * (61 + Random(40)));
PlaceVegetation(Tree_Coconut, bottom.x, bottom.y, bottom.w, bottom.h, 1000 * (61 + Random(40)));
PlaceVegetation(Tree_Coconut, top.x, top.y, top.wdt, top.hgt, 1000 * (61 + Random(40)));
PlaceVegetation(Tree_Coconut, middle.x, middle.y, middle.wdt, middle.hgt, 1000 * (61 + Random(40)));
PlaceVegetation(Tree_Coconut, bottom.x, bottom.y, bottom.wdt, bottom.hgt, 1000 * (61 + Random(40)));
}
LargeCaveMushroom->Place(6, middle, { terraform = false });
LargeCaveMushroom->Place(6, bottom, { terraform = false });
@@ -21,7 +21,7 @@ public func SetGoalRect(int x, int y, int wdt, int hgt)
// The goal is fulfilled if the train is somewhere in a rectangle.
public func IsFulfilled()
{
return FindObject(Find_ID(Locomotive), Find_InRect(AbsX(goal_rect.x), AbsY(goal_rect.y), goal_rect.w, goal_rect.h));
return FindObject(Find_ID(Locomotive), Find_InRect(AbsX(goal_rect.x), AbsY(goal_rect.y), goal_rect.wdt, goal_rect.hgt));
}

public func GetDescription(int plr)

0 comments on commit 22af9f0

Please sign in to comment.
You can’t perform that action at this time.