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

« back to all changes in this revision

Viewing changes to src/newgrf_industrytiles.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_industrytiles.cpp 19053 2010-02-07 12:04:44Z frosch $ */
 
1
/* $Id: newgrf_industrytiles.cpp 19855 2010-05-18 21:30:56Z rubidium $ */
2
2
 
3
3
/*
4
4
 * This file is part of OpenTTD.
118
118
static uint32 IndustryTileGetRandomBits(const ResolverObject *object)
119
119
{
120
120
        const TileIndex tile = object->u.industry.tile;
121
 
        if (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) return 0;
122
 
        return (object->scope == VSG_SCOPE_SELF) ? GetIndustryRandomBits(tile) : Industry::GetByTile(tile)->random;
 
121
        const Industry *ind = object->u.industry.ind;
 
122
        assert(ind != NULL && IsValidTile(tile));
 
123
        assert(ind->index == INVALID_INDUSTRY || IsTileType(tile, MP_INDUSTRY));
 
124
 
 
125
        return (object->scope == VSG_SCOPE_SELF) ?
 
126
                        (ind->index != INVALID_INDUSTRY ? GetIndustryRandomBits(tile) : 0) :
 
127
                        ind->random;
123
128
}
124
129
 
125
130
static uint32 IndustryTileGetTriggers(const ResolverObject *object)
126
131
{
127
132
        const TileIndex tile = object->u.industry.tile;
128
 
        if (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) return 0;
129
 
        return (object->scope == VSG_SCOPE_SELF) ? GetIndustryTriggers(tile) : Industry::GetByTile(tile)->random_triggers;
 
133
        const Industry *ind = object->u.industry.ind;
 
134
        assert(ind != NULL && IsValidTile(tile));
 
135
        assert(ind->index == INVALID_INDUSTRY || IsTileType(tile, MP_INDUSTRY));
 
136
        if (ind->index == INVALID_INDUSTRY) return 0;
 
137
        return (object->scope == VSG_SCOPE_SELF) ? GetIndustryTriggers(tile) : ind->random_triggers;
130
138
}
131
139
 
132
140
static void IndustryTileSetTriggers(const ResolverObject *object, int triggers)
133
141
{
134
142
        const TileIndex tile = object->u.industry.tile;
135
 
        if (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) return;
 
143
        Industry *ind = object->u.industry.ind;
 
144
        assert(ind != NULL && ind->index != INVALID_INDUSTRY && IsValidTile(tile) && IsTileType(tile, MP_INDUSTRY));
136
145
 
137
146
        if (object->scope == VSG_SCOPE_SELF) {
138
147
                SetIndustryTriggers(tile, triggers);
139
148
        } else {
140
 
                Industry::GetByTile(tile)->random_triggers = triggers;
 
149
                ind->random_triggers = triggers;
141
150
        }
142
151
}
143
152
 
194
203
        ResolverObject object;
195
204
        const SpriteGroup *group;
196
205
 
 
206
        assert(industry != NULL && IsValidTile(tile));
 
207
        assert(industry->index == INVALID_INDUSTRY || IsTileType(tile, MP_INDUSTRY));
 
208
 
197
209
        NewIndustryTileResolver(&object, gfx_id, tile, industry);
198
210
        object.callback = callback;
199
211
        object.callback_param1 = param1;
385
397
{
386
398
        ResolverObject object;
387
399
 
 
400
        assert(IsValidTile(tile) && IsTileType(tile, MP_INDUSTRY));
 
401
 
388
402
        IndustryGfx gfx = GetIndustryGfx(tile);
389
403
        const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
390
404