mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 23:21:19 +02:00
more fixes for editor
This commit is contained in:
@@ -36,7 +36,7 @@ void BaseRenderer::initMapSurface(int clientW, int clientH) {
|
||||
}
|
||||
|
||||
void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
||||
int clientW, int clientH, int cellSize) {
|
||||
int clientW, int clientH, int cellSize, bool grid) {
|
||||
float alt=0;
|
||||
float showWater=0;
|
||||
|
||||
@@ -112,14 +112,14 @@ void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
||||
// if (!found) {
|
||||
glColor3fv((surfColor*0.5f).ptr());
|
||||
//left
|
||||
if (i > 0 && map->getHeight(i - 1, j) > map->getHeight(i, j)) {
|
||||
if (grid || (i > 0 && map->getHeight(i - 1, j) > map->getHeight(i, j))) {
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(i * cellSize, clientH - (j + 1) * cellSize);
|
||||
glVertex2i(i * cellSize, clientH - j * cellSize);
|
||||
glEnd();
|
||||
}
|
||||
//down
|
||||
if (j > 0 && map->getHeight(i, j - 1) > map->getHeight(i, j)) {
|
||||
if (grid || (j > 0 && map->getHeight(i, j - 1) > map->getHeight(i, j))) {
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(i * cellSize, clientH - j * cellSize);
|
||||
glVertex2i((i + 1) * cellSize, clientH - j * cellSize);
|
||||
|
@@ -83,8 +83,7 @@ int MapPreview::getStartLocationY(int index) const {
|
||||
static int get_dist(int delta_x, int delta_y) {
|
||||
float dx = (float)delta_x;
|
||||
float dy = (float)delta_y;
|
||||
|
||||
return static_cast<int>(sqrtf(dx * dx + dy * dy));
|
||||
return static_cast<int>(sqrtf(dx * dx + dy * dy)+0.5); // round correctly
|
||||
}
|
||||
|
||||
void MapPreview::glestChangeHeight(int x, int y, int height, int radius) {
|
||||
@@ -169,8 +168,8 @@ void MapPreview::pirateChangeHeight(int x, int y, int height, int radius) {
|
||||
}
|
||||
//std::cout << endl;
|
||||
|
||||
// A brush with radius n cells should have a true radius of n-1 distance
|
||||
radius -= 1;
|
||||
// // A brush with radius n cells should have a true radius of n-1 distance // No becasue then "radius" 1==2
|
||||
// radius -= 1;
|
||||
for (int i = x - radius; i <= x + radius; i++) {
|
||||
for (int j = y - radius; j <= y + radius; j++) {
|
||||
int dist = get_dist(i - x, j - y);
|
||||
@@ -360,7 +359,7 @@ void MapPreview::changeSurface(int x, int y, MapSurfaceType surface, int radius)
|
||||
for (j = y - radius + 1; j < y + radius; j++) {
|
||||
if (inside(i, j)) {
|
||||
dist = get_dist(i - x, j - y);
|
||||
if (radius >= dist) {
|
||||
if (radius > dist) { // was >=
|
||||
cells[i][j].surface = surface;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user