39 n += c->group_all[v].num_vehicle;
44 if (n == 0)
return nullptr;
47 n = InteractiveRandomRange(n);
55 if (!v->IsPrimaryVehicle())
continue;
58 if (n-- == 0)
return v;
84 static int movement_bias = 48;
87 if (exit_on_invalid && main_win->
viewport->follow_vehicle == VehicleID::Invalid()) {
98 if (v->cur_speed > 0 && !
Chance16I(1, movement_bias, InteractiveRandom())) {
105 if (v->cur_speed == 0 &&
Chance16I(3, 4, InteractiveRandom())) {
116 if (new_vehicle ==
nullptr)
return;
119 main_win->
viewport->CancelFollow(*main_win);
120 main_win->
viewport->follow_vehicle = new_vehicle->index;
155 main_win->
viewport->CancelFollow(*main_win);
181 _switch_timer = std::make_unique<IntervalTimer<TimerGameTick>>(
@ None
These timers can be executed in any order; the order is not relevant.
Definition of stuff that is very close to a company, like the company struct itself.
Pseudo random number generator.
bool Chance16I(const uint32_t a, const uint32_t b, const uint32_t r)
Checks if a given randomize-number is below a given probability.
A number of safeguards to prevent using unsafe methods.
static const auto _screensaver_check_interval
We use a fixed period for updating the screensaver's followed vehicle, stored in this variable.
static const Vehicle * PickRandomVehicle()
Selects a random vehicle of any type.
static void SwitchVehicle(bool exit_on_invalid=true)
Switches the current followed vehicle to a new random one.
void ToggleScreensaverMode()
Enters or exits "Screensaver Mode".
void ExitScreensaverMode()
Exits "Screensaver Mode".
static std::unique_ptr< IntervalTimer< TimerGameTick > > _switch_timer
The screensaver runs on an interval timer, stored in this pointer when it is running and freed when i...
Exports a function to turn on and off a screensaver mode.
Definition of base types and functions in a cross-platform compatible way.
static Pool::IterateWrapper< Company > Iterate(size_t from=0)
static Vehicle * GetIfValid(auto index)
Data structure for an opened window.
std::unique_ptr< ViewportData > viewport
Pointer to viewport data, if present.
Definition of Interval and OneShot timers.
Definition of the tick-based game-timer.
Base class for all vehicles.
Functions related to vehicles.
bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
Types related to vehicles.
VehicleType
Available vehicle types.
@ CompanyEnd
Last company-ownable type.
Window * GetMainWindow()
Get the main window, i.e.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.