OpenTTD Source 20260206-master-g4d4e37dbf1
DemandCalculator Class Reference

Calculate the demands. More...

#include <demands.h>

Public Member Functions

 DemandCalculator (LinkGraphJob &job)
 Create the DemandCalculator and immediately do the calculation.

Private Member Functions

template<class Tscaler>
void CalcDemand (LinkGraphJob &job, Tscaler scaler)
 Do the actual demand calculation, called from constructor.

Private Attributes

int32_t base_distance
 Base distance for scaling purposes.
int32_t mod_dist
 Distance modifier, determines how much demands decrease with distance.
int32_t accuracy
 Accuracy of the calculation.

Detailed Description

Calculate the demands.

This class has a state, but is recreated for each call to of DemandHandler::Run.

Definition at line 19 of file demands.h.

Constructor & Destructor Documentation

◆ DemandCalculator()

DemandCalculator::DemandCalculator ( LinkGraphJob & job)

Create the DemandCalculator and immediately do the calculation.

Parameters
jobJob to calculate the demands for.

Definition at line 266 of file demands.cpp.

References accuracy, base_distance, LinkGraphJob::Cargo(), DistanceMaxPlusManhattan(), IntSqrt(), mod_dist, LinkGraphJob::Settings(), settings, and TileXY().

Member Function Documentation

◆ CalcDemand()

template<class Tscaler>
void DemandCalculator::CalcDemand ( LinkGraphJob & job,
Tscaler scaler )
private

Do the actual demand calculation, called from constructor.

Parameters
jobJob to calculate the demands for.
scalerScaler to be used for scaling demands.

Definition at line 169 of file demands.cpp.

References accuracy, base_distance, DistanceMaxPlusManhattan(), mod_dist, and LinkGraphJob::Size().

Field Documentation

◆ accuracy

int32_t DemandCalculator::accuracy
private

Accuracy of the calculation.

Definition at line 26 of file demands.h.

Referenced by CalcDemand(), and DemandCalculator().

◆ base_distance

int32_t DemandCalculator::base_distance
private

Base distance for scaling purposes.

Definition at line 24 of file demands.h.

Referenced by CalcDemand(), and DemandCalculator().

◆ mod_dist

int32_t DemandCalculator::mod_dist
private

Distance modifier, determines how much demands decrease with distance.

Definition at line 25 of file demands.h.

Referenced by CalcDemand(), and DemandCalculator().


The documentation for this class was generated from the following files: