mirror of
https://github.com/glest/glest-source.git
synced 2025-08-26 09:24:24 +02:00
more fixes for editor
This commit is contained in:
@@ -27,7 +27,7 @@ public:
|
||||
~BaseRenderer() { }
|
||||
|
||||
virtual void initMapSurface(int clientW, int clientH);
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize);
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid=false);
|
||||
};
|
||||
|
||||
}} // end namespace
|
||||
|
@@ -3,9 +3,9 @@
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
@@ -41,11 +41,11 @@ public:
|
||||
class RendererMapInterface {
|
||||
public:
|
||||
virtual void initMapSurface(int clientW, int clientH) = 0;
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize) = 0;
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid) = 0;
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class GraphicsInterface
|
||||
// class GraphicsInterface
|
||||
//
|
||||
/// Interface for the graphic engine
|
||||
// =====================================================
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
static GraphicsInterface &getInstance();
|
||||
|
||||
void setFactory(GraphicsFactory *graphicsFactory);
|
||||
void setCurrentContext(Context *context);
|
||||
void setCurrentContext(Context *context);
|
||||
|
||||
Context *getCurrentContext() const {return currentContext;}
|
||||
GraphicsFactory *getFactory() const {return graphicsFactory;}
|
||||
|
@@ -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