Loading
#openttdcoop - Paste
Archives
Trending
Docs
Login
ABAP
ActionScript
ActionScript 3
Ada
AIMMS3
ALGOL 68
Apache configuration
AppleScript
Apt sources
ARM ASSEMBLER
ASM
ASP
asymptote
Autoconf
Autohotkey
AutoIt
AviSynth
awk
BASCOM AVR
Bash
Basic4GL
BibTeX
BlitzBasic
bnf
Boo
Brainfuck
C
C#
C (LoadRunner)
C (Mac)
C (WinAPI)
C++
C++ (Qt)
C++ (WinAPI)
CAD DCL
CAD Lisp
CFDG
ChaiScript
Chapel
CIL
Clojure
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
Dart
DCL
DCPU-16 Assembly
DCS
Delphi
Diff
DIV
DOS
dot
E
ECMAScript
Eiffel
eMail (mbox)
EPC
Erlang
Euphoria
EZT
F#
Falcon
FO (abas-ERP)
Formula One
Fortran
FreeBasic
FreeSWITCH
GADV 4CS
GAMBAS
GDB
genero
Genie
glSlang
GML
GNU/Octave
GNU Gettext
GNU make
Gnuplot
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML
HTML5
Icon
INI
Inno
INTERCAL
Io
ISPF Panel
J
Java
Java(TM) 2 Platform Standard Edition 5.0
Javascript
JCL
jQuery
KiXtart
KLone C
KLone C++
LaTeX
LDIF
Liberty BASIC
Lisp
LLVM Intermediate Representation
Locomotive Basic
Logtalk
LOLcode
Lotus Notes @Formulas
LotusScript
LScript
LSL2
Lua
MagikSF
MapBasic
Matlab M
Microchip Assembler
Microsoft Registry
mIRC Scripting
MMIX
Modula-2
Modula-3
MOS 6502 (6510) ACME Cross Assembler format
MOS 6502 (6510) Kick Assembler format
MOS 6502 (6510) TASM/64TASS 1.46 Assembler format
Motorola 68000 - HiSoft Devpac ST 2 Assembler format
Motorola 68000 Assembler
MXML
MySQL
Nagios
NetRexx
newlisp
nginx
Nimrod
NML NewGRF Meta Language
NSIS
Oberon-2
Objeck Programming Language
Objective-C
OCaml
OCaml (brief)
ooRexx
OpenBSD Packet Filter
OpenOffice.org Basic
Oracle 8 SQL
Oracle 11 SQL
Oxygene
OZ
ParaSail
PARI/GP
Pascal
PCRE
per
Perl
Perl 6
PHP
PHP (brief)
PIC16
Pike
Pixel Bender 1.0
PL/I
PL/SQL
PostgreSQL
PostScript
POVRAY
PowerBuilder
PowerShell
ProFTPd configuration
Progress
Prolog
PROPERTIES
ProvideX
Puppet
PureBasic
Python
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
R / S+
Racket
Rails
RBScript
REBOL
rexx
robots.txt
RPM Specification File
Ruby
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
Squirrel Script
Squirrel Script with OpenTTD AI/GS
StandardML
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term Macro
Text
thinBasic
TypoScript
Unicon (Unified Extended Dialect of Icon)
Uno Idl
Unreal Script
UPC
Urbi
Vala
vb.net
VBScript
Vedit macro language
Verilog
VHDL
Vim Script
Visual Basic
Visual Fox Pro
Visual Prolog
Whitespace
Whois (RPSL format)
Winbatch
X++
XBasic
XML
Xorg configuration
YAML
ZiLOG Z80 Assembler
ZXBasic
/** * Build a ship depot. * @param tile tile where ship depot is built * @param flags type of operation * @param p1 bit 0 depot orientation (Axis) * @param p2 unused * @param text unused * @return the cost of this operation or an error */ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { Axis axis = Extract<Axis, 0, 1>(p1); TileIndexDiff diff = (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); TileIndex tile2 = tile + diff; if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); if (!Depot::CanAllocateItem()) return CMD_ERROR; CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]); CommandCost ret; WaterClass wc1 = IsWaterTile(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL; Owner oc1 = HasTileWaterGround(tile) && GetWaterClass(tile) == WATER_CLASS_CANAL ? GetCanalOwner(tile) : _current_company; bool add_cost1 = !IsWaterTile(tile); /* At this point we got a tile with no bridge over it. Check for ownership */ if (IsWaterTile(tile) && IsCanal(tile)) { ret = EnsureNoVehicleOnGround(tile); if (ret.Failed()) return ret; if (oc1 != OWNER_NONE) { ret = CheckTileOwnership(tile); if (ret.Failed() && !_settings_game.construction.build_on_competitor_canal) return ret; } } else { ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; if (add_cost1) { cost.AddCost(ret); if (wc1 == WATER_CLASS_CANAL) cost.AddCost(_price[PR_BUILD_CANAL]); } } WaterClass wc2 = IsWaterTile(tile2) ? GetWaterClass(tile2) : WATER_CLASS_CANAL; Owner oc2 = HasTileWaterGround(tile2) && GetWaterClass(tile2) == WATER_CLASS_CANAL ? GetCanalOwner(tile2) : _current_company; bool add_cost2 = !IsWaterTile(tile2); /* At this point we got a tile2 with no bridge over it. Check for ownership */ if (IsWaterTile(tile2) && IsCanal(tile2)) { ret = EnsureNoVehicleOnGround(tile2); if (ret.Failed()) return ret; if (oc2 != OWNER_NONE) { ret = CheckTileOwnership(tile2); if (ret.Failed() && !_settings_game.construction.build_on_competitor_canal) return ret; } } else { ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; if (add_cost2) { cost.AddCost(ret); if (wc2 == WATER_CLASS_CANAL) cost.AddCost(_price[PR_BUILD_CANAL]); } } int h_north_corner_n = TileHeight(tile); int h_north_corner_s = TileHeight(TileAddByDiagDir(tile, AxisToDiagDir(OtherAxis(axis)))); int h_middle_corner_n = TileHeight(tile2); int h_middle_corner_s = TileHeight(TileAddByDiagDir(tile2, AxisToDiagDir(OtherAxis(axis)))); int h_south_corner_n = TileHeight(tile2 + diff); int h_south_corner_s = TileHeight(TileAddByDiagDir(tile2 + diff, AxisToDiagDir(OtherAxis(axis)))); int corners[] = {h_north_corner_n, h_north_corner_s, h_middle_corner_n, h_middle_corner_s, h_south_corner_n, h_south_corner_s}; int min_h = MAX_TILE_HEIGHT; int max_h = 0; for (int i = 0; i < lengthof(corners); i++) { min_h = min(min_h, corners[i]); max_h = max(max_h, corners[i]); } // int min_h = min(h_north_corner_n, min(h_north_corner_s, min(h_middle_corner_n, min(h_middle_corner_s, min(h_south_corner_n, h_south_corner_s))))); // int max_h = max(h_north_corner_n, max(h_north_corner_s, max(h_middle_corner_n, max(h_middle_corner_s, max(h_south_corner_n, h_south_corner_s))))); int best_h; int max_delta = MAX_TILE_HEIGHT; for (int h = min_h; h <= max_h; h++) { int delta = 0; for (int c = 0; c < lengthof(corners); c++) { delta = max(delta, Delta(h, corners[c])); } if (delta < max_delta) { max_delta = delta; best_h = h; } } // if (!IsTileFlat(tile) || !IsTileFlat(tile2)) { // int z_slope1; // Slope slope1 = GetTileSlope(tile, &z_slope1); // int z_middle_corner_n = TileHeight(tile2); // int z_middle_corner_s = TileHeight(TileAddByDiagDir(tile2, AxisToDiagDir(OtherAxis(axis)))); // int z_slope2; // Slope slope2 = GetTileSlope(tile2, &z_slope2); // /* Forbid these combinations. */ // if (IsSteepSlope(slope1) || IsSteepSlope(slope2)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // if (slope1 == SLOPE_NS && slope2 == SLOPE_EW || slope1 == SLOPE_EW && slope2 == SLOPE_NS) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // if (z_middle_corner_n != z_middle_corner_s && (IsSlopeWithThreeCornersRaised(slope1) && IsSlopeWithOneCornerRaised(slope2) || IsSlopeWithOneCornerRaised(slope1) && IsSlopeWithThreeCornersRaised(slope2))) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // if (slope1 == slope2 && IsInclinedSlope(slope1)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // if (((IsSlopeWithOneCornerRaised(slope2) || IsSlopeWithThreeCornersRaised(slope2)) && IsInclinedSlope(slope1) && DiagDirToAxis(GetInclinedSlopeDirection(slope1)) == axis) || ((IsSlopeWithOneCornerRaised(slope1) || IsSlopeWithThreeCornersRaised(slope1)) && IsInclinedSlope(slope2) && DiagDirToAxis(GetInclinedSlopeDirection(slope2)) == axis)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // if (((slope2 == SLOPE_EW || slope2 == SLOPE_NS) && IsInclinedSlope(slope1) && DiagDirToAxis(GetInclinedSlopeDirection(slope1)) == OtherAxis(axis)) || ((slope1 == SLOPE_EW || slope1 == SLOPE_NS) && IsInclinedSlope(slope2) && DiagDirToAxis(GetInclinedSlopeDirection(slope2)) == OtherAxis(axis))) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // /* Terraform these combinations. */ // if (slope1 == SLOPE_FLAT || slope2 == SLOPE_FLAT) { // /* Mark the tile as already cleared for the terraform command. */ // ClearedObjectArea *coa = MakeClearedObjectArea(slope1 == SLOPE_FLAT ? tile2 : tile, tile, axis == AXIS_X ? 2 : 1, axis == AXIS_Y ? 2 : 1); // /* Hide the tile from the terraforming command. */ // TileIndex tile_flat_before = coa->first_tile; // coa->first_tile = INVALID_TILE; // ret = DoCommand(slope1 == SLOPE_FLAT ? tile2 : tile, slope1 == SLOPE_FLAT ? z_slope1 == z_slope2 ? slope2: ComplementSlope(slope2) : z_slope1 == z_slope2 ? slope1 : ComplementSlope(slope1), z_slope1 == z_slope2 ? 0 : 1, flags | DC_NO_WATER, CMD_TERRAFORM_LAND); // coa->first_tile = tile_flat_before; // if (ret.Failed()) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // cost.AddCost(ret); // } else { // if ((IsSlopeWithThreeCornersRaised(slope1) || IsSlopeWithOneCornerRaised(slope1)) && (IsSlopeWithThreeCornersRaised(slope2) || IsSlopeWithOneCornerRaised(slope2))) { // /* Mark the tile as already cleared for the terraform command. */ // ClearedObjectArea *coa = MakeClearedObjectArea(tile, tile, axis == AXIS_X ? 2 : 1, axis == AXIS_Y ? 2 : 1); // /* Hide the tile from the terraforming command. */ // TileIndex tile_3corner1_before = coa->first_tile; // coa->first_tile = INVALID_TILE; // ret = DoCommand(tile, IsSlopeWithThreeCornersRaised(slope1) ? ComplementSlope(slope1) : slope1, IsSlopeWithThreeCornersRaised(slope1) ? 1 : 0, flags | DC_NO_WATER, CMD_TERRAFORM_LAND); // coa->first_tile = tile_3corner1_before; // if (ret.Failed()) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // cost.AddCost(ret); // if (z_middle_corner_n == z_middle_corner_s) { // /* Mark the tile as already cleared for the terraform command. */ // ClearedObjectArea *coa = MakeClearedObjectArea(tile2, tile, axis == AXIS_X ? 2 : 1, axis == AXIS_Y ? 2 : 1); // /* Hide the tile from the terraforming command. */ // TileIndex tile_3corner2_before = coa->first_tile; // coa->first_tile = INVALID_TILE; // ret = DoCommand(tile2, IsSlopeWithThreeCornersRaised(slope2) ? ComplementSlope(slope2) : slope2, IsSlopeWithThreeCornersRaised(slope2) ? 1 : 0, flags | DC_NO_WATER, CMD_TERRAFORM_LAND); // coa->first_tile = tile_3corner2_before; // if (ret.Failed()) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // cost.AddCost(ret); // } // } else { // if ((IsInclinedSlope(slope1) && DiagDirToAxis(GetInclinedSlopeDirection(slope1)) == OtherAxis(axis) && (IsSlopeWithOneCornerRaised(slope2) || IsSlopeWithThreeCornersRaised(slope2))) || (IsInclinedSlope(slope2) && DiagDirToAxis(GetInclinedSlopeDirection(slope2)) == OtherAxis(axis) && (IsSlopeWithOneCornerRaised(slope1) || IsSlopeWithThreeCornersRaised(slope1)))) { // /* Mark the tile as already cleared for the terraform command. */ // ClearedObjectArea *coa = MakeClearedObjectArea(IsInclinedSlope(slope1) ? tile : tile2, tile, axis == AXIS_X ? 2 : 1, axis == AXIS_Y ? 2 : 1); // /* Hide the tile from the terraforming command. */ // TileIndex tile_inclined1_before = coa->first_tile; // coa->first_tile = INVALID_TILE; // ret = DoCommand(IsInclinedSlope(slope1) ? tile : tile2, IsInclinedSlope(slope1) ? IsSlopeWithThreeCornersRaised(slope2) ? ComplementSlope(slope1) : slope1 : IsSlopeWithThreeCornersRaised(slope1) ? ComplementSlope(slope2) : slope2, IsInclinedSlope(slope1) ? IsSlopeWithThreeCornersRaised(slope2) ? 1 : 0 : IsSlopeWithThreeCornersRaised(slope1) ? 1 : 0, flags | DC_NO_WATER, CMD_TERRAFORM_LAND); // coa->first_tile = tile_inclined1_before; // if (ret.Failed()) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // cost.AddCost(ret); // } else { // if ((slope1 == SLOPE_EW || slope1 == SLOPE_NS) && (IsSlopeWithOneCornerRaised(slope2) || IsSlopeWithThreeCornersRaised(slope2)) || (slope2 == SLOPE_NS || slope2 == SLOPE_EW) && (IsSlopeWithOneCornerRaised(slope1) || IsSlopeWithThreeCornersRaised(slope1))) { // /* Mark the tile as already cleared for the terraform command. */ // ClearedObjectArea *coa = MakeClearedObjectArea((slope1 == SLOPE_EW || slope1 == SLOPE_NS) ? tile : tile2, tile, axis == AXIS_X ? 2 : 1, axis == AXIS_Y ? 2 : 1); // /* Hide the tile from the terraforming command. */ // TileIndex tile_oppositecorners_before = coa->first_tile; // coa->first_tile = INVALID_TILE; // ret = DoCommand((slope1 == SLOPE_EW || slope1 == SLOPE_NS) ? tile : tile2, (slope1 == SLOPE_EW || slope1 == SLOPE_NS) ? IsSlopeWithOneCornerRaised(slope2) ? slope1 : ComplementSlope(slope1) : IsSlopeWithOneCornerRaised(slope1) ? slope2 : ComplementSlope(slope2), (slope1 == SLOPE_EW || slope1 == SLOPE_NS) ? IsSlopeWithOneCornerRaised(slope2) ? 0 : 1 : IsSlopeWithOneCornerRaised(slope1) ? 0 : 1, flags | DC_NO_WATER, CMD_TERRAFORM_LAND); // coa->first_tile = tile_oppositecorners_before; // if (ret.Failed()) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // cost.AddCost(ret); // } else { // if (slope1 == ComplementSlope(slope2) && IsInclinedSlope(slope1)) { // /* Mark the tile as already cleared for the terraform command. */ // ClearedObjectArea *coa = MakeClearedObjectArea(tile2, tile, axis == AXIS_X ? 2 : 1, axis == AXIS_Y ? 2 : 1); // /* Hide the tile from the terraforming command. */ // TileIndex tile_complement_before = coa->first_tile; // coa->first_tile = INVALID_TILE; // ret = DoCommand(tile2, z_middle_corner_n > z_slope1 ? slope2 : slope1, z_middle_corner_n > z_slope1 ? 0 : 1, flags | DC_NO_WATER, CMD_TERRAFORM_LAND); // coa->first_tile = tile_complement_before; // if (ret.Failed()) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); // cost.AddCost(ret); // } else { // /* Shouldn't reach here. */ // assert(false); // } // } // } // } // } // } if (!IsTileFlat(tile) || !IsTileFlat(tile2)) return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); DiagDirection dir_rotate = axis == AXIS_X ? DIAGDIR_SE : DIAGDIR_NE; TileIndex tc = tile + (axis == AXIS_X ? TileDiffXY(0, -1) : TileDiffXY(1, 0)); ret = EnsureNoShipFromDiagDir(tc, dir_rotate); if (ret.Failed()) return ret; tc = tile2 + (axis == AXIS_X ? TileDiffXY(0, -1) : TileDiffXY(1, 0)); ret = EnsureNoShipFromDiagDir(tc, dir_rotate); if (ret.Failed()) return ret; dir_rotate = ReverseDiagDir(dir_rotate); tc = tile + (axis == AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(-1, 0)); ret = EnsureNoShipFromDiagDir(tc, dir_rotate); if (ret.Failed()) return ret; tc = tile2 + (axis == AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(-1, 0)); ret = EnsureNoShipFromDiagDir(tc, dir_rotate); if (ret.Failed()) return ret; if (flags & DC_EXEC) { Depot *depot = new Depot(tile); depot->build_date = _date; if (add_cost1 && wc1 == WATER_CLASS_CANAL) Company::Get(_current_company)->infrastructure.water++; if (add_cost2 && wc2 == WATER_CLASS_CANAL) Company::Get(_current_company)->infrastructure.water++; Company::Get(_current_company)->infrastructure.water += 2 * LOCK_DEPOT_TILE_FACTOR; DirtyCompanyInfrastructureWindows(_current_company); MakeShipDepot(tile, _current_company, oc1, depot->index, DEPOT_PART_NORTH, axis, wc1); MakeShipDepot(tile2, _current_company, oc2, depot->index, DEPOT_PART_SOUTH, axis, wc2); MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile2); MakeDefaultName(depot); } return cost; } void MakeWaterKeepingClass(TileIndex tile, Owner o) { WaterClass wc = GetWaterClass(tile); /* Autoslope might turn an originally canal or river tile into land */ int z; Slope slope = GetTileSlope(tile, &z); if (slope != SLOPE_FLAT) { if (wc == WATER_CLASS_CANAL) { /* If we clear the canal, we have to remove it from the infrastructure count as well. */ Company *c = Company::GetIfValid(o); if (c != NULL) { c->infrastructure.water--; DirtyCompanyInfrastructureWindows(c->index); } /* Sloped canals are locks and no natural water remains whatever the slope direction */ wc = WATER_CLASS_INVALID; } /* Only river water should be restored on appropriate slopes. Other water would be invalid on slopes */ if (wc != WATER_CLASS_RIVER || GetInclinedSlopeDirection(slope) == INVALID_DIAGDIR) { wc = WATER_CLASS_INVALID; } } if (wc == WATER_CLASS_SEA && z > 0) { /* Update company infrastructure count. */ Company *c = Company::GetIfValid(o); if (c != NULL) { c->infrastructure.water++; DirtyCompanyInfrastructureWindows(c->index); } wc = WATER_CLASS_CANAL; } bool river = HasTileCanalOnRiver(tile); /* Zero map array and terminate animation */ DoClearSquare(tile); /* Maybe change to water */ switch (wc) { case WATER_CLASS_SEA: MakeSea(tile); break; case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); if (river) SetCanalOnRiver(tile); break; case WATER_CLASS_RIVER: MakeRiver(tile, Random()); break; default: break; } MarkTileDirtyByTile(tile); } static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags) { if (!IsShipDepot(tile)) return CMD_ERROR; CommandCost ret = CheckTileOwnership(tile); if (ret.Failed()) return ret; Owner oc1 = GetWaterClass(tile) == WATER_CLASS_CANAL ? GetCanalOwner(tile) : INVALID_OWNER; TileIndex tile2 = GetOtherShipDepotTile(tile); Owner oc2 = GetWaterClass(tile2) == WATER_CLASS_CANAL ? GetCanalOwner(tile2) : INVALID_OWNER; /* do not check for ship on tile when company goes bankrupt */ if (!(flags & DC_BANKRUPT)) { CommandCost ret = EnsureNoVehicleOnGround(tile); if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2); if (ret.Failed()) return ret; } if (flags & DC_EXEC) { delete Depot::GetByTile(tile); Company *c = Company::GetIfValid(GetTileOwner(tile)); if (c != NULL) { c->infrastructure.water -= 2 * LOCK_DEPOT_TILE_FACTOR; DirtyCompanyInfrastructureWindows(c->index); } MakeWaterKeepingClass(tile, oc1); MakeWaterKeepingClass(tile2, oc2); } return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_SHIP]); }
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever