MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetTrainEngineInfoString

Function GetTrainEngineInfoString

src/engine_gui.cpp:178–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178static std::string GetTrainEngineInfoString(const Engine &e)
179{
180 std::stringstream res;
181
182 res << GetString(STR_ENGINE_PREVIEW_COST_WEIGHT, e.GetCost(), e.GetDisplayWeight());
183 res << '\n';
184
185 if (e.VehInfo<RailVehicleInfo>().railtypes.Count() > 1) {
186 std::string railtypes{};
187 std::string_view list_separator = GetListSeparator();
188
189 for (const auto &rt : _sorted_railtypes) {
190 if (!e.VehInfo<RailVehicleInfo>().railtypes.Test(rt)) continue;
191
192 if (!railtypes.empty()) railtypes += list_separator;
193 AppendStringInPlace(railtypes, GetRailTypeInfo(rt)->strings.name);
194 }
195 res << GetString(STR_ENGINE_PREVIEW_RAILTYPES, railtypes);
196 res << '\n';
197 }
198
199 bool is_maglev = true;
200 for (RailType rt : e.VehInfo<RailVehicleInfo>().railtypes) {
201 is_maglev &= GetRailTypeInfo(rt)->acceleration_type == VehicleAccelerationModel::Maglev;
202 }
203
204 if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL && !is_maglev) {
205 res << GetString(STR_ENGINE_PREVIEW_SPEED_POWER_MAX_TE, PackVelocity(e.GetDisplayMaxSpeed(), e.type), e.GetPower(), e.GetDisplayMaxTractiveEffort());
206 res << '\n';
207 } else {
208 res << GetString(STR_ENGINE_PREVIEW_SPEED_POWER, PackVelocity(e.GetDisplayMaxSpeed(), e.type), e.GetPower());
209 res << '\n';
210 }
211
212 res << GetPreviewRunningCostString(e);
213 res << '\n';
214
215 uint capacity = GetTotalCapacityOfArticulatedParts(e.index);
216 res << GetString(STR_ENGINE_PREVIEW_CAPACITY, capacity == 0 ? INVALID_CARGO : e.GetDefaultCargoType(), capacity);
217
218 return res.str();
219}
220
221static std::string GetAircraftEngineInfoString(const Engine &e)
222{

Callers 1

GetEngineInfoStringFunction · 0.85

Calls 15

GetListSeparatorFunction · 0.85
AppendStringInPlaceFunction · 0.85
GetRailTypeInfoFunction · 0.85
PackVelocityFunction · 0.85
GetDisplayWeightMethod · 0.80
TestMethod · 0.80
GetDefaultCargoTypeMethod · 0.80
GetStringFunction · 0.70
GetCostMethod · 0.45

Tested by

no test coverage detected