diff --git a/CGame.cpp b/CGame.cpp index 2ef0d12..2b28fd3 100644 --- a/CGame.cpp +++ b/CGame.cpp @@ -14,11 +14,11 @@ #include #include #include +#include +#include #include #include #include -#include -#include #ifdef _WIN32 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN diff --git a/CGame_Event.cpp b/CGame_Event.cpp index ae633f4..8799fcd 100644 --- a/CGame_Event.cpp +++ b/CGame_Event.cpp @@ -77,12 +77,12 @@ void CGame::EventHandling(SDL_Event* Event) #endif // F5 - F7 is ZOOM, F5 = zoom in, F6 = normal view, F7 = zoom out case SDLK_F5: - if(TRIANGLE_INCREASE < 10 && MapObj->getMap()) + if(triangleIncrease < ZOOM_INCREASE_MAX && MapObj->getMap()) { callback::PleaseWait(INITIALIZING_CALL); - TRIANGLE_HEIGHT += 5; - TRIANGLE_WIDTH += 11; - TRIANGLE_INCREASE += 1; + triangleHeight += ZOOM_STEP_HEIGHT; + triangleWidth += ZOOM_STEP_WIDTH; + triangleIncrease += ZOOM_STEP_INCREASE; bobMAP* myMap = MapObj->getMap(); myMap->updateVertexCoords(); CSurface::get_nodeVectors(*myMap); @@ -94,9 +94,9 @@ void CGame::EventHandling(SDL_Event* Event) if(MapObj->getMap()) { callback::PleaseWait(INITIALIZING_CALL); - TRIANGLE_HEIGHT = 28; - TRIANGLE_WIDTH = 56; - TRIANGLE_INCREASE = 5; + triangleHeight = TRIANGLE_HEIGHT_DEFAULT; + triangleWidth = TRIANGLE_WIDTH_DEFAULT; + triangleIncrease = TRIANGLE_INCREASE_DEFAULT; bobMAP* myMap = MapObj->getMap(); myMap->updateVertexCoords(); CSurface::get_nodeVectors(*myMap); @@ -105,12 +105,12 @@ void CGame::EventHandling(SDL_Event* Event) } break; case SDLK_F7: - if(TRIANGLE_INCREASE > 1 && MapObj->getMap()) + if(triangleIncrease > ZOOM_INCREASE_MIN && MapObj->getMap()) { callback::PleaseWait(INITIALIZING_CALL); - TRIANGLE_HEIGHT -= 5; - TRIANGLE_WIDTH -= 11; - TRIANGLE_INCREASE -= 1; + triangleHeight -= ZOOM_STEP_HEIGHT; + triangleWidth -= ZOOM_STEP_WIDTH; + triangleIncrease -= ZOOM_STEP_INCREASE; bobMAP* myMap = MapObj->getMap(); myMap->updateVertexCoords(); CSurface::get_nodeVectors(*myMap); diff --git a/CMap.cpp b/CMap.cpp index 2af100d..3318beb 100644 --- a/CMap.cpp +++ b/CMap.cpp @@ -45,27 +45,27 @@ void bobMAP::initVertexCoords() void bobMAP::updateVertexCoords() { - width_pixel = width * TRIANGLE_WIDTH; - height_pixel = height * TRIANGLE_HEIGHT; + width_pixel = width * triangleWidth; + height_pixel = height * triangleHeight; Sint32 b = 0; for(unsigned j = 0; j < height; j++) { Sint32 a; if(j % 2u == 0u) - a = TRIANGLE_WIDTH / 2u; + a = triangleWidth / 2u; else - a = TRIANGLE_WIDTH; + a = triangleWidth; for(unsigned i = 0; i < width; i++) { MapNode& curVertex = getVertex(i, j); curVertex.x = a; - curVertex.y = b - TRIANGLE_INCREASE * (curVertex.h - 0x0A); - curVertex.z = TRIANGLE_INCREASE * (curVertex.h - 0x0A); - a += TRIANGLE_WIDTH; + curVertex.y = b - triangleIncrease * (curVertex.h - 0x0A); + curVertex.z = triangleIncrease * (curVertex.h - 0x0A); + a += triangleWidth; } - b += TRIANGLE_HEIGHT; + b += triangleHeight; } } @@ -992,15 +992,15 @@ void CMap::storeVerticesFromMouse(Uint16 MouseX, Uint16 MouseY, Uint8 /*MouseSta // get X // following out commented lines are the correct ones, but for tolerance (to prevent to early jumps of the cursor) - // we subtract "TRIANGLE_WIDTH/2" Xeven = (MouseX + displayRect.left) / TRIANGLE_WIDTH; - Xeven = (MouseX + displayRect.left - TRIANGLE_WIDTH / 2) / TRIANGLE_WIDTH; + // we subtract "triangleWidth/2" Xeven = (MouseX + displayRect.left) / triangleWidth; + Xeven = (MouseX + displayRect.left - triangleWidth / 2) / triangleWidth; if(Xeven < 0) Xeven += (map->width); else if(Xeven > map->width - 1) Xeven -= (map->width - 1); - // Add rows are already shifted by TRIANGLE_WIDTH / 2 - Xodd = (MouseX + displayRect.left) / TRIANGLE_WIDTH; - // Xodd = (MouseX + displayRect.left) / TRIANGLE_WIDTH; + // Add rows are already shifted by triangleWidth / 2 + Xodd = (MouseX + displayRect.left) / triangleWidth; + // Xodd = (MouseX + displayRect.left) / triangleWidth; if(Xodd < 0) Xodd += (map->width - 1); else if(Xodd > map->width - 1) @@ -1018,8 +1018,8 @@ void CMap::storeVerticesFromMouse(Uint16 MouseX, Uint16 MouseY, Uint8 /*MouseSta { if(j % 2 == 0) { - // subtract "TRIANGLE_HEIGHT/2" is for tolerance, we did the same for X - if((MousePosY - TRIANGLE_HEIGHT / 2) > map->getVertex(Xeven, j).y) + // subtract "triangleHeight/2" is for tolerance, we did the same for X + if((MousePosY - triangleHeight / 2) > map->getVertex(Xeven, j).y) Y++; else { @@ -1028,7 +1028,7 @@ void CMap::storeVerticesFromMouse(Uint16 MouseX, Uint16 MouseY, Uint8 /*MouseSta } } else { - if((MousePosY - TRIANGLE_HEIGHT / 2) > map->getVertex(Xodd, j).y) + if((MousePosY - triangleHeight / 2) > map->getVertex(Xodd, j).y) Y++; else { @@ -1430,9 +1430,9 @@ void CMap::drawMinimap(SDL_Surface* Window) // draw the arrow --> 6px is width of left window frame and 20px is the height of the upper window frame CSurface::Draw(Window, global::bmpArray[MAPPIC_ARROWCROSS_ORANGE].surface, - 6 + (displayRect.left + displayRect.getSize().x / 2) / TRIANGLE_WIDTH / num_x + 6 + (displayRect.left + displayRect.getSize().x / 2) / triangleWidth / num_x - global::bmpArray[MAPPIC_ARROWCROSS_ORANGE].nx, - 20 + (displayRect.top + displayRect.getSize().y / 2) / TRIANGLE_HEIGHT / num_y + 20 + (displayRect.top + displayRect.getSize().y / 2) / triangleHeight / num_y - global::bmpArray[MAPPIC_ARROWCROSS_ORANGE].ny); } @@ -1552,18 +1552,18 @@ void CMap::modifyHeightRaise(int VertexX, int VertexY) even = true; // DO IT - if(tempP->z >= TRIANGLE_INCREASE * (MaxRaiseHeight - 0x0A)) // user specified maximum reached + if(tempP->z >= triangleIncrease * (MaxRaiseHeight - 0x0A)) // user specified maximum reached return; - if(tempP->z >= TRIANGLE_INCREASE * (0x3C - 0x0A)) // maximum reached (0x3C is max) + if(tempP->z >= triangleIncrease * (0x3C - 0x0A)) // maximum reached (0x3C is max) return; - tempP->y -= TRIANGLE_INCREASE; - tempP->z += TRIANGLE_INCREASE; + tempP->y -= triangleIncrease; + tempP->z += triangleIncrease; tempP->h += 0x01; CSurface::update_shading(*map, VertexX, VertexY); - // after (5*TRIANGLE_INCREASE) pixel all vertices around will be raised too + // after (5*triangleIncrease) pixel all vertices around will be raised too // update first vertex left upside X = VertexX - (even ? 1 : 0); if(X < 0) @@ -1573,7 +1573,7 @@ void CMap::modifyHeightRaise(int VertexX, int VertexY) Y += map->height; // only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few // lines before) - if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE)) //-V807 + if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease)) //-V807 modifyHeightRaise(X, Y); // update second vertex right upside X = VertexX + (even ? 0 : 1); @@ -1584,7 +1584,7 @@ void CMap::modifyHeightRaise(int VertexX, int VertexY) Y += map->height; // only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few // lines before) - if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease)) modifyHeightRaise(X, Y); // update third point bottom left X = VertexX - 1; @@ -1593,7 +1593,7 @@ void CMap::modifyHeightRaise(int VertexX, int VertexY) Y = VertexY; // only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few // lines before) - if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease)) modifyHeightRaise(X, Y); // update fourth point bottom right X = VertexX + 1; @@ -1602,7 +1602,7 @@ void CMap::modifyHeightRaise(int VertexX, int VertexY) Y = VertexY; // only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few // lines before) - if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease)) modifyHeightRaise(X, Y); // update fifth point down left X = VertexX - (even ? 1 : 0); @@ -1613,7 +1613,7 @@ void CMap::modifyHeightRaise(int VertexX, int VertexY) Y -= map->height; // only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few // lines before) - if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease)) modifyHeightRaise(X, Y); // update sixth point down right X = VertexX + (even ? 0 : 1); @@ -1624,7 +1624,7 @@ void CMap::modifyHeightRaise(int VertexX, int VertexY) Y -= map->height; // only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few // lines before) - if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease)) modifyHeightRaise(X, Y); // at least setup the possible building and shading at the vertex and 2 sections around @@ -1649,17 +1649,17 @@ void CMap::modifyHeightReduce(int VertexX, int VertexY) even = true; // DO IT - if(tempP->z <= TRIANGLE_INCREASE * (MinReduceHeight - 0x0A)) // user specified minimum reached + if(tempP->z <= triangleIncrease * (MinReduceHeight - 0x0A)) // user specified minimum reached return; - if(tempP->z <= TRIANGLE_INCREASE * (0x00 - 0x0A)) // minimum reached (0x00 is min) + if(tempP->z <= triangleIncrease * (0x00 - 0x0A)) // minimum reached (0x00 is min) return; - tempP->y += TRIANGLE_INCREASE; - tempP->z -= TRIANGLE_INCREASE; + tempP->y += triangleIncrease; + tempP->z -= triangleIncrease; tempP->h -= 0x01; CSurface::update_shading(*map, VertexX, VertexY); - // after (5*TRIANGLE_INCREASE) pixel all vertices around will be reduced too + // after (5*triangleIncrease) pixel all vertices around will be reduced too // update first vertex left upside X = VertexX - (even ? 1 : 0); if(X < 0) @@ -1669,7 +1669,7 @@ void CMap::modifyHeightReduce(int VertexX, int VertexY) Y += map->height; // only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few // lines before) - if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE)) //-V807 + if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease)) //-V807 modifyHeightReduce(X, Y); // update second vertex right upside X = VertexX + (even ? 0 : 1); @@ -1680,7 +1680,7 @@ void CMap::modifyHeightReduce(int VertexX, int VertexY) Y += map->height; // only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few // lines before) - if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease)) modifyHeightReduce(X, Y); // update third point bottom left X = VertexX - 1; @@ -1689,7 +1689,7 @@ void CMap::modifyHeightReduce(int VertexX, int VertexY) Y = VertexY; // only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few // lines before) - if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease)) modifyHeightReduce(X, Y); // update fourth point bottom right X = VertexX + 1; @@ -1698,7 +1698,7 @@ void CMap::modifyHeightReduce(int VertexX, int VertexY) Y = VertexY; // only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few // lines before) - if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease)) modifyHeightReduce(X, Y); // update fifth point down left X = VertexX - (even ? 1 : 0); @@ -1709,7 +1709,7 @@ void CMap::modifyHeightReduce(int VertexX, int VertexY) Y -= map->height; // only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few // lines before) - if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease)) modifyHeightReduce(X, Y); // update sixth point down right X = VertexX + (even ? 0 : 1); @@ -1720,7 +1720,7 @@ void CMap::modifyHeightReduce(int VertexX, int VertexY) Y -= map->height; // only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few // lines before) - if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE)) + if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease)) modifyHeightReduce(X, Y); // at least setup the possible building and shading at the vertex and 2 sections around diff --git a/CSurface.cpp b/CSurface.cpp index 5d7ec78..6494ffb 100644 --- a/CSurface.cpp +++ b/CSurface.cpp @@ -243,7 +243,7 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d maxH = std::max(myMap.getVertex(x, y).h, maxH); } } - const int additionalRows = TRIANGLE_INCREASE * std::max(0, maxH - 0x0A) / TRIANGLE_HEIGHT; + const int additionalRows = triangleIncrease * std::max(0, maxH - 0x0A) / triangleHeight; // draw triangle field // NOTE: WE DO THIS TWICE, AT FIRST ONLY TRIANGLE-TEXTURES, AT SECOND THE TEXTURE-BORDERS AND OBJECTS @@ -258,10 +258,10 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d // IMPORTANT: integer values like +8 or -1 are for tolerance to beware of high triangles are not shown // at first call DrawTriangle for all triangles inside the map edges - int row_start = std::max(displayRect.top, 2 * TRIANGLE_HEIGHT) / TRIANGLE_HEIGHT - 2; - int row_end = (displayRect.bottom) / TRIANGLE_HEIGHT + additionalRows; - int col_start = std::max(displayRect.left, TRIANGLE_WIDTH) / TRIANGLE_WIDTH - 1; - int col_end = (displayRect.right) / TRIANGLE_WIDTH + 1; + int row_start = std::max(displayRect.top, 2 * triangleHeight) / triangleHeight - 2; + int row_end = (displayRect.bottom) / triangleHeight + additionalRows; + int col_start = std::max(displayRect.left, triangleWidth) / triangleWidth - 1; + int col_end = (displayRect.right) / triangleWidth + 1; bool view_outside_edges; if(k > 0) @@ -274,22 +274,22 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d // at first call DrawTriangle for all triangles up or down outside if(displayRect.top < 0) { - row_start = std::max(0, height - 1 - (-displayRect.top / TRIANGLE_HEIGHT) - 1); + row_start = std::max(0, height - 1 - (-displayRect.top / triangleHeight) - 1); row_end = height - 1; view_outside_edges = true; } else if(displayRect.bottom > myMap.height_pixel) { row_start = 0; - row_end = (displayRect.bottom - myMap.height_pixel) / TRIANGLE_HEIGHT + 8; + row_end = (displayRect.bottom - myMap.height_pixel) / triangleHeight + 8; view_outside_edges = true; - } else if(displayRect.top <= 2 * TRIANGLE_HEIGHT) + } else if(displayRect.top <= 2 * triangleHeight) { // this is for draw triangles that are reduced under the lower map edge (have bigger y-coords as // myMap.height_pixel) row_start = height - 3; row_end = height - 1; view_outside_edges = true; - } else if(displayRect.bottom >= (myMap.height_pixel - 8 * TRIANGLE_HEIGHT)) + } else if(displayRect.bottom >= (myMap.height_pixel - 8 * triangleHeight)) { // this is for draw triangles that are raised over the upper map edge (have negative y-coords) row_start = 0; @@ -303,10 +303,10 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d // now call DrawTriangle for all triangles left or right outside if(displayRect.left <= 0) { - col_start = std::max(0, width - 1 - (-displayRect.left / TRIANGLE_WIDTH) - 1); + col_start = std::max(0, width - 1 - (-displayRect.left / triangleWidth) - 1); col_end = width - 1; view_outside_edges = true; - } else if(displayRect.left < TRIANGLE_WIDTH) + } else if(displayRect.left < triangleWidth) { col_start = width - 2; col_end = width - 1; @@ -314,7 +314,7 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d } else if(displayRect.right > myMap.width_pixel) { col_start = 0; - col_end = (displayRect.right - myMap.width_pixel) / TRIANGLE_WIDTH + 1; + col_end = (displayRect.right - myMap.width_pixel) / triangleWidth + 1; view_outside_edges = true; } } @@ -349,7 +349,7 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d } // last UpSideDown tempP3 = myMap.getVertex(0, y); - tempP3.x = myMap.getVertex(width - 1, y).x + TRIANGLE_WIDTH; + tempP3.x = myMap.getVertex(width - 1, y).x + triangleWidth; DrawTriangle(display, displayRect, myMap, type, myMap.getVertex(width - 1, y + 1), myMap.getVertex(width - 1, y), tempP3); } else @@ -365,14 +365,14 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d } // last RightSideUp tempP3 = myMap.getVertex(0, y + 1); - tempP3.x = myMap.getVertex(width - 1, y + 1).x + TRIANGLE_WIDTH; + tempP3.x = myMap.getVertex(width - 1, y + 1).x + triangleWidth; DrawTriangle(display, displayRect, myMap, type, myMap.getVertex(width - 1, y), myMap.getVertex(width - 1, y + 1), tempP3); // last UpSideDown tempP1 = myMap.getVertex(0, y + 1); - tempP1.x = myMap.getVertex(width - 1, y + 1).x + TRIANGLE_WIDTH; + tempP1.x = myMap.getVertex(width - 1, y + 1).x + triangleWidth; tempP3 = myMap.getVertex(0, y); - tempP3.x = myMap.getVertex(width - 1, y).x + TRIANGLE_WIDTH; + tempP3.x = myMap.getVertex(width - 1, y).x + triangleWidth; DrawTriangle(display, displayRect, myMap, type, tempP1, myMap.getVertex(width - 1, y), tempP3); } } @@ -382,13 +382,13 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d { // RightSideUp tempP2 = myMap.getVertex(x, 0); - tempP2.y = height * TRIANGLE_HEIGHT + myMap.getVertex(x, 0).y; + tempP2.y = height * triangleHeight + myMap.getVertex(x, 0).y; tempP3 = myMap.getVertex(x + 1, 0); - tempP3.y = height * TRIANGLE_HEIGHT + myMap.getVertex(x + 1, 0).y; + tempP3.y = height * triangleHeight + myMap.getVertex(x + 1, 0).y; DrawTriangle(display, displayRect, myMap, type, myMap.getVertex(x, height - 1), tempP2, tempP3); // UpSideDown tempP1 = myMap.getVertex(x + 1, 0); - tempP1.y = height * TRIANGLE_HEIGHT + myMap.getVertex(x + 1, 0).y; + tempP1.y = height * triangleHeight + myMap.getVertex(x + 1, 0).y; DrawTriangle(display, displayRect, myMap, type, tempP1, myMap.getVertex(x, height - 1), myMap.getVertex(x + 1, height - 1)); } @@ -396,17 +396,17 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d // last RightSideUp tempP2 = myMap.getVertex(width - 1, 0); - tempP2.y += height * TRIANGLE_HEIGHT; + tempP2.y += height * triangleHeight; tempP3 = myMap.getVertex(0, 0); - tempP3.x = myMap.getVertex(width - 1, 0).x + TRIANGLE_WIDTH; - tempP3.y += height * TRIANGLE_HEIGHT; + tempP3.x = myMap.getVertex(width - 1, 0).x + triangleWidth; + tempP3.y += height * triangleHeight; DrawTriangle(display, displayRect, myMap, type, myMap.getVertex(width - 1, height - 1), tempP2, tempP3); // last UpSideDown tempP1 = myMap.getVertex(0, 0); - tempP1.x = myMap.getVertex(width - 1, 0).x + TRIANGLE_WIDTH; - tempP1.y += height * TRIANGLE_HEIGHT; + tempP1.x = myMap.getVertex(width - 1, 0).x + triangleWidth; + tempP1.y += height * triangleHeight; tempP3 = myMap.getVertex(0, height - 1); - tempP3.x = myMap.getVertex(width - 1, height - 1).x + TRIANGLE_WIDTH; + tempP3.x = myMap.getVertex(width - 1, height - 1).x + triangleWidth; DrawTriangle(display, displayRect, myMap, type, tempP1, myMap.getVertex(width - 1, height - 1), tempP3); } } @@ -479,10 +479,10 @@ bool GetAdjustedPoints(const DisplayRectangle& displayRect, const bobMAP& myMap, p3.x -= myMap.width_pixel; triangle_shown = true; } - } else if(displayRect.left < TRIANGLE_WIDTH) + } else if(displayRect.left < triangleWidth) { int outside_left = displayRect.left; - int outside_right = displayRect.left + TRIANGLE_WIDTH; + int outside_right = displayRect.left + triangleWidth; if(isInRange(p1.x - myMap.width_pixel, outside_left, outside_right) || isInRange(p2.x - myMap.width_pixel, outside_left, outside_right) || isInRange(p3.x - myMap.width_pixel, outside_left, outside_right)) @@ -1207,7 +1207,7 @@ void CSurface::get_nodeVectors(bobMAP& myMap) get_flatVector(myMap.getVertex(i, j), myMap.getVertex(i, j + 1), myMap.getVertex(i + 1, j + 1)); // vector of last triangle - tempP3.x = myMap.getVertex(width - 1, j + 1).x + TRIANGLE_WIDTH; + tempP3.x = myMap.getVertex(width - 1, j + 1).x + triangleWidth; tempP3.y = myMap.getVertex(0, j + 1).y; tempP3.z = myMap.getVertex(0, j + 1).z; myMap.getVertex(width - 1, j).flatVector = @@ -1218,16 +1218,16 @@ void CSurface::get_nodeVectors(bobMAP& myMap) for(int i = 0; i < width - 1; i++) { tempP2 = myMap.getVertex(i, 0); - tempP2.y += height * TRIANGLE_HEIGHT; + tempP2.y += height * triangleHeight; tempP3 = myMap.getVertex(i + 1, 0); - tempP3.y += height * TRIANGLE_HEIGHT; + tempP3.y += height * triangleHeight; myMap.getVertex(i, height - 1).flatVector = get_flatVector(myMap.getVertex(i, height - 1), tempP2, tempP3); } // vector of last Triangle tempP2 = myMap.getVertex(width - 1, 0); - tempP2.y += height * TRIANGLE_HEIGHT; - tempP3.x = myMap.getVertex(width - 1, 0).x + TRIANGLE_WIDTH; - tempP3.y = height * TRIANGLE_HEIGHT + myMap.getVertex(0, 0).y; + tempP2.y += height * triangleHeight; + tempP3.x = myMap.getVertex(width - 1, 0).x + triangleWidth; + tempP3.y = height * triangleHeight + myMap.getVertex(0, 0).y; tempP3.z = myMap.getVertex(0, 0).z; myMap.getVertex(width - 1, height - 1).flatVector = get_flatVector(myMap.getVertex(width - 1, height - 1), tempP2, tempP3); diff --git a/callbacks.cpp b/callbacks.cpp index 095c1d6..31ede4d 100644 --- a/callbacks.cpp +++ b/callbacks.cpp @@ -613,8 +613,7 @@ void callback::EditorHelpMenu(int Param) "Window/" "Fullscreen........................................................................................F2"); SelectBoxHelp->addOption( - "Zoom in/normal/out " - "(experimental)..............................................................F5/F6/" + "Zoom in/normal/out......................................................................F5/F6/" "F7"); SelectBoxHelp->addOption( "Scroll..........................................................................................." @@ -1766,7 +1765,7 @@ void callback::EditorPlayerMenu(int Param) { tempRect = MapObj->getDisplayRect(); tempRect.setOrigin(Position(PlayerHQx[PlayerIdx], PlayerHQy[PlayerIdx]) - * Position(TRIANGLE_WIDTH, TRIANGLE_HEIGHT) + * Position(triangleWidth, triangleHeight) - tempRect.getSize() / 2); MapObj->setDisplayRect(tempRect); } @@ -2762,7 +2761,7 @@ void callback::MinimapMenu(int Param) displayRect.setOrigin((mouse - WNDMinimap->getRect().getOrigin() - Position(6, 20) - Position(global::bmpArray[MAPPIC_ARROWCROSS_ORANGE].nx, global::bmpArray[MAPPIC_ARROWCROSS_ORANGE].ny)) - * Position(TRIANGLE_WIDTH, TRIANGLE_HEIGHT) * scaleNum); + * Position(triangleWidth, triangleHeight) * scaleNum); MapObj->setDisplayRect(displayRect); } } diff --git a/globals.cpp b/globals.cpp index e5bf8f4..da4edcf 100644 --- a/globals.cpp +++ b/globals.cpp @@ -19,9 +19,9 @@ boost::filesystem::path global::gameDataFilePath("."); boost::filesystem::path global::userMapsPath; WorldDescription global::worldDesc; -unsigned char TRIANGLE_HEIGHT = 28; -unsigned char TRIANGLE_WIDTH = 56; -unsigned char TRIANGLE_INCREASE = 5; +unsigned char triangleHeight = TRIANGLE_HEIGHT_DEFAULT; +unsigned char triangleWidth = TRIANGLE_WIDTH_DEFAULT; +unsigned char triangleIncrease = TRIANGLE_INCREASE_DEFAULT; // three-dimensional array for the GOUx.DAT-Files (3 files * 256 * 256 values) Uint8 gouData[3][256][256]; diff --git a/globals.h b/globals.h index 1b6ae2a..5b4dbaf 100644 --- a/globals.h +++ b/globals.h @@ -31,8 +31,22 @@ extern boost::filesystem::path userMapsPath; extern WorldDescription worldDesc; } // namespace global -extern unsigned char TRIANGLE_HEIGHT; -extern unsigned char TRIANGLE_WIDTH; -extern unsigned char TRIANGLE_INCREASE; +extern unsigned char triangleHeight; +extern unsigned char triangleWidth; +extern unsigned char triangleIncrease; + +// Default / reset values for zoom +constexpr unsigned char TRIANGLE_HEIGHT_DEFAULT = 28; +constexpr unsigned char TRIANGLE_WIDTH_DEFAULT = 56; +constexpr unsigned char TRIANGLE_INCREASE_DEFAULT = 5; + +// Zoom step increments/decrements +constexpr unsigned char ZOOM_STEP_HEIGHT = 5; +constexpr unsigned char ZOOM_STEP_WIDTH = 11; +constexpr unsigned char ZOOM_STEP_INCREASE = 1; + +// Zoom boundaries (based on triangleIncrease) +constexpr unsigned char ZOOM_INCREASE_MAX = 9; +constexpr unsigned char ZOOM_INCREASE_MIN = 1; extern Uint8 gouData[3][256][256]; diff --git a/include/defines.h b/include/defines.h index 6d7d543..9b7b039 100644 --- a/include/defines.h +++ b/include/defines.h @@ -1208,13 +1208,6 @@ constexpr auto MAXPLAYERS = 16; constexpr auto MAXMAPWIDTH = 1024; constexpr auto MAXMAPHEIGHT = 1024; -// triangle values -// these values are now handled in globals.h and globals.cpp, cause they must be changeable for the zoom mode -// #define TRIANGLE_HEIGHT 28 //30 --> old value, 28 is the right -// #define TRIANGLE_WIDTH 56 //54 --> old value, 56 is the right -// #define TRIANGLE_INCREASE 5 //depends on TRIANGLE_HEIGHT --> TRIANGLE_HEIGHT/TRIANGLE_INCREASE must be -// greater than 5 - enum TriangleTerrainType { TRIANGLE_TEXTURE_STEPPE_MEADOW1 = 0x00,