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
# HG changeset patch # User Ricardo@FX-8150 # Date 1516922321 0 # Thu Jan 25 23:18:41 2018 +0000 # Branch trunk # Node ID bb9639bf29af9fb142efd08d3ef6f4526f6de620 # Parent 437a5c7b0b81f96fe16ab21e1fd51e37226e1115 11 diff -r 437a5c7b0b81 -r bb9639bf29af src/vehicle.cpp --- a/src/vehicle.cpp Tue Jan 23 18:45:40 2018 +0000 +++ b/src/vehicle.cpp Thu Jan 25 23:18:41 2018 +0000 @@ -153,35 +153,15 @@ } /** - * Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for service or replacement. - * - * @see NeedsAutomaticServicing() - * @return true if the vehicle should go to a depot if a opportunity presents itself. + * Test whether there is some pending autoreplace. + * @note We do this after the service-interval test. + * There are a lot more reasons for autoreplace to fail than we can test here reasonably. + * @see NeedsServicing() + * @return true if there is a pending autoreplace */ -bool Vehicle::NeedsServicing() const +bool Vehicle::HasPendingReplace() const { - /* Stopped or crashed vehicles will not move, as such making unmovable - * vehicles to go for service is lame. */ - if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false; - - /* Are we ready for the next service cycle? */ const Company *c = Company::Get(this->owner); - if (this->ServiceIntervalIsPercent() ? - (this->reliability >= this->GetEngine()->reliability * (100 - this->GetServiceInterval()) / 100) : - (this->date_of_last_service + this->GetServiceInterval() >= _date)) { - return false; - } - - /* If we're servicing anyway, because we have not disabled servicing when - * there are no breakdowns or we are playing with breakdowns, bail out. */ - if (!_settings_game.order.no_servicing_if_no_breakdowns || - _settings_game.difficulty.vehicle_breakdowns != 0) { - return true; - } - - /* Test whether there is some pending autoreplace. - * Note: We do this after the service-interval test. - * There are a lot more reasons for autoreplace to fail than we can test here reasonably. */ bool pending_replace = false; Money needed_money = c->settings.engine_renew_money; if (needed_money > c->money) return false; @@ -222,6 +202,36 @@ } /** + * Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for service or replacement. + * + * @see NeedsAutomaticServicing() + * @return true if the vehicle should go to a depot if a opportunity presents itself. + */ +bool Vehicle::NeedsServicing() const +{ + /* Stopped or crashed vehicles will not move, as such making unmovable + * vehicles to go for service is lame. */ + if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false; + + /* Are we ready for the next service cycle? */ + const Company *c = Company::Get(this->owner); + if (this->ServiceIntervalIsPercent() ? + (this->reliability >= this->GetEngine()->reliability * (100 - this->GetServiceInterval()) / 100) : + (this->date_of_last_service + this->GetServiceInterval() >= _date)) { + return false; + } + + /* If we're servicing anyway, because we have not disabled servicing when + * there are no breakdowns or we are playing with breakdowns, bail out. */ + if (!_settings_game.order.no_servicing_if_no_breakdowns || + _settings_game.difficulty.vehicle_breakdowns != 0) { + return true; + } + + return this->HasPendingReplace(); +} + +/** * Checks if the current order should be interrupted for a service-in-depot order. * @see NeedsServicing() * @return true if the current order should be interrupted. diff -r 437a5c7b0b81 -r bb9639bf29af src/vehicle_base.h --- a/src/vehicle_base.h Tue Jan 23 18:45:40 2018 +0000 +++ b/src/vehicle_base.h Thu Jan 25 23:18:41 2018 +0000 @@ -728,6 +728,8 @@ bool NeedsAutorenewing(const Company *c, bool use_renew_setting = true) const; + bool HasPendingReplace() const; + bool NeedsServicing() const; bool NeedsAutomaticServicing() const;
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever