@@ -874,44 +874,46 @@ Dictionary TerrainGen::generate(
874874 // Water Corners
875875 // -------------------------//
876876
877+ // TODO : Water Corner's Logic is incorrect
878+
877879 // Water's Corner WEST
878880 // +----+----+ +---+---+
879- // | n1 | n2 | | 0 | 0 |
881+ // | n1 | n2 | | 0 | 1 |
880882 // +----+----+ +---+---+
881- // | n3 | n4 | | 0 | 1 |
883+ // | n3 | n4 | | 1 | 1 |
882884 // +----+----+ +---+---+
883885 //
884- if (n1 == 0 && n2 == 0 && n3 == 0 && n4 > 0 ) {
886+ if (n1 == 0 && n2 > 0 && n3 > 0 && n4 > 0 ) {
885887 tileMap[x][y] = WATER_CORNER;
886888 }
887889 // Water's Corner EAST
888890 // +----+----+ +---+---+
889- // | n1 | n2 | | 1 | 0 |
891+ // | n1 | n2 | | 1 | 1 |
890892 // +----+----+ +---+---+
891- // | n3 | n4 | | 0 | 0 |
893+ // | n3 | n4 | | 1 | 0 |
892894 // +----+----+ +---+---+
893895 //
894- else if (n1 > 0 && n2 == 0 && n3 == 0 && n4 == 0 ) {
896+ else if (n4 == 0 && n1 > 0 && n2 > 0 && n3 > 0 ) {
895897 tileMap[x][y] = WATER_CORNER;
896898 }
897899 // Water's Corner SOUTH
898900 // +----+----+ +---+---+
899- // | n1 | n2 | | 0 | 1 |
901+ // | n1 | n2 | | 1 | 1 |
900902 // +----+----+ +---+---+
901- // | n3 | n4 | | 0 | 0 |
903+ // | n3 | n4 | | 0 | 1 |
902904 // +----+----+ +---+---+
903905 //
904- else if (n1 == 0 && n2 > 0 && n3 == 0 && n4 == 0 ) {
906+ else if (n3 == 0 && n1 > 0 && n2 > 0 && n4 > 0 ) {
905907 tileMap[x][y] = WATER_CORNER;
906908 }
907909 // Water's Corner NORTH
908910 // +----+----+ +---+---+
909- // | n1 | n2 | | 0 | 0 |
911+ // | n1 | n2 | | 1 | 0 |
910912 // +----+----+ +---+---+
911- // | n3 | n4 | | 1 | 0 |
913+ // | n3 | n4 | | 1 | 1 |
912914 // +----+----+ +---+---+
913915 //
914- else if (n1 == 0 && n2 == 0 && n3 > 0 && n4 == 0 ) {
916+ else if (n2 == 0 && n1 > 0 && n3 > 0 && n4 > 0 ) {
915917 tileMap[x][y] = WATER_CORNER;
916918 }
917919
@@ -966,9 +968,9 @@ Dictionary TerrainGen::generate(
966968 }
967969 // Corner SOUTH
968970 // +----+----+ +---+---+
969- // | n1 | n2 | | 0 | 0 |
971+ // | n1 | n2 | | 1 | 1 |
970972 // +----+----+ +---+---+
971- // | n3 | n4 | | 1 | 0 |
973+ // | n3 | n4 | | 2 | 1 |
972974 // +----+----+ +---+---+
973975 //
974976 else if (n1 > 0 && n2 > 0 && n3 > 0 && n4 > 0 && n3 > n1 && n3 > n2 && n3 > n4) {
@@ -1270,13 +1272,14 @@ Dictionary TerrainGen::generate(
12701272
12711273 // Decide which tile types count as "edge" for the current corner type
12721274 auto is_edge_for_corner = [&](TileType t) -> bool {
1273- if (tile_id == WATER_CORNER) {
1274- return t == WATER_EDGE;
1275- } else if (tile_id == CLIFF_CORNER) {
1276- return t == CLIFF;
1277- } else {
1278- return t == RAMP;
1279- }
1275+ return t == CLIFF || t == RAMP || t == WATER_EDGE;
1276+ // if (tile_id == WATER_CORNER) {
1277+ // return t == WATER_EDGE;
1278+ // } else if (tile_id == CLIFF_CORNER) {
1279+ // return t == CLIFF;
1280+ // } else {
1281+ // return t == RAMP;
1282+ // }
12801283 };
12811284
12821285 // Convenience flags for cardinal neighbors
@@ -1304,65 +1307,48 @@ Dictionary TerrainGen::generate(
13041307 // Corner's Higher Elevation Point : South West / m6
13051308 // NE (m3), SE (m8), SW (m6), NW (m1)
13061309 // if -1, not ground tile
1307- vector<int > dElevation = { -1 , -1 , -1 , -1 };
1308- if (neGround) {
1309- dElevation[0 ] = neHeight;
1310- }
1311-
1312- if (seGround) {
1313- dElevation[1 ] = seHeight;
1314- }
1315-
1316- if (swGround) {
1317- dElevation[2 ] = swHeight;
1318- }
1319-
1320- if (nwGround) {
1321- dElevation[3 ] = nwHeight;
1322- }
1323-
1324- if (!(nEdge && eEdge)) { // m2 + m5 | NOT m3
1325- dElevation[0 ] = -1 ;
1326- }
1327-
1328- if (!(sEdge && eEdge)) { // m5 + m7 | NOT m8
1329- dElevation[1 ] = -1 ;
1330- }
1310+ //
1311+ // Corner Edge Tiles Start pointing (-x,+z) SW
1312+ // No clue why different tiles are requiring different ROT/Orientation values
13311313
1332- if (!(sEdge && wEdge)) { // m4 + m7 | NOT m6
1333- dElevation[2 ] = -1 ;
1314+ // North East
1315+ if (nEdge && eEdge && !sEdge && !wEdge) { // m2 + m5 | NOT m3
1316+ if (tile_id == CLIFF_CORNER)
1317+ rotation_val = WEST;
1318+ if (tile_id == RAMP_CORNER)
1319+ rotation_val = EAST;
1320+ if (tile_id == WATER_CORNER)
1321+ rotation_val = EAST;
13341322 }
13351323
1336- if (!(nEdge && wEdge)) { // m4 + m2 | NOT m1
1337- dElevation[3 ] = -1 ;
1324+ // South East
1325+ if (sEdge && eEdge && !nEdge && !wEdge) { // m5 + m7 | NOT m8
1326+ if (tile_id == CLIFF_CORNER)
1327+ rotation_val = NORTH;
1328+ if (tile_id == RAMP_CORNER)
1329+ rotation_val = SOUTH;
1330+ if (tile_id == WATER_CORNER)
1331+ rotation_val = SOUTH;
13381332 }
13391333
1340- int maxElevation = dElevation[ 0 ];
1341- int dEleIndex = 0 ;
1342-
1343- for ( size_t i = 1 ; i < dElevation. size (); ++i) {
1344- if (dElevation[i] > maxElevation) {
1345- maxElevation = dElevation[i] ;
1346- dEleIndex = static_cast < int >(i);
1347- }
1334+ // South West
1335+ if ( sEdge && wEdge && !nEdge && !eEdge) { // m4 + m7 | NOT m6
1336+ if (tile_id == CLIFF_CORNER)
1337+ rotation_val = EAST;
1338+ if (tile_id == RAMP_CORNER)
1339+ rotation_val = WEST ;
1340+ if (tile_id == WATER_CORNER)
1341+ rotation_val = WEST;
13481342 }
13491343
1350- switch (dEleIndex) {
1351- case 0 :
1352- rotation_val = WEST;
1353- break ;
1354- case 1 :
1355- rotation_val = NORTH;
1356- break ;
1357- case 2 :
1358- rotation_val = EAST;
1359- break ;
1360- case 3 :
1344+ // North West
1345+ if (nEdge && wEdge && !sEdge && !eEdge) { // m4 + m2 | NOT m1
1346+ if (tile_id == CLIFF_CORNER)
13611347 rotation_val = SOUTH;
1362- break ;
1363- default :
1348+ if (tile_id == RAMP_CORNER)
1349+ rotation_val = NORTH;
1350+ if (tile_id == WATER_CORNER)
13641351 rotation_val = NORTH;
1365- break ;
13661352 }
13671353 }
13681354
@@ -1407,6 +1393,9 @@ Dictionary TerrainGen::generate(
14071393 // | n3 | n4 | | r2 | g2 | | g2 | c2 | | c2 | g1 | | g1 | r2 | | r2 | c2 |
14081394 // +----+----+ +----+----+ +----+----+ +----+----+ +----+----+ +----+----+
14091395 //
1396+
1397+ // EDGE CASE : Ramps surround a Ramp tile
1398+ // Two higher ramps and two lower ramps with a ramp tile in the center
14101399 }
14111400 }
14121401
0 commit comments