mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r9876) -Codechange: [NewHouses] Add support for callback 2E (cargo production)
This commit is contained in:
parent
60a2c5280e
commit
47d17bea9d
|
@ -4213,7 +4213,7 @@ static void InitializeGRFSpecial()
|
||||||
| (0 << 0x04) // aichoosechance
|
| (0 << 0x04) // aichoosechance
|
||||||
| (1 << 0x05) // resolutionwidth
|
| (1 << 0x05) // resolutionwidth
|
||||||
| (1 << 0x06) // resolutionheight
|
| (1 << 0x06) // resolutionheight
|
||||||
| (0 << 0x07) // newindustries
|
| (1 << 0x07) // newindustries
|
||||||
| ((_patches.improved_load ? 1 : 0) << 0x08) // fifoloading
|
| ((_patches.improved_load ? 1 : 0) << 0x08) // fifoloading
|
||||||
| (0 << 0x09) // townroadbranchprob
|
| (0 << 0x09) // townroadbranchprob
|
||||||
| (0 << 0x0A) // tempsnowline
|
| (0 << 0x0A) // tempsnowline
|
||||||
|
|
|
@ -400,24 +400,55 @@ static void TileLoop_Town(TileIndex tile)
|
||||||
|
|
||||||
r = Random();
|
r = Random();
|
||||||
|
|
||||||
if (GB(r, 0, 8) < hs->population) {
|
if (HASBIT(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) {
|
||||||
uint amt = GB(r, 0, 8) / 8 + 1;
|
for (uint i = 0; i < 256; i++) {
|
||||||
uint moved;
|
uint16 callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, r, house_id, t, tile);
|
||||||
|
|
||||||
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
if (callback == CALLBACK_FAILED) break;
|
||||||
t->new_max_pass += amt;
|
if (callback == 0x20FF) break;
|
||||||
moved = MoveGoodsToStation(tile, 1, 1, CT_PASSENGERS, amt);
|
|
||||||
t->new_act_pass += moved;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GB(r, 8, 8) < hs->mail_generation) {
|
CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile);
|
||||||
uint amt = GB(r, 8, 8) / 8 + 1;
|
if (cargo == CT_INVALID) continue;
|
||||||
uint moved;
|
|
||||||
|
|
||||||
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
uint amt = GB(callback, 0, 8);
|
||||||
t->new_max_mail += amt;
|
uint moved = MoveGoodsToStation(tile, 1, 1, cargo, amt);
|
||||||
moved = MoveGoodsToStation(tile, 1, 1, CT_MAIL, amt);
|
|
||||||
t->new_act_mail += moved;
|
const CargoSpec *cs = GetCargo(cargo);
|
||||||
|
switch (cs->town_effect) {
|
||||||
|
case TE_PASSENGERS:
|
||||||
|
t->new_max_pass += amt;
|
||||||
|
t->new_act_pass += moved;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TE_MAIL:
|
||||||
|
t->new_max_mail += amt;
|
||||||
|
t->new_act_mail += moved;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (GB(r, 0, 8) < hs->population) {
|
||||||
|
uint amt = GB(r, 0, 8) / 8 + 1;
|
||||||
|
uint moved;
|
||||||
|
|
||||||
|
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
||||||
|
t->new_max_pass += amt;
|
||||||
|
moved = MoveGoodsToStation(tile, 1, 1, CT_PASSENGERS, amt);
|
||||||
|
t->new_act_pass += moved;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GB(r, 8, 8) < hs->mail_generation) {
|
||||||
|
uint amt = GB(r, 8, 8) / 8 + 1;
|
||||||
|
uint moved;
|
||||||
|
|
||||||
|
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
||||||
|
t->new_max_mail += amt;
|
||||||
|
moved = MoveGoodsToStation(tile, 1, 1, CT_MAIL, amt);
|
||||||
|
t->new_act_mail += moved;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_current_player = OWNER_TOWN;
|
_current_player = OWNER_TOWN;
|
||||||
|
|
Loading…
Reference in New Issue