222 |
222 |
223 if (flags & DC_EXEC) { |
223 if (flags & DC_EXEC) { |
224 Depot *depot = new Depot(tile); |
224 Depot *depot = new Depot(tile); |
225 depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
225 depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
226 |
226 |
227 MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1); |
227 MakeShipDepot(tile, _current_company, DEPOT_NORTH, axis, wc1); |
228 MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2); |
228 MakeShipDepot(tile2, _current_company, DEPOT_SOUTH, axis, wc2); |
229 MarkTileDirtyByTile(tile); |
229 MarkTileDirtyByTile(tile); |
230 MarkTileDirtyByTile(tile2); |
230 MarkTileDirtyByTile(tile2); |
231 } |
231 } |
232 |
232 |
233 return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot); |
233 return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot); |
312 (MayHaveBridgeAbove(tile + delta) && IsBridgeAbove(tile + delta))) { |
312 (MayHaveBridgeAbove(tile + delta) && IsBridgeAbove(tile + delta))) { |
313 return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
313 return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
314 } |
314 } |
315 |
315 |
316 if (flags & DC_EXEC) { |
316 if (flags & DC_EXEC) { |
317 MakeLock(tile, _current_player, dir, wc_lower, wc_upper); |
317 MakeLock(tile, _current_company, dir, wc_lower, wc_upper); |
318 MarkTileDirtyByTile(tile); |
318 MarkTileDirtyByTile(tile); |
319 MarkTileDirtyByTile(tile - delta); |
319 MarkTileDirtyByTile(tile - delta); |
320 MarkTileDirtyByTile(tile + delta); |
320 MarkTileDirtyByTile(tile + delta); |
321 MarkCanalsAndRiversAroundDirty(tile - delta); |
321 MarkCanalsAndRiversAroundDirty(tile - delta); |
322 MarkCanalsAndRiversAroundDirty(tile + delta); |
322 MarkCanalsAndRiversAroundDirty(tile + delta); |
416 if (TileHeight(tile) == 0 && p2 == 1) { |
416 if (TileHeight(tile) == 0 && p2 == 1) { |
417 MakeWater(tile); |
417 MakeWater(tile); |
418 } else if (p2 == 2) { |
418 } else if (p2 == 2) { |
419 MakeRiver(tile, Random()); |
419 MakeRiver(tile, Random()); |
420 } else { |
420 } else { |
421 MakeCanal(tile, _current_player, Random()); |
421 MakeCanal(tile, _current_company, Random()); |
422 } |
422 } |
423 MarkTileDirtyByTile(tile); |
423 MarkTileDirtyByTile(tile); |
424 MarkCanalsAndRiversAroundDirty(tile); |
424 MarkCanalsAndRiversAroundDirty(tile); |
425 } |
425 } |
426 |
426 |
480 {-1, 0}, {0, 1}, { 1, 0}, {0, -1}, // lower |
480 {-1, 0}, {0, 1}, { 1, 0}, {0, -1}, // lower |
481 { 1, 0}, {0, -1}, {-1, 0}, {0, 1}, // upper |
481 { 1, 0}, {0, -1}, {-1, 0}, {0, 1}, // upper |
482 }; |
482 }; |
483 |
483 |
484 if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
484 if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
485 if (_current_player == OWNER_WATER) return CMD_ERROR; |
485 if (_current_company == OWNER_WATER) return CMD_ERROR; |
486 /* move to the middle tile.. */ |
486 /* move to the middle tile.. */ |
487 return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[GetSection(tile)]), flags); |
487 return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[GetSection(tile)]), flags); |
488 } |
488 } |
489 |
489 |
490 case WATER_TILE_DEPOT: |
490 case WATER_TILE_DEPOT: |
739 DrawWaterStuff(ti, t, 0, ti->z > t[3].delta_y ? 24 : 0, true); |
739 DrawWaterStuff(ti, t, 0, ti->z > t[3].delta_y ? 24 : 0, true); |
740 } break; |
740 } break; |
741 |
741 |
742 case WATER_TILE_DEPOT: |
742 case WATER_TILE_DEPOT: |
743 DrawWaterClassGround(ti); |
743 DrawWaterClassGround(ti); |
744 DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0, false); |
744 DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], COMPANY_SPRITE_COLOR(GetTileOwner(ti->tile)), 0, false); |
745 break; |
745 break; |
746 } |
746 } |
747 } |
747 } |
748 |
748 |
749 void DrawShipDepotSprite(int x, int y, int image) |
749 void DrawShipDepotSprite(int x, int y, int image) |
752 |
752 |
753 DrawSprite(wdts++->image, PAL_NONE, x, y); |
753 DrawSprite(wdts++->image, PAL_NONE, x, y); |
754 |
754 |
755 for (; wdts->delta_x != 0x80; wdts++) { |
755 for (; wdts->delta_x != 0x80; wdts++) { |
756 Point pt = RemapCoords(wdts->delta_x, wdts->delta_y, wdts->delta_z); |
756 Point pt = RemapCoords(wdts->delta_x, wdts->delta_y, wdts->delta_z); |
757 DrawSprite(wdts->image, PLAYER_SPRITE_COLOR(_local_player), x + pt.x, y + pt.y); |
757 DrawSprite(wdts->image, COMPANY_SPRITE_COLOR(_local_company), x + pt.x, y + pt.y); |
758 } |
758 } |
759 } |
759 } |
760 |
760 |
761 |
761 |
762 static uint GetSlopeZ_Water(TileIndex tile, uint x, uint y) |
762 static uint GetSlopeZ_Water(TileIndex tile, uint x, uint y) |
991 { |
991 { |
992 assert(!IsTileType(target, MP_WATER)); |
992 assert(!IsTileType(target, MP_WATER)); |
993 |
993 |
994 bool flooded = false; // Will be set to true if something is changed. |
994 bool flooded = false; // Will be set to true if something is changed. |
995 |
995 |
996 _current_player = OWNER_WATER; |
996 _current_company = OWNER_WATER; |
997 |
997 |
998 Slope tileh = GetTileSlope(target, NULL); |
998 Slope tileh = GetTileSlope(target, NULL); |
999 if (tileh != SLOPE_FLAT) { |
999 if (tileh != SLOPE_FLAT) { |
1000 /* make coast.. */ |
1000 /* make coast.. */ |
1001 switch (GetTileType(target)) { |
1001 switch (GetTileType(target)) { |
1043 |
1043 |
1044 /* update signals if needed */ |
1044 /* update signals if needed */ |
1045 UpdateSignalsInBuffer(); |
1045 UpdateSignalsInBuffer(); |
1046 } |
1046 } |
1047 |
1047 |
1048 _current_player = OWNER_NONE; |
1048 _current_company = OWNER_NONE; |
1049 } |
1049 } |
1050 |
1050 |
1051 /** |
1051 /** |
1052 * Drys a tile up. |
1052 * Drys a tile up. |
1053 */ |
1053 */ |
1054 static void DoDryUp(TileIndex tile) |
1054 static void DoDryUp(TileIndex tile) |
1055 { |
1055 { |
1056 _current_player = OWNER_WATER; |
1056 _current_company = OWNER_WATER; |
1057 |
1057 |
1058 switch (GetTileType(tile)) { |
1058 switch (GetTileType(tile)) { |
1059 case MP_RAILWAY: |
1059 case MP_RAILWAY: |
1060 assert(IsPlainRailTile(tile)); |
1060 assert(IsPlainRailTile(tile)); |
1061 assert(GetRailGroundType(tile) == RAIL_GROUND_WATER); |
1061 assert(GetRailGroundType(tile) == RAIL_GROUND_WATER); |
1211 |
1211 |
1212 ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP); |
1212 ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP); |
1213 } |
1213 } |
1214 } |
1214 } |
1215 |
1215 |
1216 static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID new_player) |
1216 static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_owner) |
1217 { |
1217 { |
1218 if (!IsTileOwner(tile, old_player)) return; |
1218 if (!IsTileOwner(tile, old_owner)) return; |
1219 |
1219 |
1220 if (new_player != PLAYER_SPECTATOR) { |
1220 if (new_owner != INVALID_OWNER) { |
1221 SetTileOwner(tile, new_player); |
1221 SetTileOwner(tile, new_owner); |
1222 return; |
1222 return; |
1223 } |
1223 } |
1224 |
1224 |
1225 /* Remove depot */ |
1225 /* Remove depot */ |
1226 if (IsShipDepot(tile)) DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR); |
1226 if (IsShipDepot(tile)) DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR); |
1227 |
1227 |
1228 /* Set owner of canals and locks ... and also canal under dock there was before. |
1228 /* Set owner of canals and locks ... and also canal under dock there was before. |
1229 * Check if the new owner after removing depot isn't OWNER_WATER. */ |
1229 * Check if the new owner after removing depot isn't OWNER_WATER. */ |
1230 if (IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE); |
1230 if (IsTileOwner(tile, old_owner)) SetTileOwner(tile, OWNER_NONE); |
1231 } |
1231 } |
1232 |
1232 |
1233 static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y) |
1233 static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y) |
1234 { |
1234 { |
1235 return VETSB_CONTINUE; |
1235 return VETSB_CONTINUE; |