Merge branch 'departure-boards' into departure-boards-sx
This commit is contained in:
26
config.lib
26
config.lib
@@ -29,6 +29,7 @@ set_default() {
|
||||
strip=""
|
||||
lipo=""
|
||||
awk="awk"
|
||||
pkg_config="pkg-config"
|
||||
os="DETECT"
|
||||
endian="AUTO"
|
||||
cpu_type="DETECT"
|
||||
@@ -105,6 +106,7 @@ set_default() {
|
||||
strip
|
||||
lipo
|
||||
awk
|
||||
pkg_config
|
||||
os
|
||||
endian
|
||||
cpu_type
|
||||
@@ -213,6 +215,8 @@ detect_params() {
|
||||
--windres=*) windres="$optarg";;
|
||||
--awk) prev_p="awk";;
|
||||
--awk=*) awk="$optarg";;
|
||||
--pkg-config) prev_p="pkg_config";;
|
||||
--pkg-config=*) pkg_config="$optarg";;
|
||||
--strip) prev_p="strip";;
|
||||
--strip=*) strip="$optarg";;
|
||||
--lipo) prev_p="lipo";;
|
||||
@@ -1938,9 +1942,26 @@ check_compiler() {
|
||||
log 2 " exit code $ret"
|
||||
|
||||
if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
|
||||
if [ -z "$5" ]; then
|
||||
log 1 "checking $1... $compiler not found"
|
||||
log 1 "I couldn't detect any $6 binary for $3"
|
||||
exit 1
|
||||
else
|
||||
compiler="$3-$5"
|
||||
fi
|
||||
machine=`eval $compiler $9 2>/dev/null`
|
||||
ret=$?
|
||||
eval "$2=\"$compiler\""
|
||||
|
||||
log 2 "executing $compiler $9"
|
||||
log 2 " returned $machine"
|
||||
log 2 " exit code $ret"
|
||||
|
||||
if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
|
||||
log 1 "checking $1... $compiler not found"
|
||||
log 1 "I couldn't detect any $5 binary for $3"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$machine" != "$3" ] && ( [ "$8" = "0" ] || [ "$8" = "1" ] ); then
|
||||
@@ -2736,7 +2757,7 @@ detect_pkg_config() {
|
||||
log 2 "detecting $2"
|
||||
|
||||
if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
|
||||
pkg_config_call="pkg-config $2"
|
||||
pkg_config_call="$pkg_config $2"
|
||||
else
|
||||
pkg_config_call="$1"
|
||||
fi
|
||||
@@ -2758,7 +2779,7 @@ detect_pkg_config() {
|
||||
|
||||
# It was forced, so it should be found.
|
||||
if [ "$1" != "1" ]; then
|
||||
log 1 "configure: error: pkg-config $2 couldn't be found"
|
||||
log 1 "configure: error: $pkg_config $2 couldn't be found"
|
||||
log 1 "configure: error: you supplied '$1', but it seems invalid"
|
||||
exit 1
|
||||
fi
|
||||
@@ -3588,6 +3609,7 @@ showhelp() {
|
||||
echo " --windres=WINDRES the windres to use [HOST-windres]"
|
||||
echo " --strip=STRIP the strip to use [HOST-strip]"
|
||||
echo " --awk=AWK the awk to use in configure [awk]"
|
||||
echo " --pkg-config=PKG-CONFIG the pkg-config to use in configure [pkg-config]"
|
||||
echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]"
|
||||
echo " --os=OS the OS we are compiling for [DETECT]"
|
||||
echo " DETECT/UNIX/OSX/FREEBSD/DRAGONFLY/OPENBSD/"
|
||||
|
@@ -205,8 +205,8 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If an order doesn't have a travel time set, then stop. */
|
||||
if (order->GetTravelTime() == 0) {
|
||||
/* If an order has a 0 travel time, and it's not explictly set, then stop. */
|
||||
if (order->GetTravelTime() == 0 && !order->IsTravelTimetabled()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
candidate_via = (StationID)order->GetDestination();
|
||||
}
|
||||
|
||||
if (c.scheduled_date != 0 && order->GetTravelTime() != 0) {
|
||||
if (c.scheduled_date != 0 && (order->GetTravelTime() != 0 || order->IsTravelTimetabled())) {
|
||||
c.scheduled_date += order->GetTravelTime();
|
||||
} else {
|
||||
c.scheduled_date = 0;
|
||||
@@ -585,8 +585,8 @@ DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5],
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If an order doesn't have a travel time set, then stop. */
|
||||
if (order->GetTravelTime() == 0) {
|
||||
/* If an order has a 0 travel time, and it's not explictly set, then stop. */
|
||||
if (order->GetTravelTime() == 0 && !order->IsTravelTimetabled()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -1390,7 +1390,7 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Ropné rafineri
|
||||
STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Výška sněhové čáry: {STRING}
|
||||
STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Určuje o jaké výšky se vyskytuje sníh u subarktického klimatu. Sníh rovněž ovlivňuje vytváření průmyslu a požadavky na růst měst
|
||||
STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Členitost krajiny: {STRING}
|
||||
STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(Pouze TerraGenesis) Zvol množství hor: Rovinatý terén má méně hor, které jsou však rozlehlejší. Členitý terén má mnoho hor, u kterých se může zdát, že se upakují
|
||||
STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(Pouze TerraGenesis) Zvol množství hor: Rovinatý terén má méně hor, které jsou však rozlehlejší. Členitý terén má mnoho hor, u kterých se může zdát, že se opakují
|
||||
STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :velmi rovná
|
||||
STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH :rovná
|
||||
STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH :členitá
|
||||
|
@@ -1143,7 +1143,7 @@ STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN :Maximale beginl
|
||||
STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN_HELPTEXT :Maximale bedrag een bedrijf kan lenen (zonder rekening te houden met de inflatie)
|
||||
STR_CONFIG_SETTING_INTEREST_RATE :Rente van lening: {STRING}
|
||||
STR_CONFIG_SETTING_INTEREST_RATE_HELPTEXT :Percentage rente op lening; bepaald ook het inflatiecijfer wanneer ingeschakeld
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS :Brandstofkosten: {STRING}
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS :Onderhoudskosten: {STRING}
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_HELPTEXT :Het niveau van onderhoud en bedrijfskosten van voertuigen en infrastuctuur
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_SPEED :Bouwsnelheid: {STRING}
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_SPEED_HELPTEXT :Beperk de hoeveelheid bouwactiviteiten voor computerspeler
|
||||
@@ -3184,16 +3184,16 @@ STR_FINANCES_EXPENDITURE_INCOME_TITLE :{WHITE}Uitgaven
|
||||
STR_FINANCES_YEAR :{WHITE}{NUM}
|
||||
STR_FINANCES_SECTION_CONSTRUCTION :{GOLD}Bouwkosten
|
||||
STR_FINANCES_SECTION_NEW_VEHICLES :{GOLD}Nieuwe voertuigen
|
||||
STR_FINANCES_SECTION_TRAIN_RUNNING_COSTS :{GOLD}Treinbrandstofkosten
|
||||
STR_FINANCES_SECTION_TRAIN_RUNNING_COSTS :{GOLD}Treinonderhoudskosten
|
||||
STR_FINANCES_SECTION_ROAD_VEHICLE_RUNNING_COSTS :{GOLD}Wegvoertuigbrandstofkosten
|
||||
STR_FINANCES_SECTION_AIRCRAFT_RUNNING_COSTS :{GOLD}Vliegtuigbrandstofkosten
|
||||
STR_FINANCES_SECTION_SHIP_RUNNING_COSTS :{GOLD}Schipbrandstofkosten
|
||||
STR_FINANCES_SECTION_AIRCRAFT_RUNNING_COSTS :{GOLD}Vliegtuigonderhoudskosten
|
||||
STR_FINANCES_SECTION_SHIP_RUNNING_COSTS :{GOLD}Schiponderhoudskosten
|
||||
STR_FINANCES_SECTION_PROPERTY_MAINTENANCE :{GOLD}Eigendomsonderhoud
|
||||
STR_FINANCES_SECTION_TRAIN_INCOME :{GOLD}Treininkomsten
|
||||
STR_FINANCES_SECTION_ROAD_VEHICLE_INCOME :{GOLD}Wegvoertuiginkomsten
|
||||
STR_FINANCES_SECTION_AIRCRAFT_INCOME :{GOLD}Vliegtuiginkomsten
|
||||
STR_FINANCES_SECTION_SHIP_INCOME :{GOLD}Schipinkomsten
|
||||
STR_FINANCES_SECTION_LOAN_INTEREST :{GOLD}Rente van lening
|
||||
STR_FINANCES_SECTION_LOAN_INTEREST :{GOLD} De rente van de lening
|
||||
STR_FINANCES_SECTION_OTHER :{GOLD}Overig
|
||||
STR_FINANCES_NEGATIVE_INCOME :{BLACK}-{CURRENCY_LONG}
|
||||
STR_FINANCES_POSITIVE_INCOME :{BLACK}+{CURRENCY_LONG}
|
||||
@@ -3598,12 +3598,12 @@ STR_VEHICLE_VIEW_SHIP_REFIT_TOOLTIP :{BLACK}Bouw sch
|
||||
STR_VEHICLE_VIEW_AIRCRAFT_REFIT_TOOLTIP :{BLACK}Bouw vliegtuig om voor een ander goederentype
|
||||
|
||||
STR_VEHICLE_VIEW_TRAIN_REVERSE_TOOLTIP :{BLACK}Keer trein om
|
||||
STR_VEHICLE_VIEW_ROAD_VEHICLE_REVERSE_TOOLTIP :{BLACK}Dwing het wegvoertuig om om te draaien
|
||||
STR_VEHICLE_VIEW_ROAD_VEHICLE_REVERSE_TOOLTIP :{BLACK}Dwing het wegvoertuig te keren.
|
||||
|
||||
STR_VEHICLE_VIEW_TRAIN_ORDERS_TOOLTIP :{BLACK}Toon orders van trein. Ctrl+klik toont het tijdschema van de trein
|
||||
STR_VEHICLE_VIEW_ROAD_VEHICLE_ORDERS_TOOLTIP :{BLACK}Toon orders van wegvoertuig. Ctrl+klik toont tijdschema van het voertuig
|
||||
STR_VEHICLE_VIEW_SHIP_ORDERS_TOOLTIP :{BLACK}Toon orders van schip. Ctrl+klik toont tijdschema van het schip
|
||||
STR_VEHICLE_VIEW_AIRCRAFT_ORDERS_TOOLTIP :{BLACK}Toon orders van vliegtuig. Ctrl+klik toont het tijdschema van het vliegtuig
|
||||
STR_VEHICLE_VIEW_TRAIN_ORDERS_TOOLTIP :{BLACK}Toon orders van de trein. Ctrl+klik toont het tijdschema van de trein
|
||||
STR_VEHICLE_VIEW_ROAD_VEHICLE_ORDERS_TOOLTIP :{BLACK}Toon orders van het wegvoertuig. Ctrl+klik toont tijdschema van het voertuig
|
||||
STR_VEHICLE_VIEW_SHIP_ORDERS_TOOLTIP :{BLACK}Toon orders van het schip. Ctrl+klik toont tijdschema van het schip
|
||||
STR_VEHICLE_VIEW_AIRCRAFT_ORDERS_TOOLTIP :{BLACK}Toon orders van het vliegtuig. Ctrl+klik toont het tijdschema van het vliegtuig
|
||||
|
||||
STR_VEHICLE_VIEW_TRAIN_SHOW_DETAILS_TOOLTIP :{BLACK}Toon details van trein
|
||||
STR_VEHICLE_VIEW_ROAD_VEHICLE_SHOW_DETAILS_TOOLTIP :{BLACK}Toon details van wegvoertuig
|
||||
@@ -4153,9 +4153,9 @@ STR_ERROR_MAXIMUM_PERMITTED_LOAN :{WHITE}... maxi
|
||||
STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY :{WHITE}Kan geen geld meer lenen...
|
||||
STR_ERROR_LOAN_ALREADY_REPAYED :{WHITE}... geen lening om af te betalen
|
||||
STR_ERROR_CURRENCY_REQUIRED :{WHITE}... {CURRENCY_LONG} benodigd
|
||||
STR_ERROR_CAN_T_REPAY_LOAN :{WHITE}Kan geen lening afbetalen...
|
||||
STR_ERROR_CAN_T_REPAY_LOAN :{WHITE}Kan de lening niet afbetalen..
|
||||
STR_ERROR_INSUFFICIENT_FUNDS :{WHITE}Kan geen geld weggeven dat van de bank geleend is...
|
||||
STR_ERROR_CAN_T_BUY_COMPANY :{WHITE}Kan bedrijf niet kopen...
|
||||
STR_ERROR_CAN_T_BUY_COMPANY :{WHITE}Kan het bedrijf niet kopen...
|
||||
STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS :{WHITE}Kan bedrijfshoofdkantoor niet bouwen...
|
||||
STR_ERROR_CAN_T_BUY_25_SHARE_IN_THIS :{WHITE}Kan geen 25% aandeel in dit bedrijf kopen...
|
||||
STR_ERROR_CAN_T_SELL_25_SHARE_IN :{WHITE}Kan geen 25% aandeel in dit bedrijf verkopen...
|
||||
|
@@ -3848,7 +3848,7 @@ STR_ORDER_NO_LOAD :(Ingen lastning
|
||||
STR_ORDER_UNLOAD :(Lasta av och lasta gods)
|
||||
STR_ORDER_UNLOAD_FULL_LOAD :(Lasta av och vänta på full last)
|
||||
STR_ORDER_UNLOAD_FULL_LOAD_ANY :(Lasta av och vänta på någon full last)
|
||||
STR_ORDER_UNLOAD_NO_LOAD :(Ladda av och lämna tom)
|
||||
STR_ORDER_UNLOAD_NO_LOAD :(Lasta av och lämna tom)
|
||||
STR_ORDER_TRANSFER :(Överför och lasta gods)
|
||||
STR_ORDER_TRANSFER_FULL_LOAD :(Överför och vänta på full last)
|
||||
STR_ORDER_TRANSFER_FULL_LOAD_ANY :(Överför och vänta på full last av någon godstyp)
|
||||
|
@@ -42,9 +42,16 @@ protected:
|
||||
|
||||
public:
|
||||
/** implicit constructor */
|
||||
inline SmallArray() { }
|
||||
inline SmallArray()
|
||||
{
|
||||
}
|
||||
|
||||
/** Clear (destroy) all items */
|
||||
inline void Clear() {data.Clear();}
|
||||
inline void Clear()
|
||||
{
|
||||
data.Clear();
|
||||
}
|
||||
|
||||
/** Return actual number of items */
|
||||
inline uint Length() const
|
||||
{
|
||||
@@ -54,13 +61,29 @@ public:
|
||||
return (super_size - 1) * B + sub_size;
|
||||
}
|
||||
/** return true if array is empty */
|
||||
inline bool IsEmpty() { return data.IsEmpty(); }
|
||||
inline bool IsEmpty()
|
||||
{
|
||||
return data.IsEmpty();
|
||||
}
|
||||
|
||||
/** return true if array is full */
|
||||
inline bool IsFull() { return data.IsFull() && data[N - 1].IsFull(); }
|
||||
inline bool IsFull()
|
||||
{
|
||||
return data.IsFull() && data[N - 1].IsFull();
|
||||
}
|
||||
|
||||
/** allocate but not construct new item */
|
||||
inline T *Append() { return FirstFreeSubArray().Append(); }
|
||||
inline T *Append()
|
||||
{
|
||||
return FirstFreeSubArray().Append();
|
||||
}
|
||||
|
||||
/** allocate and construct new item */
|
||||
inline T *AppendC() { return FirstFreeSubArray().AppendC(); }
|
||||
inline T *AppendC()
|
||||
{
|
||||
return FirstFreeSubArray().AppendC();
|
||||
}
|
||||
|
||||
/** indexed access (non-const) */
|
||||
inline T& operator[](uint index)
|
||||
{
|
||||
|
@@ -157,21 +157,30 @@ public:
|
||||
*
|
||||
* @return The number of items in the queue
|
||||
*/
|
||||
inline uint Length() const { return this->items; }
|
||||
inline uint Length() const
|
||||
{
|
||||
return this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the priority queue is empty.
|
||||
*
|
||||
* @return True if empty
|
||||
*/
|
||||
inline bool IsEmpty() const { return this->items == 0; }
|
||||
inline bool IsEmpty() const
|
||||
{
|
||||
return this->items == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the priority queue is full.
|
||||
*
|
||||
* @return True if full.
|
||||
*/
|
||||
inline bool IsFull() const { return this->items >= this->capacity; }
|
||||
inline bool IsFull() const
|
||||
{
|
||||
return this->items >= this->capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the smallest item in the binary tree.
|
||||
@@ -287,7 +296,10 @@ public:
|
||||
* Make the priority queue empty.
|
||||
* All remaining items will remain untouched.
|
||||
*/
|
||||
inline void Clear() { this->items = 0; }
|
||||
inline void Clear()
|
||||
{
|
||||
this->items = 0;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* BINARYHEAP_HPP */
|
||||
|
@@ -71,7 +71,10 @@ public:
|
||||
static const size_t header_size = sizeof(BlobHeader);
|
||||
|
||||
/** default constructor - initializes empty blob */
|
||||
inline ByteBlob() { InitEmpty(); }
|
||||
inline ByteBlob()
|
||||
{
|
||||
InitEmpty();
|
||||
}
|
||||
|
||||
/** copy constructor */
|
||||
inline ByteBlob(const ByteBlob &src)
|
||||
@@ -311,9 +314,22 @@ public:
|
||||
|
||||
struct OnTransfer {
|
||||
typename base::BlobHeader *header;
|
||||
OnTransfer(const OnTransfer& src) : header(src.header) {assert(src.header != NULL); *const_cast<typename base::BlobHeader**>(&src.header) = NULL;}
|
||||
OnTransfer(CBlobT& src) : header(src.header) {src.InitEmpty();}
|
||||
~OnTransfer() {assert(header == NULL);}
|
||||
|
||||
OnTransfer(const OnTransfer& src) : header(src.header)
|
||||
{
|
||||
assert(src.header != NULL);
|
||||
*const_cast<typename base::BlobHeader**>(&src.header) = NULL;
|
||||
}
|
||||
|
||||
OnTransfer(CBlobT& src) : header(src.header)
|
||||
{
|
||||
src.InitEmpty();
|
||||
}
|
||||
|
||||
~OnTransfer()
|
||||
{
|
||||
assert(header == NULL);
|
||||
}
|
||||
};
|
||||
|
||||
/** Default constructor - makes new Blob ready to accept any data */
|
||||
|
@@ -35,48 +35,97 @@ protected:
|
||||
|
||||
public:
|
||||
/** default (NULL) construct or construct from a raw pointer */
|
||||
inline CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj) {AddRef();}
|
||||
inline CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj)
|
||||
{
|
||||
AddRef();
|
||||
}
|
||||
|
||||
/** copy constructor (invoked also when initializing from another smart ptr) */
|
||||
inline CCountedPtr(const CCountedPtr& src) : m_pT(src.m_pT) {AddRef();}
|
||||
inline CCountedPtr(const CCountedPtr &src) : m_pT(src.m_pT)
|
||||
{
|
||||
AddRef();
|
||||
}
|
||||
|
||||
/** destructor releasing the reference */
|
||||
inline ~CCountedPtr() {Release();}
|
||||
inline ~CCountedPtr()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
protected:
|
||||
/** add one ref to the underlaying object */
|
||||
inline void AddRef() {if (m_pT != NULL) m_pT->AddRef();}
|
||||
inline void AddRef()
|
||||
{
|
||||
if (m_pT != NULL) m_pT->AddRef();
|
||||
}
|
||||
|
||||
public:
|
||||
/** release smart pointer (and decrement ref count) if not null */
|
||||
inline void Release() {if (m_pT != NULL) {Tcls *pT = m_pT; m_pT = NULL; pT->Release();}}
|
||||
inline void Release()
|
||||
{
|
||||
if (m_pT != NULL) {
|
||||
Tcls *pT = m_pT;
|
||||
m_pT = NULL;
|
||||
pT->Release();
|
||||
}
|
||||
}
|
||||
|
||||
/** dereference of smart pointer - const way */
|
||||
inline const Tcls *operator -> () const {assert(m_pT != NULL); return m_pT;}
|
||||
inline const Tcls *operator->() const
|
||||
{
|
||||
assert(m_pT != NULL);
|
||||
return m_pT;
|
||||
}
|
||||
|
||||
/** dereference of smart pointer - non const way */
|
||||
inline Tcls *operator -> () {assert(m_pT != NULL); return m_pT;}
|
||||
inline Tcls *operator->()
|
||||
{
|
||||
assert(m_pT != NULL);
|
||||
return m_pT;
|
||||
}
|
||||
|
||||
/** raw pointer casting operator - const way */
|
||||
inline operator const Tcls*() const {assert(m_pT == NULL); return m_pT;}
|
||||
inline operator const Tcls*() const
|
||||
{
|
||||
assert(m_pT == NULL);
|
||||
return m_pT;
|
||||
}
|
||||
|
||||
/** raw pointer casting operator - non-const way */
|
||||
inline operator Tcls*() {return m_pT;}
|
||||
inline operator Tcls*()
|
||||
{
|
||||
return m_pT;
|
||||
}
|
||||
|
||||
/** operator & to support output arguments */
|
||||
inline Tcls** operator &() {assert(m_pT == NULL); return &m_pT;}
|
||||
inline Tcls** operator&()
|
||||
{
|
||||
assert(m_pT == NULL);
|
||||
return &m_pT;
|
||||
}
|
||||
|
||||
/** assignment operator from raw ptr */
|
||||
inline CCountedPtr& operator = (Tcls *pT) {Assign(pT); return *this;}
|
||||
inline CCountedPtr& operator=(Tcls *pT)
|
||||
{
|
||||
Assign(pT);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** assignment operator from another smart ptr */
|
||||
inline CCountedPtr& operator = (const CCountedPtr& src) {Assign(src.m_pT); return *this;}
|
||||
inline CCountedPtr& operator=(const CCountedPtr &src)
|
||||
{
|
||||
Assign(src.m_pT);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** assignment operator helper */
|
||||
inline void Assign(Tcls *pT);
|
||||
|
||||
/** one way how to test for NULL value */
|
||||
inline bool IsNull() const {return m_pT == NULL;}
|
||||
inline bool IsNull() const
|
||||
{
|
||||
return m_pT == NULL;
|
||||
}
|
||||
|
||||
/** another way how to test for NULL value */
|
||||
//inline bool operator == (const CCountedPtr &sp) const {return m_pT == sp.m_pT;}
|
||||
@@ -85,10 +134,19 @@ public:
|
||||
//inline bool operator != (const CCountedPtr &sp) const {return m_pT != sp.m_pT;}
|
||||
|
||||
/** assign pointer w/o incrementing ref count */
|
||||
inline void Attach(Tcls *pT) {Release(); m_pT = pT;}
|
||||
inline void Attach(Tcls *pT)
|
||||
{
|
||||
Release();
|
||||
m_pT = pT;
|
||||
}
|
||||
|
||||
/** detach pointer w/o decrementing ref count */
|
||||
inline Tcls *Detach() {Tcls *pT = m_pT; m_pT = NULL; return pT;}
|
||||
inline Tcls *Detach()
|
||||
{
|
||||
Tcls *pT = m_pT;
|
||||
m_pT = NULL;
|
||||
return pT;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Tcls_>
|
||||
@@ -136,7 +194,6 @@ template <class T> struct AdaptT {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Simple counted object. Use it as base of your struct/class if you want to use
|
||||
* basic reference counting. Your struct/class will destroy and free itself when
|
||||
@@ -161,7 +218,4 @@ struct SimpleCountedObject {
|
||||
virtual void FinalRelease() {};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* COUNTEDPTR_HPP */
|
||||
|
@@ -41,13 +41,28 @@ protected:
|
||||
T *data;
|
||||
|
||||
/** return reference to the array header (non-const) */
|
||||
inline ArrayHeader& Hdr() { return *(ArrayHeader*)(((byte*)data) - HeaderSize); }
|
||||
inline ArrayHeader& Hdr()
|
||||
{
|
||||
return *(ArrayHeader*)(((byte*)data) - HeaderSize);
|
||||
}
|
||||
|
||||
/** return reference to the array header (const) */
|
||||
inline const ArrayHeader& Hdr() const { return *(ArrayHeader*)(((byte*)data) - HeaderSize); }
|
||||
inline const ArrayHeader& Hdr() const
|
||||
{
|
||||
return *(ArrayHeader*)(((byte*)data) - HeaderSize);
|
||||
}
|
||||
|
||||
/** return reference to the block reference counter */
|
||||
inline uint& RefCnt() { return Hdr().reference_count; }
|
||||
inline uint& RefCnt()
|
||||
{
|
||||
return Hdr().reference_count;
|
||||
}
|
||||
|
||||
/** return reference to number of used items */
|
||||
inline uint& SizeRef() { return Hdr().items; }
|
||||
inline uint& SizeRef()
|
||||
{
|
||||
return Hdr().items;
|
||||
}
|
||||
|
||||
public:
|
||||
/** Default constructor. Preallocate space for items and header, then initialize header. */
|
||||
@@ -96,19 +111,50 @@ public:
|
||||
}
|
||||
|
||||
/** return number of used items */
|
||||
inline uint Length() const { return Hdr().items; }
|
||||
inline uint Length() const
|
||||
{
|
||||
return Hdr().items;
|
||||
}
|
||||
|
||||
/** return true if array is full */
|
||||
inline bool IsFull() const { return Length() >= C; }
|
||||
inline bool IsFull() const
|
||||
{
|
||||
return Length() >= C;
|
||||
}
|
||||
|
||||
/** return true if array is empty */
|
||||
inline bool IsEmpty() const { return Length() <= 0; }
|
||||
inline bool IsEmpty() const
|
||||
{
|
||||
return Length() <= 0;
|
||||
}
|
||||
|
||||
/** add (allocate), but don't construct item */
|
||||
inline T *Append() { assert(!IsFull()); return &data[SizeRef()++]; }
|
||||
inline T *Append()
|
||||
{
|
||||
assert(!IsFull());
|
||||
return &data[SizeRef()++];
|
||||
}
|
||||
|
||||
/** add and construct item using default constructor */
|
||||
inline T *AppendC() { T *item = Append(); new(item)T; return item; }
|
||||
inline T *AppendC()
|
||||
{
|
||||
T *item = Append();
|
||||
new(item)T;
|
||||
return item;
|
||||
}
|
||||
/** return item by index (non-const version) */
|
||||
inline T& operator [] (uint index) { assert(index < Length()); return data[index]; }
|
||||
inline T& operator[](uint index)
|
||||
{
|
||||
assert(index < Length());
|
||||
return data[index];
|
||||
}
|
||||
|
||||
/** return item by index (const version) */
|
||||
inline const T& operator [] (uint index) const { assert(index < Length()); return data[index]; }
|
||||
inline const T& operator[](uint index) const
|
||||
{
|
||||
assert(index < Length());
|
||||
return data[index];
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* FIXEDSIZEARRAY_HPP */
|
||||
|
@@ -24,7 +24,10 @@ struct CHashTableSlotT
|
||||
inline CHashTableSlotT() : m_pFirst(NULL) {}
|
||||
|
||||
/** hash table slot helper - clears the slot by simple forgetting its items */
|
||||
inline void Clear() {m_pFirst = NULL;}
|
||||
inline void Clear()
|
||||
{
|
||||
m_pFirst = NULL;
|
||||
}
|
||||
|
||||
/** hash table slot helper - linear search for item with given key through the given blob - const version */
|
||||
inline const Titem_ *Find(const Key &key) const
|
||||
@@ -168,14 +171,23 @@ protected:
|
||||
}
|
||||
|
||||
/** static helper - return hash for the given item modulo number of slots */
|
||||
inline static int CalcHash(const Titem_& item) {return CalcHash(item.GetKey());}
|
||||
inline static int CalcHash(const Titem_ &item)
|
||||
{
|
||||
return CalcHash(item.GetKey());
|
||||
}
|
||||
|
||||
public:
|
||||
/** item count */
|
||||
inline int Count() const {return m_num_items;}
|
||||
inline int Count() const
|
||||
{
|
||||
return m_num_items;
|
||||
}
|
||||
|
||||
/** simple clear - forget all items - used by CSegmentCostCacheT.Flush() */
|
||||
inline void Clear() {for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();}
|
||||
inline void Clear()
|
||||
{
|
||||
for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();
|
||||
}
|
||||
|
||||
/** const item search */
|
||||
const Titem_ *Find(const Tkey &key) const
|
||||
|
@@ -24,34 +24,23 @@
|
||||
template <class Titem_, int Thash_bits_open_, int Thash_bits_closed_>
|
||||
class CNodeList_HashTableT {
|
||||
public:
|
||||
/** make Titem_ visible from outside of class */
|
||||
typedef Titem_ Titem;
|
||||
/** make Titem_::Key a property of HashTable */
|
||||
typedef typename Titem_::Key Key;
|
||||
/** type that we will use as item container */
|
||||
typedef SmallArray<Titem_, 65536, 256> CItemArray;
|
||||
/** how pointers to open nodes will be stored */
|
||||
typedef CHashTableT<Titem_, Thash_bits_open_ > COpenList;
|
||||
/** how pointers to closed nodes will be stored */
|
||||
typedef CHashTableT<Titem_, Thash_bits_closed_> CClosedList;
|
||||
/** how the priority queue will be managed */
|
||||
typedef CBinaryHeapT<Titem_> CPriorityQueue;
|
||||
typedef Titem_ Titem; ///< Make #Titem_ visible from outside of class.
|
||||
typedef typename Titem_::Key Key; ///< Make Titem_::Key a property of #HashTable.
|
||||
typedef SmallArray<Titem_, 65536, 256> CItemArray; ///< Type that we will use as item container.
|
||||
typedef CHashTableT<Titem_, Thash_bits_open_ > COpenList; ///< How pointers to open nodes will be stored.
|
||||
typedef CHashTableT<Titem_, Thash_bits_closed_> CClosedList; ///< How pointers to closed nodes will be stored.
|
||||
typedef CBinaryHeapT<Titem_> CPriorityQueue; ///< How the priority queue will be managed.
|
||||
|
||||
protected:
|
||||
/** here we store full item data (Titem_) */
|
||||
CItemArray m_arr;
|
||||
/** hash table of pointers to open item data */
|
||||
COpenList m_open;
|
||||
/** hash table of pointers to closed item data */
|
||||
CClosedList m_closed;
|
||||
/** priority queue of pointers to open item data */
|
||||
CPriorityQueue m_open_queue;
|
||||
/** new open node under construction */
|
||||
Titem *m_new_node;
|
||||
CItemArray m_arr; ///< Here we store full item data (Titem_).
|
||||
COpenList m_open; ///< Hash table of pointers to open item data.
|
||||
CClosedList m_closed; ///< Hash table of pointers to closed item data.
|
||||
CPriorityQueue m_open_queue; ///< Priority queue of pointers to open item data.
|
||||
Titem *m_new_node; ///< New open node under construction.
|
||||
|
||||
public:
|
||||
/** default constructor */
|
||||
CNodeList_HashTableT()
|
||||
: m_open_queue(2048)
|
||||
CNodeList_HashTableT() : m_open_queue(2048)
|
||||
{
|
||||
m_new_node = NULL;
|
||||
}
|
||||
@@ -152,9 +141,16 @@ public:
|
||||
}
|
||||
|
||||
/** The number of items. */
|
||||
inline int TotalCount() {return m_arr.Length();}
|
||||
inline int TotalCount()
|
||||
{
|
||||
return m_arr.Length();
|
||||
}
|
||||
|
||||
/** Get a particular item. */
|
||||
inline Titem_& ItemAt(int idx) {return m_arr[idx];}
|
||||
inline Titem_& ItemAt(int idx)
|
||||
{
|
||||
return m_arr[idx];
|
||||
}
|
||||
|
||||
/** Helper for creating output of this array. */
|
||||
template <class D> void Dump(D &dmp) const
|
||||
|
@@ -121,9 +121,7 @@ struct CSegmentCostCacheBase
|
||||
* Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example
|
||||
*/
|
||||
template <class Tsegment>
|
||||
struct CSegmentCostCacheT
|
||||
: public CSegmentCostCacheBase
|
||||
{
|
||||
struct CSegmentCostCacheT : public CSegmentCostCacheBase {
|
||||
static const int C_HASH_BITS = 14;
|
||||
|
||||
typedef CHashTableT<Tsegment, C_HASH_BITS> HashTable;
|
||||
@@ -162,9 +160,7 @@ struct CSegmentCostCacheT
|
||||
* segment cost caching services for your Nodes.
|
||||
*/
|
||||
template <class Types>
|
||||
class CYapfSegmentCostCacheGlobalT
|
||||
: public CYapfSegmentCostCacheLocalT<Types>
|
||||
{
|
||||
class CYapfSegmentCostCacheGlobalT : public CYapfSegmentCostCacheLocalT<Types> {
|
||||
public:
|
||||
typedef CYapfSegmentCostCacheLocalT<Types> Tlocal;
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
|
@@ -15,9 +15,7 @@
|
||||
#include "../../pbs.h"
|
||||
|
||||
template <class Types>
|
||||
class CYapfCostRailT
|
||||
: public CYapfCostBase
|
||||
{
|
||||
class CYapfCostRailT : public CYapfCostBase {
|
||||
public:
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
typedef typename Types::TrackFollower TrackFollower;
|
||||
@@ -74,10 +72,7 @@ protected:
|
||||
|
||||
static const int s_max_segment_cost = 10000;
|
||||
|
||||
CYapfCostRailT()
|
||||
: m_max_cost(0)
|
||||
, m_disable_cache(false)
|
||||
, m_stopped_on_first_two_way_signal(false)
|
||||
CYapfCostRailT() : m_max_cost(0), m_disable_cache(false), m_stopped_on_first_two_way_signal(false)
|
||||
{
|
||||
/* pre-compute look-ahead penalties into array */
|
||||
int p0 = Yapf().PfGetSettings().rail_look_ahead_signal_p0;
|
||||
|
@@ -12,8 +12,7 @@
|
||||
#ifndef YAPF_DESTRAIL_HPP
|
||||
#define YAPF_DESTRAIL_HPP
|
||||
|
||||
class CYapfDestinationRailBase
|
||||
{
|
||||
class CYapfDestinationRailBase {
|
||||
protected:
|
||||
RailTypes m_compatible_railtypes;
|
||||
|
||||
@@ -36,9 +35,7 @@ public:
|
||||
};
|
||||
|
||||
template <class Types>
|
||||
class CYapfDestinationAnyDepotRailT
|
||||
: public CYapfDestinationRailBase
|
||||
{
|
||||
class CYapfDestinationAnyDepotRailT : public CYapfDestinationRailBase {
|
||||
public:
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
typedef typename Types::NodeList::Titem Node; ///< this will be our node type
|
||||
@@ -75,9 +72,7 @@ public:
|
||||
};
|
||||
|
||||
template <class Types>
|
||||
class CYapfDestinationAnySafeTileRailT
|
||||
: public CYapfDestinationRailBase
|
||||
{
|
||||
class CYapfDestinationAnySafeTileRailT : public CYapfDestinationRailBase {
|
||||
public:
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
typedef typename Types::NodeList::Titem Node; ///< this will be our node type
|
||||
@@ -115,9 +110,7 @@ public:
|
||||
};
|
||||
|
||||
template <class Types>
|
||||
class CYapfDestinationTileOrStationRailT
|
||||
: public CYapfDestinationRailBase
|
||||
{
|
||||
class CYapfDestinationTileOrStationRailT : public CYapfDestinationRailBase {
|
||||
public:
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
typedef typename Types::NodeList::Titem Node; ///< this will be our node type
|
||||
|
@@ -25,8 +25,15 @@ struct CYapfNodeKeyExitDir {
|
||||
m_exitdir = (m_td == INVALID_TRACKDIR) ? INVALID_DIAGDIR : TrackdirToExitdir(m_td);
|
||||
}
|
||||
|
||||
inline int CalcHash() const {return m_exitdir | (m_tile << 2);}
|
||||
inline bool operator == (const CYapfNodeKeyExitDir& other) const {return (m_tile == other.m_tile) && (m_exitdir == other.m_exitdir);}
|
||||
inline int CalcHash() const
|
||||
{
|
||||
return m_exitdir | (m_tile << 2);
|
||||
}
|
||||
|
||||
inline bool operator==(const CYapfNodeKeyExitDir &other) const
|
||||
{
|
||||
return m_tile == other.m_tile && m_exitdir == other.m_exitdir;
|
||||
}
|
||||
|
||||
void Dump(DumpTarget &dmp) const
|
||||
{
|
||||
@@ -38,8 +45,15 @@ struct CYapfNodeKeyExitDir {
|
||||
|
||||
struct CYapfNodeKeyTrackDir : public CYapfNodeKeyExitDir
|
||||
{
|
||||
inline int CalcHash() const {return m_td | (m_tile << 4);}
|
||||
inline bool operator == (const CYapfNodeKeyTrackDir& other) const {return (m_tile == other.m_tile) && (m_td == other.m_td);}
|
||||
inline int CalcHash() const
|
||||
{
|
||||
return m_td | (m_tile << 4);
|
||||
}
|
||||
|
||||
inline bool operator==(const CYapfNodeKeyTrackDir &other) const
|
||||
{
|
||||
return m_tile == other.m_tile && m_td == other.m_td;
|
||||
}
|
||||
};
|
||||
|
||||
/** Yapf Node base */
|
||||
@@ -63,14 +77,45 @@ struct CYapfNodeT {
|
||||
m_estimate = 0;
|
||||
}
|
||||
|
||||
inline Node *GetHashNext() {return m_hash_next;}
|
||||
inline void SetHashNext(Node *pNext) {m_hash_next = pNext;}
|
||||
inline TileIndex GetTile() const {return m_key.m_tile;}
|
||||
inline Trackdir GetTrackdir() const {return m_key.m_td;}
|
||||
inline const Tkey_& GetKey() const {return m_key;}
|
||||
inline int GetCost() const {return m_cost;}
|
||||
inline int GetCostEstimate() const {return m_estimate;}
|
||||
inline bool operator < (const Node& other) const {return m_estimate < other.m_estimate;}
|
||||
inline Node *GetHashNext()
|
||||
{
|
||||
return m_hash_next;
|
||||
}
|
||||
|
||||
inline void SetHashNext(Node *pNext)
|
||||
{
|
||||
m_hash_next = pNext;
|
||||
}
|
||||
|
||||
inline TileIndex GetTile() const
|
||||
{
|
||||
return m_key.m_tile;
|
||||
}
|
||||
|
||||
inline Trackdir GetTrackdir() const
|
||||
{
|
||||
return m_key.m_td;
|
||||
}
|
||||
|
||||
inline const Tkey_& GetKey() const
|
||||
{
|
||||
return m_key;
|
||||
}
|
||||
|
||||
inline int GetCost() const
|
||||
{
|
||||
return m_cost;
|
||||
}
|
||||
|
||||
inline int GetCostEstimate() const
|
||||
{
|
||||
return m_estimate;
|
||||
}
|
||||
|
||||
inline bool operator<(const Node &other) const
|
||||
{
|
||||
return m_estimate < other.m_estimate;
|
||||
}
|
||||
|
||||
void Dump(DumpTarget &dmp) const
|
||||
{
|
||||
|
@@ -14,9 +14,7 @@
|
||||
|
||||
/** Yapf Node for road YAPF */
|
||||
template <class Tkey_>
|
||||
struct CYapfRoadNodeT
|
||||
: CYapfNodeT<Tkey_, CYapfRoadNodeT<Tkey_> >
|
||||
{
|
||||
struct CYapfRoadNodeT : CYapfNodeT<Tkey_, CYapfRoadNodeT<Tkey_> > {
|
||||
typedef CYapfNodeT<Tkey_, CYapfRoadNodeT<Tkey_> > base;
|
||||
|
||||
TileIndex m_segment_last_tile;
|
||||
|
@@ -14,11 +14,7 @@
|
||||
|
||||
/** Yapf Node for ships */
|
||||
template <class Tkey_>
|
||||
struct CYapfShipNodeT
|
||||
: CYapfNodeT<Tkey_, CYapfShipNodeT<Tkey_> >
|
||||
{
|
||||
|
||||
};
|
||||
struct CYapfShipNodeT : CYapfNodeT<Tkey_, CYapfShipNodeT<Tkey_> > { };
|
||||
|
||||
/* now define two major node types (that differ by key type) */
|
||||
typedef CYapfShipNodeT<CYapfNodeKeyExitDir> CYapfShipNodeExitDir;
|
||||
@@ -28,5 +24,4 @@ typedef CYapfShipNodeT<CYapfNodeKeyTrackDir> CYapfShipNodeTrackDir;
|
||||
typedef CNodeList_HashTableT<CYapfShipNodeExitDir , 10, 12> CShipNodeListExitDir;
|
||||
typedef CNodeList_HashTableT<CYapfShipNodeTrackDir, 10, 12> CShipNodeListTrackDir;
|
||||
|
||||
|
||||
#endif /* YAPF_NODE_SHIP_HPP */
|
||||
|
Reference in New Issue
Block a user