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

Method GetGroupProfitSpriteID

src/group_gui.cpp:322–331  ·  view source on GitHub ↗

* Get the profit sprite ID to draw for the given group. * @param g_id Group to get profit sprite ID for. * @return SpriteID to draw. */

Source from the content-addressed store, hash-verified

320 * @return SpriteID to draw.
321 */
322 SpriteID GetGroupProfitSpriteID(GroupID g_id) const
323 {
324 uint num_vehicle_min_age = GetGroupNumVehicleMinAge(this->vli.company, g_id, this->vli.vtype);
325 if (num_vehicle_min_age == 0) return SPR_PROFIT_NA;
326
327 Money profit_last_year_min_age = GetGroupProfitLastYearMinAge(this->vli.company, g_id, this->vli.vtype);
328 if (profit_last_year_min_age < 0) return SPR_PROFIT_NEGATIVE;
329 if (profit_last_year_min_age < VEHICLE_PROFIT_THRESHOLD * num_vehicle_min_age) return SPR_PROFIT_SOME;
330 return SPR_PROFIT_LOT;
331 }
332
333 /**
334 * Draw a row in the group list.

Callers 1

DrawGroupInfoMethod · 0.95

Calls 2

GetGroupNumVehicleMinAgeFunction · 0.85

Tested by

no test coverage detected