| 902 | } |
| 903 | |
| 904 | static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new) |
| 905 | { |
| 906 | ObjectType type = GetObjectType(tile); |
| 907 | |
| 908 | if (type == OBJECT_OWNED_LAND) { |
| 909 | /* Owned land remains unsold */ |
| 910 | CommandCost ret = CheckTileOwnership(tile); |
| 911 | if (ret.Succeeded()) return CommandCost(); |
| 912 | } else if (AutoslopeEnabled() && type != OBJECT_TRANSMITTER && type != OBJECT_LIGHTHOUSE) { |
| 913 | /* Behaviour: |
| 914 | * - Both new and old slope must not be steep. |
| 915 | * - TileMaxZ must not be changed. |
| 916 | * - Allow autoslope by default. |
| 917 | * - Disallow autoslope if callback succeeds and returns non-zero. |
| 918 | */ |
| 919 | Slope tileh_old = GetTileSlope(tile); |
| 920 | /* TileMaxZ must not be changed. Slopes must not be steep. */ |
| 921 | if (!IsSteepSlope(tileh_old) && !IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) { |
| 922 | const ObjectSpec *spec = ObjectSpec::Get(type); |
| 923 | |
| 924 | /* Call callback 'disable autosloping for objects'. */ |
| 925 | if (spec->callback_mask.Test(ObjectCallbackMask::Autoslope)) { |
| 926 | /* If the callback fails, allow autoslope. */ |
| 927 | uint16_t res = GetObjectCallback(CBID_OBJECT_AUTOSLOPE, 0, 0, spec, Object::GetByTile(tile), tile); |
| 928 | if (res == CALLBACK_FAILED || !ConvertBooleanCallback(spec->grf_prop.grffile, CBID_OBJECT_AUTOSLOPE, res)) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]); |
| 929 | } else if (spec->IsEnabled()) { |
| 930 | /* allow autoslope */ |
| 931 | return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]); |
| 932 | } |
| 933 | } |
| 934 | } |
| 935 | |
| 936 | return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile); |
| 937 | } |
| 938 | |
| 939 | static CommandCost CheckBuildAbove_Object(TileIndex tile, DoCommandFlags flags, Axis, int height) |
| 940 | { |
nothing calls this directly
no test coverage detected