mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-26 20:32:07 -05:00
squash! Add map_element_height (finishes sub_662783)
This commit is contained in:
parent
297043fecd
commit
d4583339f4
1 changed files with 30 additions and 23 deletions
53
src/map.c
53
src/map.c
|
@ -156,7 +156,8 @@ int map_element_height(int x, int y)
|
||||||
uint8 extra_height = (slope & 0x10) >> 4; // 0x10 is the 5th bit - sets slope to double height
|
uint8 extra_height = (slope & 0x10) >> 4; // 0x10 is the 5th bit - sets slope to double height
|
||||||
slope &= 0xF;
|
slope &= 0xF;
|
||||||
|
|
||||||
uint8 quad, quad_2; // which quadrant the element is in?
|
uint8 quad, quad_extra; // which quadrant the element is in?
|
||||||
|
// quad_extra is for extra height tiles
|
||||||
|
|
||||||
uint8 xl, yl;
|
uint8 xl, yl;
|
||||||
|
|
||||||
|
@ -208,47 +209,53 @@ int map_element_height(int x, int y)
|
||||||
|
|
||||||
// One corner down
|
// One corner down
|
||||||
if ((slope == 7) || (slope == 11) || (slope == 13) || (slope == 14)) {
|
if ((slope == 7) || (slope == 11) || (slope == 13) || (slope == 14)) {
|
||||||
switch(slope) {
|
switch (slope) {
|
||||||
case 7: // NW corner down
|
case 7: // NW corner down
|
||||||
quad = xl + TILE_SIZE - yl;
|
quad_extra = xl + TILE_SIZE - yl;
|
||||||
quad_2 = xl - yl;
|
quad = xl - yl;
|
||||||
break;
|
break;
|
||||||
case 11: // SW corner down
|
case 11: // SW corner down
|
||||||
quad = xl + yl;
|
quad_extra = xl + yl;
|
||||||
quad_2 = xl + yl - TILE_SIZE;
|
quad = xl + yl - TILE_SIZE;
|
||||||
break;
|
break;
|
||||||
case 13: // SE corner down
|
case 13: // SE corner down
|
||||||
quad = TILE_SIZE - xl + yl;
|
quad_extra = TILE_SIZE - xl + yl;
|
||||||
quad_2 = xl - yl;
|
quad = xl - yl;
|
||||||
break;
|
break;
|
||||||
case 14: // NE corner down
|
case 14: // NE corner down
|
||||||
quad = (TILE_SIZE - xl) + (TILE_SIZE - yl);
|
quad_extra = (TILE_SIZE - xl) + (TILE_SIZE - yl);
|
||||||
quad_2 = TILE_SIZE - yl - xl;
|
quad = TILE_SIZE - yl - xl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
height += 0x10;
|
|
||||||
if (extra_height) {
|
if (extra_height) {
|
||||||
height += quad / 2;
|
height += quad_extra / 2;
|
||||||
height++;
|
height++;
|
||||||
|
return height;
|
||||||
}
|
}
|
||||||
if (quad_2 < 0) {
|
// This tile is essentially at the next height level
|
||||||
height += quad_2 / 2;
|
height += 0x10;
|
||||||
|
// so we move *down* the slope
|
||||||
|
if (quad < 0) {
|
||||||
|
height += quad / 2;
|
||||||
height += 0xFF00;
|
height += 0xFF00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valleys
|
// Valleys
|
||||||
if (slope == 5) { // NW-SE valley
|
if ((slope == 5) || (slope == 10)) {
|
||||||
quad = xl + yl;
|
switch (slope) {
|
||||||
if (quad > TILE_SIZE + 1) {
|
case 5: // NW-SE valley
|
||||||
quad = TILE_SIZE - xl - yl;
|
if (xl + yl <= TILE_SIZE + 1) {
|
||||||
if (quad > 0) {
|
return height;
|
||||||
height += quad / 2;
|
|
||||||
}
|
}
|
||||||
}
|
quad = TILE_SIZE - xl - yl;
|
||||||
} else if (slope == 10) { // NE-SW valley
|
break;
|
||||||
if (xl > yl) {
|
case 10: // NE-SW valley
|
||||||
quad = xl - yl;
|
quad = xl - yl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (quad > 0) {
|
||||||
height += quad / 2;
|
height += quad / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue