mirror of https://github.com/OpenTTD/OpenTTD
(svn r20401) -Codechange: let HouseSpec use GRFFileProps
parent
b6a0806948
commit
6d6939f844
11
src/house.h
11
src/house.h
|
@ -17,6 +17,7 @@
|
||||||
#include "economy_type.h"
|
#include "economy_type.h"
|
||||||
#include "date_type.h"
|
#include "date_type.h"
|
||||||
#include "house_type.h"
|
#include "house_type.h"
|
||||||
|
#include "newgrf_commons.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple value that indicates the house has reached the final stage of
|
* Simple value that indicates the house has reached the final stage of
|
||||||
|
@ -108,9 +109,7 @@ struct HouseSpec {
|
||||||
bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf)
|
bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf)
|
||||||
|
|
||||||
/* NewHouses properties */
|
/* NewHouses properties */
|
||||||
HouseID substitute_id; ///< which original house this one is based on
|
GRFFileProps grf_prop; ///< Properties related the the grf file
|
||||||
struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the house
|
|
||||||
HouseID override; ///< which house this one replaces
|
|
||||||
uint16 callback_mask; ///< Bitmask of house callbacks that have to be called
|
uint16 callback_mask; ///< Bitmask of house callbacks that have to be called
|
||||||
byte random_colour[4]; ///< 4 "random" colours
|
byte random_colour[4]; ///< 4 "random" colours
|
||||||
byte probability; ///< Relative probability of appearing (16 is the standard value)
|
byte probability; ///< Relative probability of appearing (16 is the standard value)
|
||||||
|
@ -121,10 +120,6 @@ struct HouseSpec {
|
||||||
byte processing_time; ///< Periodic refresh multiplier
|
byte processing_time; ///< Periodic refresh multiplier
|
||||||
byte minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it
|
byte minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it
|
||||||
|
|
||||||
/* grf file related properties*/
|
|
||||||
uint8 local_id; ///< id defined by the grf file for this house
|
|
||||||
const struct GRFFile *grffile; ///< grf file that introduced this house
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cost for removing this house
|
* Get the cost for removing this house
|
||||||
* @return the cost (inflation corrected etc)
|
* @return the cost (inflation corrected etc)
|
||||||
|
@ -147,7 +142,7 @@ struct HouseSpec {
|
||||||
static inline HouseID GetTranslatedHouseID(HouseID hid)
|
static inline HouseID GetTranslatedHouseID(HouseID hid)
|
||||||
{
|
{
|
||||||
const HouseSpec *hs = HouseSpec::Get(hid);
|
const HouseSpec *hs = HouseSpec::Get(hid);
|
||||||
return hs->override == INVALID_HOUSE_ID ? hid : hs->override;
|
return hs->grf_prop.override == INVALID_HOUSE_ID ? hid : hs->grf_prop.override;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HOUSE_H */
|
#endif /* HOUSE_H */
|
||||||
|
|
|
@ -1581,9 +1581,9 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt
|
||||||
MemCpyT(housespec, HouseSpec::Get(subs_id));
|
MemCpyT(housespec, HouseSpec::Get(subs_id));
|
||||||
|
|
||||||
housespec->enabled = true;
|
housespec->enabled = true;
|
||||||
housespec->local_id = hid + i;
|
housespec->grf_prop.local_id = hid + i;
|
||||||
housespec->substitute_id = subs_id;
|
housespec->grf_prop.subst_id = subs_id;
|
||||||
housespec->grffile = _cur_grffile;
|
housespec->grf_prop.grffile = _cur_grffile;
|
||||||
housespec->random_colour[0] = 0x04; // those 4 random colours are the base colour
|
housespec->random_colour[0] = 0x04; // those 4 random colours are the base colour
|
||||||
housespec->random_colour[1] = 0x08; // for all new houses
|
housespec->random_colour[1] = 0x08; // for all new houses
|
||||||
housespec->random_colour[2] = 0x0C; // they stand for red, blue, orange and green
|
housespec->random_colour[2] = 0x0C; // they stand for red, blue, orange and green
|
||||||
|
@ -3920,7 +3920,7 @@ static void TownHouseMapSpriteGroup(ByteReader *buf, uint8 idcount)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
hs->spritegroup = _cur_grffile->spritegroups[groupid];
|
hs->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7043,7 +7043,7 @@ static void FinaliseHouseArray()
|
||||||
(next2 == NULL || !next2->enabled || (next2->building_flags & BUILDING_HAS_1_TILE) != 0 ||
|
(next2 == NULL || !next2->enabled || (next2->building_flags & BUILDING_HAS_1_TILE) != 0 ||
|
||||||
next3 == NULL || !next3->enabled || (next3->building_flags & BUILDING_HAS_1_TILE) != 0))) {
|
next3 == NULL || !next3->enabled || (next3->building_flags & BUILDING_HAS_1_TILE) != 0))) {
|
||||||
hs->enabled = false;
|
hs->enabled = false;
|
||||||
DEBUG(grf, 1, "FinaliseHouseArray: %s defines house %d as multitile, but no suitable tiles follow. Disabling house.", (*file)->filename, hs->local_id);
|
DEBUG(grf, 1, "FinaliseHouseArray: %s defines house %d as multitile, but no suitable tiles follow. Disabling house.", (*file)->filename, hs->grf_prop.local_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7053,7 +7053,7 @@ static void FinaliseHouseArray()
|
||||||
if (((hs->building_flags & BUILDING_HAS_2_TILES) != 0 && next1->population != 0) ||
|
if (((hs->building_flags & BUILDING_HAS_2_TILES) != 0 && next1->population != 0) ||
|
||||||
((hs->building_flags & BUILDING_HAS_4_TILES) != 0 && (next2->population != 0 || next3->population != 0))) {
|
((hs->building_flags & BUILDING_HAS_4_TILES) != 0 && (next2->population != 0 || next3->population != 0))) {
|
||||||
hs->enabled = false;
|
hs->enabled = false;
|
||||||
DEBUG(grf, 1, "FinaliseHouseArray: %s defines multitile house %d with non-zero population on additional tiles. Disabling house.", (*file)->filename, hs->local_id);
|
DEBUG(grf, 1, "FinaliseHouseArray: %s defines multitile house %d with non-zero population on additional tiles. Disabling house.", (*file)->filename, hs->grf_prop.local_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ uint16 OverrideManagerBase::GetSubstituteID(uint16 entity_id)
|
||||||
*/
|
*/
|
||||||
void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs)
|
void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs)
|
||||||
{
|
{
|
||||||
HouseID house_id = this->AddEntityID(hs->local_id, hs->grffile->grfid, hs->substitute_id);
|
HouseID house_id = this->AddEntityID(hs->grf_prop.local_id, hs->grf_prop.grffile->grfid, hs->grf_prop.subst_id);
|
||||||
|
|
||||||
if (house_id == invalid_ID) {
|
if (house_id == invalid_ID) {
|
||||||
grfmsg(1, "House.SetEntitySpec: Too many houses allocated. Ignoring.");
|
grfmsg(1, "House.SetEntitySpec: Too many houses allocated. Ignoring.");
|
||||||
|
@ -170,9 +170,9 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs)
|
||||||
for (int i = 0; i != max_offset; i++) {
|
for (int i = 0; i != max_offset; i++) {
|
||||||
HouseSpec *overridden_hs = HouseSpec::Get(i);
|
HouseSpec *overridden_hs = HouseSpec::Get(i);
|
||||||
|
|
||||||
if (entity_overrides[i] != hs->local_id || grfid_overrides[i] != hs->grffile->grfid) continue;
|
if (entity_overrides[i] != hs->grf_prop.local_id || grfid_overrides[i] != hs->grf_prop.grffile->grfid) continue;
|
||||||
|
|
||||||
overridden_hs->override = house_id;
|
overridden_hs->grf_prop.override = house_id;
|
||||||
entity_overrides[i] = invalid_ID;
|
entity_overrides[i] = invalid_ID;
|
||||||
grfid_overrides[i] = 0;
|
grfid_overrides[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,14 +157,14 @@ static bool SearchNearbyHouseID(TileIndex tile, void *user_data)
|
||||||
if (IsTileType(tile, MP_HOUSE)) {
|
if (IsTileType(tile, MP_HOUSE)) {
|
||||||
HouseID house = GetHouseType(tile); // tile been examined
|
HouseID house = GetHouseType(tile); // tile been examined
|
||||||
const HouseSpec *hs = HouseSpec::Get(house);
|
const HouseSpec *hs = HouseSpec::Get(house);
|
||||||
if (hs->grffile != NULL) { // must be one from a grf file
|
if (hs->grf_prop.grffile != NULL) { // must be one from a grf file
|
||||||
SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
|
SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
|
||||||
|
|
||||||
TileIndex north_tile = tile + GetHouseNorthPart(house); // modifies 'house'!
|
TileIndex north_tile = tile + GetHouseNorthPart(house); // modifies 'house'!
|
||||||
if (north_tile == nbhd->north_tile) return false; // Always ignore origin house
|
if (north_tile == nbhd->north_tile) return false; // Always ignore origin house
|
||||||
|
|
||||||
return hs->local_id == nbhd->hs->local_id && // same local id as the one requested
|
return hs->grf_prop.local_id == nbhd->hs->grf_prop.local_id && // same local id as the one requested
|
||||||
hs->grffile->grfid == nbhd->hs->grffile->grfid; // from the same grf
|
hs->grf_prop.grffile->grfid == nbhd->hs->grf_prop.grffile->grfid; // from the same grf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -181,14 +181,14 @@ static bool SearchNearbyHouseClass(TileIndex tile, void *user_data)
|
||||||
if (IsTileType(tile, MP_HOUSE)) {
|
if (IsTileType(tile, MP_HOUSE)) {
|
||||||
HouseID house = GetHouseType(tile); // tile been examined
|
HouseID house = GetHouseType(tile); // tile been examined
|
||||||
const HouseSpec *hs = HouseSpec::Get(house);
|
const HouseSpec *hs = HouseSpec::Get(house);
|
||||||
if (hs->grffile != NULL) { // must be one from a grf file
|
if (hs->grf_prop.grffile != NULL) { // must be one from a grf file
|
||||||
SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
|
SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
|
||||||
|
|
||||||
TileIndex north_tile = tile + GetHouseNorthPart(house); // modifies 'house'!
|
TileIndex north_tile = tile + GetHouseNorthPart(house); // modifies 'house'!
|
||||||
if (north_tile == nbhd->north_tile) return false; // Always ignore origin house
|
if (north_tile == nbhd->north_tile) return false; // Always ignore origin house
|
||||||
|
|
||||||
return hs->class_id == nbhd->hs->class_id && // same classid as the one requested
|
return hs->class_id == nbhd->hs->class_id && // same classid as the one requested
|
||||||
hs->grffile->grfid == nbhd->hs->grffile->grfid; // from the same grf
|
hs->grf_prop.grffile->grfid == nbhd->hs->grf_prop.grffile->grfid; // from the same grf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -205,13 +205,13 @@ static bool SearchNearbyHouseGRFID(TileIndex tile, void *user_data)
|
||||||
if (IsTileType(tile, MP_HOUSE)) {
|
if (IsTileType(tile, MP_HOUSE)) {
|
||||||
HouseID house = GetHouseType(tile); // tile been examined
|
HouseID house = GetHouseType(tile); // tile been examined
|
||||||
const HouseSpec *hs = HouseSpec::Get(house);
|
const HouseSpec *hs = HouseSpec::Get(house);
|
||||||
if (hs->grffile != NULL) { // must be one from a grf file
|
if (hs->grf_prop.grffile != NULL) { // must be one from a grf file
|
||||||
SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
|
SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
|
||||||
|
|
||||||
TileIndex north_tile = tile + GetHouseNorthPart(house); // modifies 'house'!
|
TileIndex north_tile = tile + GetHouseNorthPart(house); // modifies 'house'!
|
||||||
if (north_tile == nbhd->north_tile) return false; // Always ignore origin house
|
if (north_tile == nbhd->north_tile) return false; // Always ignore origin house
|
||||||
|
|
||||||
return hs->grffile->grfid == nbhd->hs->grffile->grfid; // from the same grf
|
return hs->grf_prop.grffile->grfid == nbhd->hs->grf_prop.grffile->grfid; // from the same grf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -297,9 +297,9 @@ static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte
|
||||||
/* Building counts for new houses with id = parameter. */
|
/* Building counts for new houses with id = parameter. */
|
||||||
case 0x61: {
|
case 0x61: {
|
||||||
const HouseSpec *hs = HouseSpec::Get(house_id);
|
const HouseSpec *hs = HouseSpec::Get(house_id);
|
||||||
if (hs->grffile == NULL) return 0;
|
if (hs->grf_prop.grffile == NULL) return 0;
|
||||||
|
|
||||||
HouseID new_house = _house_mngr.GetID(parameter, hs->grffile->grfid);
|
HouseID new_house = _house_mngr.GetID(parameter, hs->grf_prop.grffile->grfid);
|
||||||
return new_house == INVALID_HOUSE_ID ? 0 : GetNumHouses(new_house, town);
|
return new_house == INVALID_HOUSE_ID ? 0 : GetNumHouses(new_house, town);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte
|
||||||
/* Information about the grf local classid if the house has a class */
|
/* Information about the grf local classid if the house has a class */
|
||||||
uint houseclass = 0;
|
uint houseclass = 0;
|
||||||
if (hs->class_id != HOUSE_NO_CLASS) {
|
if (hs->class_id != HOUSE_NO_CLASS) {
|
||||||
houseclass = (hs->grffile == object->grffile ? 1 : 2) << 8;
|
houseclass = (hs->grf_prop.grffile == object->grffile ? 1 : 2) << 8;
|
||||||
houseclass |= _class_mapping[hs->class_id].class_id;
|
houseclass |= _class_mapping[hs->class_id].class_id;
|
||||||
}
|
}
|
||||||
/* old house type or grf-local houseid */
|
/* old house type or grf-local houseid */
|
||||||
|
@ -334,8 +334,8 @@ static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte
|
||||||
if (house_id < NEW_HOUSE_OFFSET) {
|
if (house_id < NEW_HOUSE_OFFSET) {
|
||||||
local_houseid = house_id;
|
local_houseid = house_id;
|
||||||
} else {
|
} else {
|
||||||
local_houseid = (hs->grffile == object->grffile ? 1 : 2) << 8;
|
local_houseid = (hs->grf_prop.grffile == object->grffile ? 1 : 2) << 8;
|
||||||
local_houseid |= hs->local_id;
|
local_houseid |= hs->grf_prop.local_id;
|
||||||
}
|
}
|
||||||
return houseclass << 16 | local_houseid;
|
return houseclass << 16 | local_houseid;
|
||||||
}
|
}
|
||||||
|
@ -390,8 +390,8 @@ static void NewHouseResolver(ResolverObject *res, HouseID house_id, TileIndex ti
|
||||||
res->reseed = 0;
|
res->reseed = 0;
|
||||||
res->count = 0;
|
res->count = 0;
|
||||||
|
|
||||||
const HouseSpec *hs = HouseSpec::Get(house_id);
|
const HouseSpec *hs = HouseSpec::Get(house_id);
|
||||||
res->grffile = (hs != NULL ? hs->grffile : NULL);
|
res->grffile = (hs != NULL ? hs->grf_prop.grffile : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile, bool not_yet_constructed, uint8 initial_random_bits)
|
uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile, bool not_yet_constructed, uint8 initial_random_bits)
|
||||||
|
@ -408,7 +408,7 @@ uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, House
|
||||||
object.u.house.not_yet_constructed = not_yet_constructed;
|
object.u.house.not_yet_constructed = not_yet_constructed;
|
||||||
object.u.house.initial_random_bits = initial_random_bits;
|
object.u.house.initial_random_bits = initial_random_bits;
|
||||||
|
|
||||||
group = SpriteGroup::Resolve(HouseSpec::Get(house_id)->spritegroup, &object);
|
group = SpriteGroup::Resolve(HouseSpec::Get(house_id)->grf_prop.spritegroup, &object);
|
||||||
if (group == NULL) return CALLBACK_FAILED;
|
if (group == NULL) return CALLBACK_FAILED;
|
||||||
|
|
||||||
return group->GetCallbackResult();
|
return group->GetCallbackResult();
|
||||||
|
@ -459,7 +459,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
|
||||||
|
|
||||||
NewHouseResolver(&object, house_id, ti->tile, Town::GetByTile(ti->tile));
|
NewHouseResolver(&object, house_id, ti->tile, Town::GetByTile(ti->tile));
|
||||||
|
|
||||||
group = SpriteGroup::Resolve(hs->spritegroup, &object);
|
group = SpriteGroup::Resolve(hs->grf_prop.spritegroup, &object);
|
||||||
if (group == NULL || group->type != SGT_TILELAYOUT) {
|
if (group == NULL || group->type != SGT_TILELAYOUT) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -513,7 +513,7 @@ void AnimateNewHouseTile(TileIndex tile)
|
||||||
|
|
||||||
/* If the lower 7 bits of the upper byte of the callback
|
/* If the lower 7 bits of the upper byte of the callback
|
||||||
* result are not empty, it is a sound effect. */
|
* result are not empty, it is a sound effect. */
|
||||||
if (GB(callback_res, 8, 7) != 0) PlayTileSound(hs->grffile, GB(callback_res, 8, 7), tile);
|
if (GB(callback_res, 8, 7) != 0) PlayTileSound(hs->grf_prop.grffile, GB(callback_res, 8, 7), tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,7 +575,7 @@ static void AnimationControl(TileIndex tile, uint16 random_bits)
|
||||||
uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random();
|
uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random();
|
||||||
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
||||||
|
|
||||||
if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grffile, tile, callback_res);
|
if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grf_prop.grffile, tile, callback_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,14 +632,14 @@ static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, byte base_rando
|
||||||
HouseID hid = GetHouseType(tile);
|
HouseID hid = GetHouseType(tile);
|
||||||
HouseSpec *hs = HouseSpec::Get(hid);
|
HouseSpec *hs = HouseSpec::Get(hid);
|
||||||
|
|
||||||
if (hs->spritegroup == NULL) return;
|
if (hs->grf_prop.spritegroup == NULL) return;
|
||||||
|
|
||||||
NewHouseResolver(&object, hid, tile, Town::GetByTile(tile));
|
NewHouseResolver(&object, hid, tile, Town::GetByTile(tile));
|
||||||
|
|
||||||
object.callback = CBID_RANDOM_TRIGGER;
|
object.callback = CBID_RANDOM_TRIGGER;
|
||||||
object.trigger = trigger;
|
object.trigger = trigger;
|
||||||
|
|
||||||
const SpriteGroup *group = SpriteGroup::Resolve(hs->spritegroup, &object);
|
const SpriteGroup *group = SpriteGroup::Resolve(hs->grf_prop.spritegroup, &object);
|
||||||
if (group == NULL) return;
|
if (group == NULL) return;
|
||||||
|
|
||||||
byte new_random_bits = Random();
|
byte new_random_bits = Random();
|
||||||
|
|
|
@ -180,7 +180,7 @@ static const NIVariable _niv_house[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class NIHHouse : public NIHelper {
|
class NIHHouse : public NIHelper {
|
||||||
bool IsInspectable(uint index) const { return HouseSpec::Get(GetHouseType(index))->grffile != NULL; }
|
bool IsInspectable(uint index) const { return HouseSpec::Get(GetHouseType(index))->grf_prop.grffile != NULL; }
|
||||||
uint GetParent(uint index) const { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); }
|
uint GetParent(uint index) const { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); }
|
||||||
const void *GetInstance(uint index)const { return NULL; }
|
const void *GetInstance(uint index)const { return NULL; }
|
||||||
const void *GetSpec(uint index) const { return HouseSpec::Get(GetHouseType(index)); }
|
const void *GetSpec(uint index) const { return HouseSpec::Get(GetHouseType(index)); }
|
||||||
|
|
|
@ -1813,7 +1813,7 @@ assert_compile(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);
|
||||||
*/
|
*/
|
||||||
#define MS(mnd, mxd, p, rc, bn, rr, mg, ca1, ca2, ca3, bf, ba, cg1, cg2, cg3) \
|
#define MS(mnd, mxd, p, rc, bn, rr, mg, ca1, ca2, ca3, bf, ba, cg1, cg2, cg3) \
|
||||||
{mnd, mxd, p, rc, bn, rr, mg, {ca1, ca2, ca3}, {cg1, cg2, cg3}, bf, ba, true, \
|
{mnd, mxd, p, rc, bn, rr, mg, {ca1, ca2, ca3}, {cg1, cg2, cg3}, bf, ba, true, \
|
||||||
0, NULL, INVALID_HOUSE_ID, 0, {0, 0, 0, 0}, 16, NO_EXTRA_FLAG, HOUSE_NO_CLASS, 0, 2, 0, 0, 0, NULL}
|
GRFFileProps(INVALID_HOUSE_ID), 0, {0, 0, 0, 0}, 16, NO_EXTRA_FLAG, HOUSE_NO_CLASS, 0, 2, 0, 0}
|
||||||
/** House specifications from original data */
|
/** House specifications from original data */
|
||||||
static const HouseSpec _original_house_specs[] = {
|
static const HouseSpec _original_house_specs[] = {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -204,11 +204,11 @@ static void DrawTile_Town(TileInfo *ti)
|
||||||
/* Houses don't necessarily need new graphics. If they don't have a
|
/* Houses don't necessarily need new graphics. If they don't have a
|
||||||
* spritegroup associated with them, then the sprite for the substitute
|
* spritegroup associated with them, then the sprite for the substitute
|
||||||
* house id is drawn instead. */
|
* house id is drawn instead. */
|
||||||
if (HouseSpec::Get(house_id)->spritegroup != NULL) {
|
if (HouseSpec::Get(house_id)->grf_prop.spritegroup != NULL) {
|
||||||
DrawNewHouseTile(ti, house_id);
|
DrawNewHouseTile(ti, house_id);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
house_id = HouseSpec::Get(house_id)->substitute_id;
|
house_id = HouseSpec::Get(house_id)->grf_prop.subst_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ static Foundation GetFoundation_Town(TileIndex tile, Slope tileh)
|
||||||
*/
|
*/
|
||||||
if (hid >= NEW_HOUSE_OFFSET) {
|
if (hid >= NEW_HOUSE_OFFSET) {
|
||||||
const HouseSpec *hs = HouseSpec::Get(hid);
|
const HouseSpec *hs = HouseSpec::Get(hid);
|
||||||
if (hs->spritegroup != NULL && HasBit(hs->callback_mask, CBM_HOUSE_DRAW_FOUNDATIONS)) {
|
if (hs->grf_prop.spritegroup != NULL && HasBit(hs->callback_mask, CBM_HOUSE_DRAW_FOUNDATIONS)) {
|
||||||
uint32 callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, hid, Town::GetByTile(tile), tile);
|
uint32 callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, hid, Town::GetByTile(tile), tile);
|
||||||
if (callback_res == 0) return FOUNDATION_NONE;
|
if (callback_res == 0) return FOUNDATION_NONE;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ static void MakeSingleHouseBigger(TileIndex tile)
|
||||||
/* Check and/or */
|
/* Check and/or */
|
||||||
if (HasBit(hs->callback_mask, CBM_HOUSE_CONSTRUCTION_STATE_CHANGE)) {
|
if (HasBit(hs->callback_mask, CBM_HOUSE_CONSTRUCTION_STATE_CHANGE)) {
|
||||||
uint16 callback_res = GetHouseCallback(CBID_HOUSE_CONSTRUCTION_STATE_CHANGE, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
uint16 callback_res = GetHouseCallback(CBID_HOUSE_CONSTRUCTION_STATE_CHANGE, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
||||||
if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grffile, tile, callback_res);
|
if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grf_prop.grffile, tile, callback_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsHouseCompleted(tile)) {
|
if (IsHouseCompleted(tile)) {
|
||||||
|
@ -475,7 +475,7 @@ static void TileLoop_Town(TileIndex tile)
|
||||||
|
|
||||||
if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break;
|
if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break;
|
||||||
|
|
||||||
CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile);
|
CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grf_prop.grffile);
|
||||||
if (cargo == CT_INVALID) continue;
|
if (cargo == CT_INVALID) continue;
|
||||||
|
|
||||||
uint amt = GB(callback, 0, 8);
|
uint amt = GB(callback, 0, 8);
|
||||||
|
@ -576,7 +576,7 @@ static void AddProducedCargo_Town(TileIndex tile, CargoArray &produced)
|
||||||
|
|
||||||
if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break;
|
if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break;
|
||||||
|
|
||||||
CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile);
|
CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grf_prop.grffile);
|
||||||
|
|
||||||
if (cargo == CT_INVALID) continue;
|
if (cargo == CT_INVALID) continue;
|
||||||
produced[cargo]++;
|
produced[cargo]++;
|
||||||
|
@ -613,9 +613,9 @@ static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, uint32
|
||||||
uint16 callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
uint16 callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
||||||
if (callback != CALLBACK_FAILED) {
|
if (callback != CALLBACK_FAILED) {
|
||||||
/* Replace accepted cargo types with translated values from callback */
|
/* Replace accepted cargo types with translated values from callback */
|
||||||
accepts[0] = GetCargoTranslation(GB(callback, 0, 5), hs->grffile);
|
accepts[0] = GetCargoTranslation(GB(callback, 0, 5), hs->grf_prop.grffile);
|
||||||
accepts[1] = GetCargoTranslation(GB(callback, 5, 5), hs->grffile);
|
accepts[1] = GetCargoTranslation(GB(callback, 5, 5), hs->grf_prop.grffile);
|
||||||
accepts[2] = GetCargoTranslation(GB(callback, 10, 5), hs->grffile);
|
accepts[2] = GetCargoTranslation(GB(callback, 10, 5), hs->grf_prop.grffile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +651,7 @@ static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
|
||||||
|
|
||||||
uint16 callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, Town::GetByTile(tile), tile);
|
uint16 callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, Town::GetByTile(tile), tile);
|
||||||
if (callback_res != CALLBACK_FAILED) {
|
if (callback_res != CALLBACK_FAILED) {
|
||||||
StringID new_name = GetGRFStringID(hs->grffile->grfid, 0xD000 + callback_res);
|
StringID new_name = GetGRFStringID(hs->grf_prop.grffile->grfid, 0xD000 + callback_res);
|
||||||
if (new_name != STR_NULL && new_name != STR_UNDEFINED) {
|
if (new_name != STR_NULL && new_name != STR_UNDEFINED) {
|
||||||
td->str = new_name;
|
td->str = new_name;
|
||||||
}
|
}
|
||||||
|
@ -662,8 +662,8 @@ static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
|
||||||
td->str = STR_LAI_TOWN_INDUSTRY_DESCRIPTION_UNDER_CONSTRUCTION;
|
td->str = STR_LAI_TOWN_INDUSTRY_DESCRIPTION_UNDER_CONSTRUCTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hs->grffile != NULL) {
|
if (hs->grf_prop.grffile != NULL) {
|
||||||
const GRFConfig *gc = GetGRFConfig(hs->grffile->grfid);
|
const GRFConfig *gc = GetGRFConfig(hs->grf_prop.grffile->grfid);
|
||||||
td->grf = gc->GetName();
|
td->grf = gc->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2101,7 +2101,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
||||||
const HouseSpec *hs = HouseSpec::Get(i);
|
const HouseSpec *hs = HouseSpec::Get(i);
|
||||||
|
|
||||||
/* Verify that the candidate house spec matches the current tile status */
|
/* Verify that the candidate house spec matches the current tile status */
|
||||||
if ((~hs->building_availability & bitmask) != 0 || !hs->enabled || hs->override != INVALID_HOUSE_ID) continue;
|
if ((~hs->building_availability & bitmask) != 0 || !hs->enabled || hs->grf_prop.override != INVALID_HOUSE_ID) continue;
|
||||||
|
|
||||||
/* Don't let these counters overflow. Global counters are 32bit, there will never be that many houses. */
|
/* Don't let these counters overflow. Global counters are 32bit, there will never be that many houses. */
|
||||||
if (hs->class_id != HOUSE_NO_CLASS) {
|
if (hs->class_id != HOUSE_NO_CLASS) {
|
||||||
|
|
Loading…
Reference in New Issue