411 } |
411 } |
412 |
412 |
413 static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac) |
413 static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac) |
414 { |
414 { |
415 HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
415 HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
416 |
416 CargoID accepts[3]; |
417 for (uint8 i = 0; i < 3; i++) ac[hs->accepts_cargo[i]] = hs->cargo_acceptance[i]; |
417 |
|
418 /* Set the initial accepted cargo types */ |
|
419 for (uint8 i = 0; i < lengthof(accepts); i++) { |
|
420 accepts[i] = hs->accepts_cargo[i]; |
|
421 } |
|
422 |
|
423 /* Check for custom accepted cargo types */ |
|
424 if (HASBIT(hs->callback_mask, CBM_HOUSE_ACCEPT_CARGO)) { |
|
425 uint16 callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
|
426 if (callback != CALLBACK_FAILED) { |
|
427 /* Replace accepted cargo types with translated values from callback */ |
|
428 accepts[0] = GetCargoTranslation(GB(callback, 0, 5), hs->grffile); |
|
429 accepts[1] = GetCargoTranslation(GB(callback, 5, 5), hs->grffile); |
|
430 accepts[2] = GetCargoTranslation(GB(callback, 10, 5), hs->grffile); |
|
431 } |
|
432 } |
|
433 |
|
434 /* Check for custom cargo acceptance */ |
|
435 if (HASBIT(hs->callback_mask, CBM_CARGO_ACCEPTANCE)) { |
|
436 uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
|
437 if (callback != CALLBACK_FAILED) { |
|
438 if (accepts[0] != CT_INVALID) ac[accepts[0]] = GB(callback, 0, 4); |
|
439 if (accepts[1] != CT_INVALID) ac[accepts[1]] = GB(callback, 4, 4); |
|
440 if (_opt.landscape != LT_TEMPERATE && HASBIT(callback, 12)) { |
|
441 /* The 'S' bit indicates food instead of goods */ |
|
442 ac[CT_FOOD] = GB(callback, 8, 4); |
|
443 } else { |
|
444 if (accepts[2] != CT_INVALID) ac[accepts[2]] = GB(callback, 8, 4); |
|
445 } |
|
446 return; |
|
447 } |
|
448 } |
|
449 |
|
450 /* No custom acceptance, so fill in with the default values */ |
|
451 for (uint8 i = 0; i < lengthof(accepts); i++) { |
|
452 if (accepts[i] != CT_INVALID) ac[accepts[i]] = hs->cargo_acceptance[i]; |
|
453 } |
418 } |
454 } |
419 |
455 |
420 static void GetTileDesc_Town(TileIndex tile, TileDesc *td) |
456 static void GetTileDesc_Town(TileIndex tile, TileDesc *td) |
421 { |
457 { |
422 td->str = GetHouseSpecs(GetHouseType(tile))->building_name; |
458 td->str = GetHouseSpecs(GetHouseType(tile))->building_name; |