Codechange: change Source into a class with conversion helpers
A Source is either a CompanyID (Headquarters), IndustryID or TownID. When making those types stronger a lot of casts would be needed, but with these simple helpers the intent is shown more clearly.
This commit is contained in:
@@ -118,17 +118,17 @@ void AddCargoDelivery(CargoType cargo_type, CompanyID company, uint32_t amount,
|
||||
{
|
||||
if (amount == 0) return;
|
||||
|
||||
if (src.id != INVALID_SOURCE) {
|
||||
if (src.IsValid()) {
|
||||
/* Handle pickup update. */
|
||||
switch (src.type) {
|
||||
case SourceType::Industry: {
|
||||
CargoMonitorID num = EncodeCargoIndustryMonitor(company, cargo_type, src.id);
|
||||
CargoMonitorID num = EncodeCargoIndustryMonitor(company, cargo_type, src.ToIndustryID());
|
||||
CargoMonitorMap::iterator iter = _cargo_pickups.find(num);
|
||||
if (iter != _cargo_pickups.end()) iter->second += amount;
|
||||
break;
|
||||
}
|
||||
case SourceType::Town: {
|
||||
CargoMonitorID num = EncodeCargoTownMonitor(company, cargo_type, src.id);
|
||||
CargoMonitorID num = EncodeCargoTownMonitor(company, cargo_type, src.ToTownID());
|
||||
CargoMonitorMap::iterator iter = _cargo_pickups.find(num);
|
||||
if (iter != _cargo_pickups.end()) iter->second += amount;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user