Skip to content

Commit e94fd30

Browse files
author
Your Name
committed
Merge remote-tracking branch 'upstream/master' into xy-point-extent
2 parents 8a46597 + 4a2d0df commit e94fd30

7 files changed

Lines changed: 107 additions & 101 deletions

File tree

CGame_Event.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ void CGame::EventHandling(SDL_Event* Event)
7777
#endif
7878
// F5 - F7 is ZOOM, F5 = zoom in, F6 = normal view, F7 = zoom out
7979
case SDLK_F5:
80-
if(TRIANGLE_INCREASE < 10 && MapObj->getMap())
80+
if(triangleIncrease < ZOOM_INCREASE_MAX && MapObj->getMap())
8181
{
8282
callback::PleaseWait(INITIALIZING_CALL);
83-
TRIANGLE_HEIGHT += 5;
84-
TRIANGLE_WIDTH += 11;
85-
TRIANGLE_INCREASE += 1;
83+
triangleHeight += ZOOM_STEP_HEIGHT;
84+
triangleWidth += ZOOM_STEP_WIDTH;
85+
triangleIncrease += ZOOM_STEP_INCREASE;
8686
bobMAP* myMap = MapObj->getMap();
8787
myMap->updateVertexCoords();
8888
CSurface::get_nodeVectors(*myMap);
@@ -94,9 +94,9 @@ void CGame::EventHandling(SDL_Event* Event)
9494
if(MapObj->getMap())
9595
{
9696
callback::PleaseWait(INITIALIZING_CALL);
97-
TRIANGLE_HEIGHT = 28;
98-
TRIANGLE_WIDTH = 56;
99-
TRIANGLE_INCREASE = 5;
97+
triangleHeight = TRIANGLE_HEIGHT_DEFAULT;
98+
triangleWidth = TRIANGLE_WIDTH_DEFAULT;
99+
triangleIncrease = TRIANGLE_INCREASE_DEFAULT;
100100
bobMAP* myMap = MapObj->getMap();
101101
myMap->updateVertexCoords();
102102
CSurface::get_nodeVectors(*myMap);
@@ -105,12 +105,12 @@ void CGame::EventHandling(SDL_Event* Event)
105105
}
106106
break;
107107
case SDLK_F7:
108-
if(TRIANGLE_INCREASE > 1 && MapObj->getMap())
108+
if(triangleIncrease > ZOOM_INCREASE_MIN && MapObj->getMap())
109109
{
110110
callback::PleaseWait(INITIALIZING_CALL);
111-
TRIANGLE_HEIGHT -= 5;
112-
TRIANGLE_WIDTH -= 11;
113-
TRIANGLE_INCREASE -= 1;
111+
triangleHeight -= ZOOM_STEP_HEIGHT;
112+
triangleWidth -= ZOOM_STEP_WIDTH;
113+
triangleIncrease -= ZOOM_STEP_INCREASE;
114114
bobMAP* myMap = MapObj->getMap();
115115
myMap->updateVertexCoords();
116116
CSurface::get_nodeVectors(*myMap);

CMap.cpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,27 @@ void bobMAP::initVertexCoords()
4545

4646
void bobMAP::updateVertexCoords()
4747
{
48-
width_pixel = width * TRIANGLE_WIDTH;
49-
height_pixel = height * TRIANGLE_HEIGHT;
48+
width_pixel = width * triangleWidth;
49+
height_pixel = height * triangleHeight;
5050

5151
Sint32 b = 0;
5252
for(unsigned j = 0; j < height; j++)
5353
{
5454
Sint32 a;
5555
if(j % 2u == 0u)
56-
a = TRIANGLE_WIDTH / 2u;
56+
a = triangleWidth / 2u;
5757
else
58-
a = TRIANGLE_WIDTH;
58+
a = triangleWidth;
5959

6060
for(unsigned i = 0; i < width; i++)
6161
{
6262
MapNode& curVertex = getVertex(i, j);
6363
curVertex.x = a;
64-
curVertex.y = b - TRIANGLE_INCREASE * (curVertex.h - 0x0A);
65-
curVertex.z = TRIANGLE_INCREASE * (curVertex.h - 0x0A);
66-
a += TRIANGLE_WIDTH;
64+
curVertex.y = b - triangleIncrease * (curVertex.h - 0x0A);
65+
curVertex.z = triangleIncrease * (curVertex.h - 0x0A);
66+
a += triangleWidth;
6767
}
68-
b += TRIANGLE_HEIGHT;
68+
b += triangleHeight;
6969
}
7070
}
7171

@@ -992,15 +992,15 @@ void CMap::storeVerticesFromMouse(Position mousePos, Uint8 /*MouseState*/)
992992

993993
// get X
994994
// following out commented lines are the correct ones, but for tolerance (to prevent to early jumps of the cursor)
995-
// we subtract "TRIANGLE_WIDTH/2" Xeven = (MouseX + displayRect.left) / TRIANGLE_WIDTH;
996-
Xeven = (mousePos.x + displayRect.left - TRIANGLE_WIDTH / 2) / TRIANGLE_WIDTH;
995+
// we subtract "triangleWidth/2" Xeven = (MouseX + displayRect.left) / triangleWidth;
996+
Xeven = (mousePos.x + displayRect.left - triangleWidth / 2) / triangleWidth;
997997
if(Xeven < 0)
998998
Xeven += (map->width);
999999
else if(Xeven > map->width - 1)
10001000
Xeven -= (map->width - 1);
1001-
// Add rows are already shifted by TRIANGLE_WIDTH / 2
1002-
Xodd = (mousePos.x + displayRect.left) / TRIANGLE_WIDTH;
1003-
// Xodd = (mousePos.x + displayRect.left) / TRIANGLE_WIDTH;
1001+
// Add rows are already shifted by triangleWidth / 2
1002+
Xodd = (mousePos.x + displayRect.left) / triangleWidth;
1003+
// Xodd = (mousePos.x + displayRect.left) / triangleWidth;
10041004
if(Xodd < 0)
10051005
Xodd += (map->width - 1);
10061006
else if(Xodd > map->width - 1)
@@ -1018,8 +1018,8 @@ void CMap::storeVerticesFromMouse(Position mousePos, Uint8 /*MouseState*/)
10181018
{
10191019
if(j % 2 == 0)
10201020
{
1021-
// subtract "TRIANGLE_HEIGHT/2" is for tolerance, we did the same for X
1022-
if((MousePosY - TRIANGLE_HEIGHT / 2) > map->getVertex(Xeven, j).y)
1021+
// subtract "triangleHeight/2" is for tolerance, we did the same for X
1022+
if((MousePosY - triangleHeight / 2) > map->getVertex(Xeven, j).y)
10231023
Y++;
10241024
else
10251025
{
@@ -1028,7 +1028,7 @@ void CMap::storeVerticesFromMouse(Position mousePos, Uint8 /*MouseState*/)
10281028
}
10291029
} else
10301030
{
1031-
if((MousePosY - TRIANGLE_HEIGHT / 2) > map->getVertex(Xodd, j).y)
1031+
if((MousePosY - triangleHeight / 2) > map->getVertex(Xodd, j).y)
10321032
Y++;
10331033
else
10341034
{
@@ -1430,9 +1430,9 @@ void CMap::drawMinimap(SDL_Surface* Window)
14301430

14311431
// draw the arrow --> 6px is width of left window frame and 20px is the height of the upper window frame
14321432
CSurface::Draw(Window, global::bmpArray[MAPPIC_ARROWCROSS_ORANGE].surface,
1433-
6 + (displayRect.left + displayRect.getSize().x / 2) / TRIANGLE_WIDTH / num_x
1433+
6 + (displayRect.left + displayRect.getSize().x / 2) / triangleWidth / num_x
14341434
- global::bmpArray[MAPPIC_ARROWCROSS_ORANGE].nx,
1435-
20 + (displayRect.top + displayRect.getSize().y / 2) / TRIANGLE_HEIGHT / num_y
1435+
20 + (displayRect.top + displayRect.getSize().y / 2) / triangleHeight / num_y
14361436
- global::bmpArray[MAPPIC_ARROWCROSS_ORANGE].ny);
14371437
}
14381438

@@ -1552,18 +1552,18 @@ void CMap::modifyHeightRaise(Position pos)
15521552
even = true;
15531553

15541554
// DO IT
1555-
if(tempP->z >= TRIANGLE_INCREASE * (MaxRaiseHeight - 0x0A)) // user specified maximum reached
1555+
if(tempP->z >= triangleIncrease * (MaxRaiseHeight - 0x0A)) // user specified maximum reached
15561556
return;
15571557

1558-
if(tempP->z >= TRIANGLE_INCREASE * (0x3C - 0x0A)) // maximum reached (0x3C is max)
1558+
if(tempP->z >= triangleIncrease * (0x3C - 0x0A)) // maximum reached (0x3C is max)
15591559
return;
15601560

1561-
tempP->y -= TRIANGLE_INCREASE;
1562-
tempP->z += TRIANGLE_INCREASE;
1561+
tempP->y -= triangleIncrease;
1562+
tempP->z += triangleIncrease;
15631563
tempP->h += 0x01;
15641564
CSurface::update_shading(*map, pos);
15651565

1566-
// after (5*TRIANGLE_INCREASE) pixel all vertices around will be raised too
1566+
// after (5*triangleIncrease) pixel all vertices around will be raised too
15671567
// update first vertex left upside
15681568
X = pos.x - (even ? 1 : 0);
15691569
if(X < 0)
@@ -1573,7 +1573,7 @@ void CMap::modifyHeightRaise(Position pos)
15731573
Y += map->height;
15741574
// only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few
15751575
// lines before)
1576-
if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE)) //-V807
1576+
if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease)) //-V807
15771577
modifyHeightRaise(Position(X, Y));
15781578
// update second vertex right upside
15791579
X = pos.x + (even ? 0 : 1);
@@ -1584,7 +1584,7 @@ void CMap::modifyHeightRaise(Position pos)
15841584
Y += map->height;
15851585
// only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few
15861586
// lines before)
1587-
if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE))
1587+
if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease))
15881588
modifyHeightRaise(Position(X, Y));
15891589
// update third point bottom left
15901590
X = pos.x - 1;
@@ -1593,7 +1593,7 @@ void CMap::modifyHeightRaise(Position pos)
15931593
Y = pos.y;
15941594
// only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few
15951595
// lines before)
1596-
if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE))
1596+
if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease))
15971597
modifyHeightRaise(Position(X, Y));
15981598
// update fourth point bottom right
15991599
X = pos.x + 1;
@@ -1602,7 +1602,7 @@ void CMap::modifyHeightRaise(Position pos)
16021602
Y = pos.y;
16031603
// only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few
16041604
// lines before)
1605-
if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE))
1605+
if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease))
16061606
modifyHeightRaise(Position(X, Y));
16071607
// update fifth point down left
16081608
X = pos.x - (even ? 1 : 0);
@@ -1613,7 +1613,7 @@ void CMap::modifyHeightRaise(Position pos)
16131613
Y -= map->height;
16141614
// only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few
16151615
// lines before)
1616-
if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE))
1616+
if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease))
16171617
modifyHeightRaise(Position(X, Y));
16181618
// update sixth point down right
16191619
X = pos.x + (even ? 0 : 1);
@@ -1624,7 +1624,7 @@ void CMap::modifyHeightRaise(Position pos)
16241624
Y -= map->height;
16251625
// only modify if the other point is lower than the middle point of the hexagon (-5 cause point was raised a few
16261626
// lines before)
1627-
if(map->getVertex(X, Y).z < tempP->z - (5 * TRIANGLE_INCREASE))
1627+
if(map->getVertex(X, Y).z < tempP->z - (5 * triangleIncrease))
16281628
modifyHeightRaise(Position(X, Y));
16291629

16301630
// at least setup the possible building and shading at the vertex and 2 sections around
@@ -1649,17 +1649,17 @@ void CMap::modifyHeightReduce(Position pos)
16491649
even = true;
16501650

16511651
// DO IT
1652-
if(tempP->z <= TRIANGLE_INCREASE * (MinReduceHeight - 0x0A)) // user specified minimum reached
1652+
if(tempP->z <= triangleIncrease * (MinReduceHeight - 0x0A)) // user specified minimum reached
16531653
return;
16541654

1655-
if(tempP->z <= TRIANGLE_INCREASE * (0x00 - 0x0A)) // minimum reached (0x00 is min)
1655+
if(tempP->z <= triangleIncrease * (0x00 - 0x0A)) // minimum reached (0x00 is min)
16561656
return;
16571657

1658-
tempP->y += TRIANGLE_INCREASE;
1659-
tempP->z -= TRIANGLE_INCREASE;
1658+
tempP->y += triangleIncrease;
1659+
tempP->z -= triangleIncrease;
16601660
tempP->h -= 0x01;
16611661
CSurface::update_shading(*map, pos);
1662-
// after (5*TRIANGLE_INCREASE) pixel all vertices around will be reduced too
1662+
// after (5*triangleIncrease) pixel all vertices around will be reduced too
16631663
// update first vertex left upside
16641664
X = pos.x - (even ? 1 : 0);
16651665
if(X < 0)
@@ -1669,7 +1669,7 @@ void CMap::modifyHeightReduce(Position pos)
16691669
Y += map->height;
16701670
// only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few
16711671
// lines before)
1672-
if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE)) //-V807
1672+
if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease)) //-V807
16731673
modifyHeightReduce(Position(X, Y));
16741674
// update second vertex right upside
16751675
X = pos.x + (even ? 0 : 1);
@@ -1680,7 +1680,7 @@ void CMap::modifyHeightReduce(Position pos)
16801680
Y += map->height;
16811681
// only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few
16821682
// lines before)
1683-
if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE))
1683+
if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease))
16841684
modifyHeightReduce(Position(X, Y));
16851685
// update third point bottom left
16861686
X = pos.x - 1;
@@ -1689,7 +1689,7 @@ void CMap::modifyHeightReduce(Position pos)
16891689
Y = pos.y;
16901690
// only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few
16911691
// lines before)
1692-
if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE))
1692+
if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease))
16931693
modifyHeightReduce(Position(X, Y));
16941694
// update fourth point bottom right
16951695
X = pos.x + 1;
@@ -1698,7 +1698,7 @@ void CMap::modifyHeightReduce(Position pos)
16981698
Y = pos.y;
16991699
// only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few
17001700
// lines before)
1701-
if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE))
1701+
if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease))
17021702
modifyHeightReduce(Position(X, Y));
17031703
// update fifth point down left
17041704
X = pos.x - (even ? 1 : 0);
@@ -1709,7 +1709,7 @@ void CMap::modifyHeightReduce(Position pos)
17091709
Y -= map->height;
17101710
// only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few
17111711
// lines before)
1712-
if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE))
1712+
if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease))
17131713
modifyHeightReduce(Position(X, Y));
17141714
// update sixth point down right
17151715
X = pos.x + (even ? 0 : 1);
@@ -1720,7 +1720,7 @@ void CMap::modifyHeightReduce(Position pos)
17201720
Y -= map->height;
17211721
// only modify if the other point is higher than the middle point of the hexagon (+5 cause point was reduced a few
17221722
// lines before)
1723-
if(map->getVertex(X, Y).z > tempP->z + (5 * TRIANGLE_INCREASE))
1723+
if(map->getVertex(X, Y).z > tempP->z + (5 * triangleIncrease))
17241724
modifyHeightReduce(Position(X, Y));
17251725

17261726
// at least setup the possible building and shading at the vertex and 2 sections around

0 commit comments

Comments
 (0)