equal
deleted
inserted
replaced
43 uint GetTileSlope(uint tile, int *h) |
43 uint GetTileSlope(uint tile, int *h) |
44 { |
44 { |
45 uint a,b,c,d,min; |
45 uint a,b,c,d,min; |
46 int r; |
46 int r; |
47 |
47 |
48 if (GET_TILE_X(tile) == TILE_X_MAX || GET_TILE_Y(tile) == TILE_Y_MAX) { |
48 if (GET_TILE_X(tile) == MapMaxX() || GET_TILE_Y(tile) == MapMaxY()) { |
49 if (h) |
49 if (h) |
50 *h = 0; |
50 *h = 0; |
51 return 0; |
51 return 0; |
52 } |
52 } |
53 |
53 |
54 assert(tile < TILES_X * TILES_Y && GET_TILE_X(tile) != TILE_X_MAX && GET_TILE_Y(tile) != TILE_Y_MAX); |
54 assert(tile < TILES_X * TILES_Y && GET_TILE_X(tile) != MapMaxX() && GET_TILE_Y(tile) != MapMaxY()); |
55 |
55 |
56 min = a = _map_type_and_height[tile] & 0xF; |
56 min = a = _map_type_and_height[tile] & 0xF; |
57 b = _map_type_and_height[tile+TILE_XY(1,0)] & 0xF; |
57 b = _map_type_and_height[tile+TILE_XY(1,0)] & 0xF; |
58 if (min >= b) min = b; |
58 if (min >= b) min = b; |
59 c = _map_type_and_height[tile+TILE_XY(0,1)] & 0xF; |
59 c = _map_type_and_height[tile+TILE_XY(0,1)] & 0xF; |
80 return h; |
80 return h; |
81 } |
81 } |
82 |
82 |
83 void FindLandscapeHeightByTile(TileInfo *ti, uint tile) |
83 void FindLandscapeHeightByTile(TileInfo *ti, uint tile) |
84 { |
84 { |
85 if (GET_TILE_X(tile) == TILE_X_MAX || |
85 if (GET_TILE_X(tile) == MapMaxX() || GET_TILE_Y(tile) == MapMaxY()) { |
86 GET_TILE_Y(tile) == TILE_Y_MAX) { |
|
87 ti->tileh = 0; |
86 ti->tileh = 0; |
88 ti->type = MP_STRANGE; |
87 ti->type = MP_STRANGE; |
89 ti->tile = 0; |
88 ti->tile = 0; |
90 ti->map5 = 0; |
89 ti->map5 = 0; |
91 ti->z = 0; |
90 ti->z = 0; |
105 int tile; |
104 int tile; |
106 |
105 |
107 ti->x = x; |
106 ti->x = x; |
108 ti->y = y; |
107 ti->y = y; |
109 |
108 |
110 if (x >= TILE_X_MAX*16-1 || y >= TILE_Y_MAX*16-1) { |
109 if (x >= MapMaxX() * 16 - 1 || y >= MapMaxY() * 16 - 1) { |
111 ti->tileh = 0; |
110 ti->tileh = 0; |
112 ti->type = MP_STRANGE; |
111 ti->type = MP_STRANGE; |
113 ti->tile = 0; |
112 ti->tile = 0; |
114 ti->map5 = 0; |
113 ti->map5 = 0; |
115 ti->z = 0; |
114 ti->z = 0; |
510 _map_type_and_height[tile] = MP_WATER << 4; |
509 _map_type_and_height[tile] = MP_WATER << 4; |
511 _map5[tile] = 0; |
510 _map5[tile] = 0; |
512 _map_owner[tile] = OWNER_WATER; |
511 _map_owner[tile] = OWNER_WATER; |
513 } |
512 } |
514 tile++; |
513 tile++; |
515 if (GET_TILE_X(tile) == TILE_X_MAX) { |
514 if (GET_TILE_X(tile) == MapMaxX()) { |
516 tile += TILE_XY(-TILE_X_MAX, 1); |
515 tile += TILE_XY(-MapMaxX(), 1); |
517 if (GET_TILE_Y(tile) == TILE_Y_MAX) |
516 if (GET_TILE_Y(tile) == MapMaxY()) |
518 break; |
517 break; |
519 } |
518 } |
520 } |
519 } |
521 } |
520 } |
522 |
521 |
532 byte direction; |
531 byte direction; |
533 |
532 |
534 r = Random(); |
533 r = Random(); |
535 p = GetSpritePtr((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845); |
534 p = GetSpritePtr((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845); |
536 |
535 |
537 x = r & TILE_X_MAX; |
536 x = r & MapMaxX(); |
538 y = (r >> TILE_X_BITS) & TILE_Y_MAX; |
537 y = (r >> TILE_X_BITS) & MapMaxY(); |
539 |
538 |
540 |
539 |
541 if (x < 2 || y < 2) |
540 if (x < 2 || y < 2) |
542 return; |
541 return; |
543 |
542 |
565 return; |
564 return; |
566 } |
565 } |
567 } |
566 } |
568 } |
567 } |
569 |
568 |
570 if (x + w >= TILE_X_MAX-1) |
569 if (x + w >= MapMaxX() - 1) |
571 return; |
570 return; |
572 |
571 |
573 if (y + h >= TILE_Y_MAX-1) |
572 if (y + h >= MapMaxY() - 1) |
574 return; |
573 return; |
575 |
574 |
576 tile = &_map_type_and_height[TILE_XY(x,y)]; |
575 tile = &_map_type_and_height[TILE_XY(x,y)]; |
577 |
576 |
578 if (direction == 0) { |
577 if (direction == 0) { |
751 int x, y; |
750 int x, y; |
752 x = GET_TILE_X(tile) + addx; |
751 x = GET_TILE_X(tile) + addx; |
753 y = GET_TILE_Y(tile) + addy; |
752 y = GET_TILE_Y(tile) + addy; |
754 |
753 |
755 // Are we about to wrap? |
754 // Are we about to wrap? |
756 if (x > 0 && x < TILE_X_MAX && y > 0 && y < TILE_Y_MAX) |
755 if (x > 0 && x < MapMaxX() && y > 0 && y < MapMaxY()) |
757 return tile + TILE_XY(addx, addy); |
756 return tile + TILE_XY(addx, addy); |
758 |
757 |
759 return TILE_WRAPPED; |
758 return TILE_WRAPPED; |
760 } |
759 } |
761 |
760 |
762 bool IsValidTile(uint tile) |
761 bool IsValidTile(uint tile) |
763 { |
762 { |
764 return (tile < TILES_X * TILE_Y_MAX && GET_TILE_X(tile) != TILE_X_MAX); |
763 return (tile < TILES_X * MapMaxY() && GET_TILE_X(tile) != MapMaxX()); |
765 } |
764 } |