~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/newgrf_house.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Kooijman
  • Date: 2010-07-01 08:14:02 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20100701081402-98jmva0t3sqywxmi
Tags: 1.0.2-1
* [00c4efe] New upstream release 1.0.2.
* [c7b38fd] Break older openttd versions instead of Conflicting with
  them.
* [36bd61f] Bump standards version to 3.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: newgrf_house.cpp 18872 2010-01-21 01:38:13Z rubidium $ */
 
1
/* $Id: newgrf_house.cpp 19855 2010-05-18 21:30:56Z rubidium $ */
2
2
 
3
3
/*
4
4
 * This file is part of OpenTTD.
99
99
 
100
100
static uint32 HouseGetRandomBits(const ResolverObject *object)
101
101
{
102
 
        const TileIndex tile = object->u.house.tile;
103
 
        return (tile == INVALID_TILE || !IsTileType(tile, MP_HOUSE)) ? 0 : GetHouseRandomBits(tile);
 
102
        /* Note: Towns build houses over houses. So during construction checks 'tile' may be a valid but unrelated house. */
 
103
        TileIndex tile = object->u.house.tile;
 
104
        assert(IsValidTile(tile) && (object->u.house.not_yet_constructed || IsTileType(tile, MP_HOUSE)));
 
105
        return object->u.house.not_yet_constructed ? 0 : GetHouseRandomBits(tile);
104
106
}
105
107
 
106
108
static uint32 HouseGetTriggers(const ResolverObject *object)
107
109
{
108
 
        const TileIndex tile = object->u.house.tile;
109
 
        return (tile == INVALID_TILE || !IsTileType(tile, MP_HOUSE)) ? 0 : GetHouseTriggers(tile);
 
110
        /* Note: Towns build houses over houses. So during construction checks 'tile' may be a valid but unrelated house. */
 
111
        TileIndex tile = object->u.house.tile;
 
112
        assert(IsValidTile(tile) && (object->u.house.not_yet_constructed || IsTileType(tile, MP_HOUSE)));
 
113
        return object->u.house.not_yet_constructed ? 0 : GetHouseTriggers(tile);
110
114
}
111
115
 
112
116
static void HouseSetTriggers(const ResolverObject *object, int triggers)
113
117
{
114
 
        const TileIndex tile = object->u.house.tile;
115
 
        if (IsTileType(tile, MP_HOUSE)) SetHouseTriggers(tile, triggers);
 
118
        TileIndex tile = object->u.house.tile;
 
119
        assert(!object->u.house.not_yet_constructed && IsValidTile(tile) && IsTileType(tile, MP_HOUSE));
 
120
        SetHouseTriggers(tile, triggers);
116
121
}
117
122
 
118
123
static uint32 GetNumHouses(HouseID house_id, const Town *town)
370
375
        res->u.house.tile     = tile;
371
376
        res->u.house.town     = town;
372
377
        res->u.house.house_id = house_id;
 
378
        res->u.house.not_yet_constructed = false;
373
379
 
374
380
        res->callback        = CBID_NO_CALLBACK;
375
381
        res->callback_param1 = 0;
383
389
        res->grffile         = (hs != NULL ? hs->grffile : NULL);
384
390
}
385
391
 
386
 
uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile)
 
392
uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile, bool not_yet_constructed)
387
393
{
388
394
        ResolverObject object;
389
395
        const SpriteGroup *group;
390
396
 
 
397
        assert(IsValidTile(tile) && (not_yet_constructed || IsTileType(tile, MP_HOUSE)));
 
398
 
391
399
        NewHouseResolver(&object, house_id, tile, town);
392
400
        object.callback = callback;
393
401
        object.callback_param1 = param1;
394
402
        object.callback_param2 = param2;
 
403
        object.u.house.not_yet_constructed = not_yet_constructed;
395
404
 
396
405
        group = SpriteGroup::Resolve(HouseSpec::Get(house_id)->spritegroup, &object);
397
406
        if (group == NULL) return CALLBACK_FAILED;