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
/** * Find a suitable spot for an airport, walking all towns hoping to find one. * When a town is used, it is marked as such and not re-used. */ function WrightAI::FindSuitableAirportSpot(airportTypes, airport1_tile, large_aircraft, small_aircraft, helicopter, triedTowns) { local town_list = AITownList(); /* Remove all the towns we already used */ town_list.RemoveList(this.towns_used); /* Remove towns we have tried recently */ town_list.RemoveList(triedTowns); if (AIController.GetSetting("cities_only")) { town_list.Valuate(AITown.IsCity); town_list.KeepValue(1); } town_list.Valuate(AITown.GetLastMonthProduction, this.cargoId); town_list.KeepAboveValue(LuDiAIAfterFix.cargoClass == AICargo.CC_PASSENGERS ? 70 : 18); if (AIController.GetSetting("pick_random")) { town_list.Valuate(AIBase.RandItem); } else { town_list.Sort(AIList.SORT_BY_VALUE, false); } /* Keep the best 10, if we can't find a station in there, just leave it anyway */ town_list.KeepTop(10); /* Now find a suitable town */ for (local town = town_list.Begin(); town_list.HasNext(); town = town_list.Next()) { // /* Don't make this a CPU hog */ // Sleep(1); local town_tile = AITown.GetLocation(town); AILog.Info("Checking town " + AITown.GetName(town)); local tileList = AITileList(); for (local i = airportTypes.Begin(); airportTypes.HasNext(); i = airportTypes.Next()) { local a = airportTypes.GetValue(i); local airport_x = AIAirport.GetAirportWidth(a); local airport_y = AIAirport.GetAirportHeight(a); local airport_rad = AIAirport.GetAirportCoverageRadius(a); // AILog.Info("Checking airport of type " + a); if (!AIAirport.IsValidAirportType(a)) continue; if (large_aircraft && a != AIAirport.AT_INTERCON && a != AIAirport.AT_INTERNATIONAL && a != AIAirport.AT_METROPOLITAN && a != AIAirport.AT_LARGE) { continue; } if (small_aircraft && (a == AIAirport.AT_INTERCON || a == AIAirport.AT_INTERNATIONAL || a == AIAirport.AT_METROPOLITAN || a == AIAirport.AT_LARGE)) { continue; } if (helicopter && a != AIAirport.AT_HELISTATION && a != AIAirport.AT_HELIDEPOT && a != AIAirport.AT_HELIPORT) { continue; } local rectangleCoordinates = this.TownAirportRadRect(a, town); tileList.AddRectangle(rectangleCoordinates[0], rectangleCoordinates[1]); tileList.Valuate(AITile.GetClosestTown); tileList.KeepValue(town); tileList.Valuate(AITile.IsBuildableRectangle, airport_x, airport_y); tileList.KeepValue(1) if (tileList.Count() == 0) continue; if (airport1_tile != 0) { /* If we have the tile of the first airport, we don't want the second airport to be as close */ tileList.Valuate(AITile.GetDistanceManhattanToTile, airport1_tile); tileList.KeepAboveValue(min_air_distance); if (tileList.Count() == 0) continue; } /* Sort on acceptance, remove places that don't have acceptance */ tileList.Valuate(AITile.GetCargoAcceptance, this.cargoId, airport_x, airport_y, airport_rad); tileList.RemoveBelowValue(10); if (tileList.Count() == 0) continue; tileList.Valuate(AITile.GetCargoProduction, this.cargoId, airport_x, airport_y, airport_rad); tileList.RemoveBelowValue(10); if (tileList.Count() == 0) continue; tileList.Sort(AIList.SORT_BY_VALUE, false); /* Couldn't find a suitable place for this town, skip to the next */ if (tileList.Count() == 0) continue; /* Walk all the tiles and see if we can build the airport at all */ local test = AITestMode(); local good_tile = 0; for (local tile = tileList.Begin(); tileList.HasNext(); tile = tileList.Next()) { local adjacentStationId = checkAdjacentStation(tile, a); local nearest_town; if (adjacentStationId == AIStation.STATION_NEW) { nearest_town = AITile.GetClosestTown(tile); } else { nearest_town = AIStation.GetNearestTown(adjacentStationId); } local noise = AIAirport.GetNoiseLevelIncrease(tile, a); local allowed_noise = AITown.GetAllowedNoise(AIAirport.GetNearestTown(tile, a)); if (noise > allowed_noise) continue; // AISign.BuildSign(tile, ("" + noise + " <= " + allowed_noise + "")); Sleep(1); // local test = AITestMode(); if (!AIAirport.BuildAirport(tile, a, AIStation.STATION_NEW)) continue; good_tile = tile; // AILog.Info("Found a good spot for an airport near " + AITown.GetName(nearest_town) + " or " + AITown.GetName(aitile) + " at tile " + good_tile); AILog.Info("Found a good spot for an airport near " + AITown.GetName(nearest_town) + " at tile " + good_tile); /* Make the town as used, so we don't use it again */ assert(!towns_used.HasItem(nearest_town) && town == nearest_town); this.towns_used.AddItem(nearest_town, good_tile); if (a == AIAirport.AT_INTERCON || a == AIAirport.AT_INTERNATIONAL || a == AIAirport.AT_METROPOLITAN || a == AIAirport.AT_LARGE) { large_aircraft = true; } if (a == AIAirport.AT_SMALL || a == AIAirport.AT_COMMUTER) { small_aircraft = true; } if (a == AIAirport.AT_HELISTATION || a == AIAirport.AT_HELIDEPOT || a == AIAirport.AT_HELIPORT) { helicopter = true; } return [good_tile, a, large_aircraft, small_aircraft, helicopter, triedTowns]; } } /* All airport types were tried on this town and no suitable location was found */ if (airport1_tile == 0) { triedTowns.AddItem(town, town_tile); } } /* We haven't found a suitable location for any airport type in any town */ return [-1, AIAirport.AT_INVALID, large_aircraft, small_aircraft, helicopter, triedTowns]; }
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever