407 &_price.purchase_land, |
407 &_price.purchase_land, |
408 &_price.clear_2, // XXX unused? |
408 &_price.clear_2, // XXX unused? |
409 }; |
409 }; |
410 int32 price; |
410 int32 price; |
411 |
411 |
412 if (IsClearGround(tile, CL_GRASS) && GetClearDensity(tile) == 0) { |
412 if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) { |
413 price = 0; |
413 price = 0; |
414 } else { |
414 } else { |
415 price = *clear_price_table[GetClearGround(tile)]; |
415 price = *clear_price_table[GetClearGround(tile)]; |
416 } |
416 } |
417 |
417 |
483 } |
483 } |
484 |
484 |
485 static void DrawTile_Clear(TileInfo *ti) |
485 static void DrawTile_Clear(TileInfo *ti) |
486 { |
486 { |
487 switch (GetClearGround(ti->tile)) { |
487 switch (GetClearGround(ti->tile)) { |
488 case CL_GRASS: |
488 case CLEAR_GRASS: |
489 DrawClearLandTile(ti, GetClearDensity(ti->tile)); |
489 DrawClearLandTile(ti, GetClearDensity(ti->tile)); |
490 break; |
490 break; |
491 |
491 |
492 case CL_ROUGH: |
492 case CLEAR_ROUGH: |
493 DrawHillyLandTile(ti); |
493 DrawHillyLandTile(ti); |
494 break; |
494 break; |
495 |
495 |
496 case CL_ROCKS: |
496 case CLEAR_ROCKS: |
497 DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + _tileh_to_sprite[ti->tileh]); |
497 DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + _tileh_to_sprite[ti->tileh]); |
498 break; |
498 break; |
499 |
499 |
500 case CL_FIELDS: |
500 case CLEAR_FIELDS: |
501 DrawGroundSprite(_clear_land_sprites_1[GetFieldType(ti->tile)] + _tileh_to_sprite[ti->tileh]); |
501 DrawGroundSprite(_clear_land_sprites_1[GetFieldType(ti->tile)] + _tileh_to_sprite[ti->tileh]); |
502 break; |
502 break; |
503 |
503 |
504 case CL_SNOW: |
504 case CLEAR_SNOW: |
505 DrawGroundSprite(_clear_land_sprites_2[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]); |
505 DrawGroundSprite(_clear_land_sprites_2[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]); |
506 break; |
506 break; |
507 |
507 |
508 case CL_DESERT: |
508 case CLEAR_DESERT: |
509 DrawGroundSprite(_clear_land_sprites_3[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]); |
509 DrawGroundSprite(_clear_land_sprites_3[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]); |
510 break; |
510 break; |
511 } |
511 } |
512 |
512 |
513 DrawClearLandFence(ti); |
513 DrawClearLandFence(ti); |
537 { |
537 { |
538 byte self; |
538 byte self; |
539 byte neighbour; |
539 byte neighbour; |
540 TileIndex dirty = INVALID_TILE; |
540 TileIndex dirty = INVALID_TILE; |
541 |
541 |
542 self = (IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CL_FIELDS)); |
542 self = (IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS)); |
543 |
543 |
544 neighbour = (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 1, 0), CL_FIELDS)); |
544 neighbour = (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 1, 0), CLEAR_FIELDS)); |
545 if (GetFenceSW(tile) == 0) { |
545 if (GetFenceSW(tile) == 0) { |
546 if (self != neighbour) { |
546 if (self != neighbour) { |
547 SetFenceSW(tile, 3); |
547 SetFenceSW(tile, 3); |
548 dirty = tile; |
548 dirty = tile; |
549 } |
549 } |
552 SetFenceSW(tile, 0); |
552 SetFenceSW(tile, 0); |
553 dirty = tile; |
553 dirty = tile; |
554 } |
554 } |
555 } |
555 } |
556 |
556 |
557 neighbour = (IsTileType(TILE_ADDXY(tile, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, 1), CL_FIELDS)); |
557 neighbour = (IsTileType(TILE_ADDXY(tile, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, 1), CLEAR_FIELDS)); |
558 if (GetFenceSE(tile) == 0) { |
558 if (GetFenceSE(tile) == 0) { |
559 if (self != neighbour) { |
559 if (self != neighbour) { |
560 SetFenceSE(tile, 3); |
560 SetFenceSE(tile, 3); |
561 dirty = tile; |
561 dirty = tile; |
562 } |
562 } |
576 { |
576 { |
577 /* distance from snow line, in steps of 8 */ |
577 /* distance from snow line, in steps of 8 */ |
578 int k = GetTileZ(tile) - _opt.snow_line; |
578 int k = GetTileZ(tile) - _opt.snow_line; |
579 |
579 |
580 if (k < -TILE_HEIGHT) { // well below the snow line |
580 if (k < -TILE_HEIGHT) { // well below the snow line |
581 if (!IsClearGround(tile, CL_SNOW)) return; |
581 if (!IsClearGround(tile, CLEAR_SNOW)) return; |
582 if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CL_GRASS, 3); |
582 if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CLEAR_GRASS, 3); |
583 } else { |
583 } else { |
584 if (!IsClearGround(tile, CL_SNOW)) { |
584 if (!IsClearGround(tile, CLEAR_SNOW)) { |
585 SetClearGroundDensity(tile, CL_SNOW, 0); |
585 SetClearGroundDensity(tile, CLEAR_SNOW, 0); |
586 } else { |
586 } else { |
587 uint density = min((uint)(k + TILE_HEIGHT) / TILE_HEIGHT, 3); |
587 uint density = min((uint)(k + TILE_HEIGHT) / TILE_HEIGHT, 3); |
588 |
588 |
589 if (GetClearDensity(tile) < density) { |
589 if (GetClearDensity(tile) < density) { |
590 AddClearDensity(tile, 1); |
590 AddClearDensity(tile, 1); |
599 MarkTileDirtyByTile(tile); |
599 MarkTileDirtyByTile(tile); |
600 } |
600 } |
601 |
601 |
602 static void TileLoopClearDesert(TileIndex tile) |
602 static void TileLoopClearDesert(TileIndex tile) |
603 { |
603 { |
604 if (IsClearGround(tile, CL_DESERT)) return; |
604 if (IsClearGround(tile, CLEAR_DESERT)) return; |
605 |
605 |
606 if (GetTropicZone(tile) == TROPICZONE_DESERT) { |
606 if (GetTropicZone(tile) == TROPICZONE_DESERT) { |
607 SetClearGroundDensity(tile, CL_DESERT, 3); |
607 SetClearGroundDensity(tile, CLEAR_DESERT, 3); |
608 } else { |
608 } else { |
609 if (GetTropicZone(tile + TileDiffXY( 1, 0)) != TROPICZONE_DESERT && |
609 if (GetTropicZone(tile + TileDiffXY( 1, 0)) != TROPICZONE_DESERT && |
610 GetTropicZone(tile + TileDiffXY(-1, 0)) != TROPICZONE_DESERT && |
610 GetTropicZone(tile + TileDiffXY(-1, 0)) != TROPICZONE_DESERT && |
611 GetTropicZone(tile + TileDiffXY( 0, 1)) != TROPICZONE_DESERT && |
611 GetTropicZone(tile + TileDiffXY( 0, 1)) != TROPICZONE_DESERT && |
612 GetTropicZone(tile + TileDiffXY( 0, -1)) != TROPICZONE_DESERT) |
612 GetTropicZone(tile + TileDiffXY( 0, -1)) != TROPICZONE_DESERT) |
613 return; |
613 return; |
614 SetClearGroundDensity(tile, CL_DESERT, 1); |
614 SetClearGroundDensity(tile, CLEAR_DESERT, 1); |
615 } |
615 } |
616 |
616 |
617 MarkTileDirtyByTile(tile); |
617 MarkTileDirtyByTile(tile); |
618 } |
618 } |
619 |
619 |
625 case LT_DESERT: TileLoopClearDesert(tile); break; |
625 case LT_DESERT: TileLoopClearDesert(tile); break; |
626 case LT_HILLY: TileLoopClearAlps(tile); break; |
626 case LT_HILLY: TileLoopClearAlps(tile); break; |
627 } |
627 } |
628 |
628 |
629 switch (GetClearGround(tile)) { |
629 switch (GetClearGround(tile)) { |
630 case CL_GRASS: |
630 case CLEAR_GRASS: |
631 if (GetClearDensity(tile) == 3) return; |
631 if (GetClearDensity(tile) == 3) return; |
632 |
632 |
633 if (_game_mode != GM_EDITOR) { |
633 if (_game_mode != GM_EDITOR) { |
634 if (GetClearCounter(tile) < 7) { |
634 if (GetClearCounter(tile) < 7) { |
635 AddClearCounter(tile, 1); |
635 AddClearCounter(tile, 1); |
637 } else { |
637 } else { |
638 SetClearCounter(tile, 0); |
638 SetClearCounter(tile, 0); |
639 AddClearDensity(tile, 1); |
639 AddClearDensity(tile, 1); |
640 } |
640 } |
641 } else { |
641 } else { |
642 SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CL_GRASS : CL_ROUGH, 3); |
642 SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3); |
643 } |
643 } |
644 break; |
644 break; |
645 |
645 |
646 case CL_FIELDS: { |
646 case CLEAR_FIELDS: { |
647 uint field_type; |
647 uint field_type; |
648 |
648 |
649 if (_game_mode == GM_EDITOR) return; |
649 if (_game_mode == GM_EDITOR) return; |
650 |
650 |
651 if (GetClearCounter(tile) < 7) { |
651 if (GetClearCounter(tile) < 7) { |
675 |
675 |
676 /* add hills */ |
676 /* add hills */ |
677 i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400); |
677 i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400); |
678 do { |
678 do { |
679 tile = RandomTile(); |
679 tile = RandomTile(); |
680 if (IsTileType(tile, MP_CLEAR)) SetClearGroundDensity(tile, CL_ROUGH, 3); |
680 if (IsTileType(tile, MP_CLEAR)) SetClearGroundDensity(tile, CLEAR_ROUGH, 3); |
681 } while (--i); |
681 } while (--i); |
682 |
682 |
683 /* add grey squares */ |
683 /* add grey squares */ |
684 i = ScaleByMapSize(GB(Random(), 0, 7) + 0x80); |
684 i = ScaleByMapSize(GB(Random(), 0, 7) + 0x80); |
685 do { |
685 do { |
688 if (IsTileType(tile, MP_CLEAR)) { |
688 if (IsTileType(tile, MP_CLEAR)) { |
689 uint j = GB(r, 16, 4) + 5; |
689 uint j = GB(r, 16, 4) + 5; |
690 for (;;) { |
690 for (;;) { |
691 TileIndex tile_new; |
691 TileIndex tile_new; |
692 |
692 |
693 SetClearGroundDensity(tile, CL_ROCKS, 3); |
693 SetClearGroundDensity(tile, CLEAR_ROCKS, 3); |
694 do { |
694 do { |
695 if (--j == 0) goto get_out; |
695 if (--j == 0) goto get_out; |
696 tile_new = tile + TileOffsByDir(GB(Random(), 0, 2)); |
696 tile_new = tile + TileOffsByDir(GB(Random(), 0, 2)); |
697 } while (!IsTileType(tile_new, MP_CLEAR)); |
697 } while (!IsTileType(tile_new, MP_CLEAR)); |
698 tile = tile_new; |
698 tile = tile_new; |
721 STR_0810_DESERT |
721 STR_0810_DESERT |
722 }; |
722 }; |
723 |
723 |
724 static void GetTileDesc_Clear(TileIndex tile, TileDesc *td) |
724 static void GetTileDesc_Clear(TileIndex tile, TileDesc *td) |
725 { |
725 { |
726 if (IsClearGround(tile, CL_GRASS) && GetClearDensity(tile) == 0) { |
726 if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) { |
727 td->str = STR_080C_BARE_LAND; |
727 td->str = STR_080C_BARE_LAND; |
728 } else { |
728 } else { |
729 td->str = _clear_land_str[GetClearGround(tile)]; |
729 td->str = _clear_land_str[GetClearGround(tile)]; |
730 } |
730 } |
731 td->owner = GetTileOwner(tile); |
731 td->owner = GetTileOwner(tile); |