Ejemplo n.º 1
0
void CLosAlgorithm::LosAdd(int2 pos, int radius, float baseHeight, std::vector<int>& squares)
{
	pos.x = std::max(0, std::min(size.x - 1, pos.x));
	pos.y = std::max(0, std::min(size.y - 1, pos.y));

	if ((pos.x - radius < 0) || (pos.x + radius >= size.x) ||
	    (pos.y - radius < 0) || (pos.y + radius >= size.y)) {
		SafeLosAdd(pos, radius, baseHeight, squares);
	} else {
		UnsafeLosAdd(pos, radius, baseHeight, squares);
	}
}
Ejemplo n.º 2
0
void CLosAlgorithm::LosAdd(int2 pos, int radius, float baseHeight, std::vector<int>& squares)
{
	if (radius <= 0) { return; }

	pos.x = Clamp(pos.x, 0, size.x - 1);
	pos.y = Clamp(pos.y, 0, size.y - 1);

	if ((pos.x - radius < radius) || (pos.x + radius >= size.x - radius) || // FIXME: This additional margin is due to a suspect bug in losalgorithm
	    (pos.y - radius < radius) || (pos.y + radius >= size.y - radius)) { // causing rare crash with big units such as arm Colossus
		SafeLosAdd(pos, radius, baseHeight, squares);
	} else {
		UnsafeLosAdd(pos, radius, baseHeight, squares);
	}
}