src/industry_map.h
author translators
Thu, 04 Dec 2008 18:47:20 +0000
changeset 10404 ea3784c0b3dd
parent 9839 f1ba805bd78b
permissions -rw-r--r--
(svn r14655) -Update: WebTranslator2 update to 2008-12-04 18:47:16
croatian - 61 fixed by knovak (61)
hebrew - 192 fixed by davidx123 (192)
hungarian - 1 changed by IPG (1)
indonesian - 165 fixed, 6 changed by fanioz (121), dnaftali (50)
malay - 182 fixed, 1 changed by tombakemas (104), Syed (79)
3314
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
     1
/* $Id$ */
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
     2
3495
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
     3
/** @file industry_map.h Accessors for industries */
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
     4
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
     5
#ifndef INDUSTRY_MAP_H
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
     6
#define INDUSTRY_MAP_H
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
     7
3314
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
     8
#include "industry.h"
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7928
diff changeset
     9
#include "tile_map.h"
9718
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
    10
#include "water_map.h"
3545
b08ce1bbb589 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3538
diff changeset
    11
3553
4aab99ade276 (svn r4425) Fix bug introduced in r4411 : while IS_BYTE_INSIDE, max value is STRICKLY LESS THEN. This caused airports animations to stay unanimated. Industries were similarly affected.
belugas
parents: 3545
diff changeset
    12
4aab99ade276 (svn r4425) Fix bug introduced in r4411 : while IS_BYTE_INSIDE, max value is STRICKLY LESS THEN. This caused airports animations to stay unanimated. Industries were similarly affected.
belugas
parents: 3545
diff changeset
    13
/**
4aab99ade276 (svn r4425) Fix bug introduced in r4411 : while IS_BYTE_INSIDE, max value is STRICKLY LESS THEN. This caused airports animations to stay unanimated. Industries were similarly affected.
belugas
parents: 3545
diff changeset
    14
 * The following enums are indices used to know what to draw for this industry tile.
4aab99ade276 (svn r4425) Fix bug introduced in r4411 : while IS_BYTE_INSIDE, max value is STRICKLY LESS THEN. This caused airports animations to stay unanimated. Industries were similarly affected.
belugas
parents: 3545
diff changeset
    15
 * They all are pointing toward array _industry_draw_tile_data, in table/industry_land.h
4aab99ade276 (svn r4425) Fix bug introduced in r4411 : while IS_BYTE_INSIDE, max value is STRICKLY LESS THEN. This caused airports animations to stay unanimated. Industries were similarly affected.
belugas
parents: 3545
diff changeset
    16
 * How to calculate the correct position ? GFXid << 2 | IndustryStage (0 to 3)
4aab99ade276 (svn r4425) Fix bug introduced in r4411 : while IS_BYTE_INSIDE, max value is STRICKLY LESS THEN. This caused airports animations to stay unanimated. Industries were similarly affected.
belugas
parents: 3545
diff changeset
    17
 */
3545
b08ce1bbb589 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3538
diff changeset
    18
enum {
4583
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    19
	GFX_COAL_MINE_TOWER_NOT_ANIMATED   =   0,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    20
	GFX_COAL_MINE_TOWER_ANIMATED       =   1,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    21
	GFX_POWERPLANT_CHIMNEY             =   8,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    22
	GFX_POWERPLANT_SPARKS              =  10,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    23
	GFX_OILRIG_1                       =  24,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    24
	GFX_OILRIG_2                       =  25,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    25
	GFX_OILRIG_3                       =  26,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    26
	GFX_OILRIG_4                       =  27,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    27
	GFX_OILRIG_5                       =  28,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    28
	GFX_OILWELL_NOT_ANIMATED           =  29,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    29
	GFX_OILWELL_ANIMATED_1             =  30,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    30
	GFX_OILWELL_ANIMATED_2             =  31,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    31
	GFX_OILWELL_ANIMATED_3             =  32,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    32
	GFX_COPPER_MINE_TOWER_NOT_ANIMATED =  47,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    33
	GFX_COPPER_MINE_TOWER_ANIMATED     =  48,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    34
	GFX_COPPER_MINE_CHIMNEY            =  49,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    35
	GFX_GOLD_MINE_TOWER_NOT_ANIMATED   =  79,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    36
	GFX_GOLD_MINE_TOWER_ANIMATED       =  88,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    37
	GFX_TOY_FACTORY                    = 143,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    38
	GFX_PLASTIC_FOUNTAIN_ANIMATED_1    = 148,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    39
	GFX_PLASTIC_FOUNTAIN_ANIMATED_2    = 149,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    40
	GFX_PLASTIC_FOUNTAIN_ANIMATED_3    = 150,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    41
	GFX_PLASTIC_FOUNTAIN_ANIMATED_4    = 151,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    42
	GFX_PLASTIC_FOUNTAIN_ANIMATED_5    = 152,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    43
	GFX_PLASTIC_FOUNTAIN_ANIMATED_6    = 153,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    44
	GFX_PLASTIC_FOUNTAIN_ANIMATED_7    = 154,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    45
	GFX_PLASTIC_FOUNTAIN_ANIMATED_8    = 155,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    46
	GFX_BUBBLE_GENERATOR               = 161,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    47
	GFX_BUBBLE_CATCHER                 = 162,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    48
	GFX_TOFFEE_QUARY                   = 165,
af31ba5db77d (svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents: 4330
diff changeset
    49
	GFX_SUGAR_MINE_SIEVE               = 174,
7473
3dfe8243a870 (svn r10980) -Fix [FS#1158] : This will hopefully fix the case of an assert that happens when an industry uses a special gfx index (tile spec 0xFF). This 0xFF is the sentinel of a special check done for oil rigs, where water need to be around, but no tile will be constructed on it.
belugas
parents: 7467
diff changeset
    50
	GFX_WATERTILE_SPECIALCHECK         = 255,  ///< not really a tile, but rather a very special check
3545
b08ce1bbb589 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3538
diff changeset
    51
};
3314
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
    52
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    53
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    54
 * Get the industry ID of the given tile
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    55
 * @param t the tile to get the industry ID from
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    56
 * @pre IsTileType(t, MP_INDUSTRY)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    57
 * @return the industry ID
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    58
 */
4330
cf31daa8b321 (svn r6005) -Cleanup: introduce IndustryID and use it
rubidium
parents: 4077
diff changeset
    59
static inline IndustryID GetIndustryIndex(TileIndex t)
3314
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
    60
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3331
diff changeset
    61
	assert(IsTileType(t, MP_INDUSTRY));
3314
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
    62
	return _m[t].m2;
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
    63
}
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
    64
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    65
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    66
 * Get the industry of the given tile
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    67
 * @param t the tile to get the industry from
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    68
 * @pre IsTileType(t, MP_INDUSTRY)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    69
 * @return the industry
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    70
 */
7318
632cd0497770 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 6874
diff changeset
    71
static inline Industry *GetIndustryByTile(TileIndex t)
3314
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
    72
{
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
    73
	return GetIndustry(GetIndustryIndex(t));
6aaeba4b92e8 (svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
diff changeset
    74
}
3320
e9e284ab853a (svn r4086) Add MakeIndustry()
tron
parents: 3314
diff changeset
    75
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    76
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    77
 * Is this industry tile fully built?
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    78
 * @param t the tile to analyze
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    79
 * @pre IsTileType(t, MP_INDUSTRY)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    80
 * @return true if and only if the industry tile is fully built
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
    81
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3331
diff changeset
    82
static inline bool IsIndustryCompleted(TileIndex t)
3321
4061bfef1830 (svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents: 3320
diff changeset
    83
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3331
diff changeset
    84
	assert(IsTileType(t, MP_INDUSTRY));
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7862
diff changeset
    85
	return HasBit(_m[t].m1, 7);
3321
4061bfef1830 (svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents: 3320
diff changeset
    86
}
4061bfef1830 (svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents: 3320
diff changeset
    87
3499
92f95849788c (svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents: 3495
diff changeset
    88
IndustryType GetIndustryType(TileIndex tile);
92f95849788c (svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents: 3495
diff changeset
    89
3495
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    90
/**
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    91
 * Set if the industry that owns the tile as under construction or not
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    92
 * @param tile the tile to query
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    93
 * @param isCompleted whether it is completed or not
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    94
 * @pre IsTileType(tile, MP_INDUSTRY)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    95
 */
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    96
static inline void SetIndustryCompleted(TileIndex tile, bool isCompleted)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    97
{
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    98
	assert(IsTileType(tile, MP_INDUSTRY));
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
    99
	SB(_m[tile].m1, 7, 1, isCompleted ? 1 :0);
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   100
}
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   101
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   102
/**
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   103
 * Returns the industry construction stage of the specified tile
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   104
 * @param tile the tile to query
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   105
 * @pre IsTileType(tile, MP_INDUSTRY)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   106
 * @return the construction stage
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   107
 */
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   108
static inline byte GetIndustryConstructionStage(TileIndex tile)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   109
{
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   110
	assert(IsTileType(tile, MP_INDUSTRY));
7654
533a9c9a5e83 (svn r11185) -Codechange: prepare some more code for the introduction of NewIndustries. Patch by Belugas.
rubidium
parents: 7622
diff changeset
   111
	return IsIndustryCompleted(tile) ? (byte)INDUSTRY_COMPLETED : GB(_m[tile].m1, 0, 2);
3495
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   112
}
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   113
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   114
/**
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   115
 * Sets the industry construction stage of the specified tile
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   116
 * @param tile the tile to query
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   117
 * @param value the new construction stage
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   118
 * @pre IsTileType(tile, MP_INDUSTRY)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   119
 */
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   120
static inline void SetIndustryConstructionStage(TileIndex tile, byte value)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   121
{
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   122
	assert(IsTileType(tile, MP_INDUSTRY));
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   123
	SB(_m[tile].m1, 0, 2, value);
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   124
}
3321
4061bfef1830 (svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents: 3320
diff changeset
   125
7622
12388e4d86bb (svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
rubidium
parents: 7621
diff changeset
   126
static inline IndustryGfx GetCleanIndustryGfx(TileIndex t)
12388e4d86bb (svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
rubidium
parents: 7621
diff changeset
   127
{
12388e4d86bb (svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
rubidium
parents: 7621
diff changeset
   128
	assert(IsTileType(t, MP_INDUSTRY));
12388e4d86bb (svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
rubidium
parents: 7621
diff changeset
   129
	return _m[t].m5 | (GB(_m[t].m6, 2, 1) << 8);
12388e4d86bb (svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
rubidium
parents: 7621
diff changeset
   130
}
12388e4d86bb (svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
rubidium
parents: 7621
diff changeset
   131
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   132
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   133
 * Get the industry graphics ID for the given industry tile
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   134
 * @param t the tile to get the gfx for
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   135
 * @pre IsTileType(t, MP_INDUSTRY)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   136
 * @return the gfx ID
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   137
 */
3499
92f95849788c (svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents: 3495
diff changeset
   138
static inline IndustryGfx GetIndustryGfx(TileIndex t)
3331
da6bbabbb6cc (svn r4108) Add [GS]etIndustryGfx()
tron
parents: 3321
diff changeset
   139
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3331
diff changeset
   140
	assert(IsTileType(t, MP_INDUSTRY));
7622
12388e4d86bb (svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
rubidium
parents: 7621
diff changeset
   141
	return GetTranslatedIndustryTileID(GetCleanIndustryGfx(t));
3331
da6bbabbb6cc (svn r4108) Add [GS]etIndustryGfx()
tron
parents: 3321
diff changeset
   142
}
da6bbabbb6cc (svn r4108) Add [GS]etIndustryGfx()
tron
parents: 3321
diff changeset
   143
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   144
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   145
 * Set the industry graphics ID for the given industry tile
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   146
 * @param t   the tile to set the gfx for
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   147
 * @pre IsTileType(t, MP_INDUSTRY)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   148
 * @param gfx the graphics ID
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   149
 */
3499
92f95849788c (svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents: 3495
diff changeset
   150
static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
3331
da6bbabbb6cc (svn r4108) Add [GS]etIndustryGfx()
tron
parents: 3321
diff changeset
   151
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3331
diff changeset
   152
	assert(IsTileType(t, MP_INDUSTRY));
7622
12388e4d86bb (svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
rubidium
parents: 7621
diff changeset
   153
	_m[t].m5 = GB(gfx, 0, 8);
12388e4d86bb (svn r11152) -Fix: GetIndustryIDAtOffset crashed when translation of the GFX ID would be needed. Fix by Belugas.
rubidium
parents: 7621
diff changeset
   154
	SB(_m[t].m6, 2, 1, GB(gfx, 8, 1));
3331
da6bbabbb6cc (svn r4108) Add [GS]etIndustryGfx()
tron
parents: 3321
diff changeset
   155
}
da6bbabbb6cc (svn r4108) Add [GS]etIndustryGfx()
tron
parents: 3321
diff changeset
   156
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   157
/**
9718
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   158
 * Tests if the industry tile was built on water.
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   159
 * @param t the industry tile
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   160
 * @return true iff on water
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   161
 */
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   162
static inline bool IsIndustryTileOnWater(TileIndex t)
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   163
{
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   164
	assert(IsTileType(t, MP_INDUSTRY));
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   165
	return (GetWaterClass(t) != WATER_CLASS_INVALID);
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   166
}
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   167
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   168
/**
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   169
 * Make the given tile an industry tile
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8113
diff changeset
   170
 * @param t      the tile to make an industry tile
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8113
diff changeset
   171
 * @param index  the industry this tile belongs to
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8113
diff changeset
   172
 * @param gfx    the graphics to use for the tile
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8113
diff changeset
   173
 * @param random the random value
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   174
 */
9718
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   175
static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc)
3320
e9e284ab853a (svn r4086) Add MakeIndustry()
tron
parents: 3314
diff changeset
   176
{
e9e284ab853a (svn r4086) Add MakeIndustry()
tron
parents: 3314
diff changeset
   177
	SetTileType(t, MP_INDUSTRY);
e9e284ab853a (svn r4086) Add MakeIndustry()
tron
parents: 3314
diff changeset
   178
	_m[t].m1 = 0;
e9e284ab853a (svn r4086) Add MakeIndustry()
tron
parents: 3314
diff changeset
   179
	_m[t].m2 = index;
e9e284ab853a (svn r4086) Add MakeIndustry()
tron
parents: 3314
diff changeset
   180
	_m[t].m3 = 0;
e9e284ab853a (svn r4086) Add MakeIndustry()
tron
parents: 3314
diff changeset
   181
	_m[t].m4 = 0;
6874
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   182
	SetIndustryGfx(t, gfx);
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8113
diff changeset
   183
	_me[t].m7 = random;
9718
4b7468076d31 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents: 8119
diff changeset
   184
	SetWaterClass(t, wc);
3320
e9e284ab853a (svn r4086) Add MakeIndustry()
tron
parents: 3314
diff changeset
   185
}
3495
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   186
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   187
/**
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   188
 * Returns this indutry tile's construction counter value
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   189
 * @param tile the tile to query
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   190
 * @pre IsTileType(tile, MP_INDUSTRY)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   191
 * @return the construction counter
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   192
 */
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   193
static inline byte GetIndustryConstructionCounter(TileIndex tile)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   194
{
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   195
	assert(IsTileType(tile, MP_INDUSTRY));
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   196
	return GB(_m[tile].m1, 2, 2);
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   197
}
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   198
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   199
/**
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   200
 * Sets this indutry tile's construction counter value
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   201
 * @param tile the tile to query
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   202
 * @param value the new value for the construction counter
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   203
 * @pre IsTileType(tile, MP_INDUSTRY)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   204
 */
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   205
static inline void SetIndustryConstructionCounter(TileIndex tile, byte value)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   206
{
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   207
	assert(IsTileType(tile, MP_INDUSTRY));
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   208
	SB(_m[tile].m1, 2, 2, value);
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   209
}
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   210
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   211
/**
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   212
 * Reset the construction stage counter of the industry,
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   213
 * as well as the completion bit.
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   214
 * In fact, it is the same as restarting construction frmo ground up
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   215
 * @param tile the tile to query
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   216
 * @pre IsTileType(tile, MP_INDUSTRY)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   217
 */
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   218
static inline void ResetIndustryConstructionStage(TileIndex tile)
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   219
{
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   220
	assert(IsTileType(tile, MP_INDUSTRY));
9839
f1ba805bd78b (svn r13982) -Fix (r13981): And then not enough was cleared...
peter1138
parents: 9838
diff changeset
   221
	SB(_m[tile].m1, 0, 4, 0);
9838
976f08497fa7 (svn r13981) -Fix [FS#AmmlersStillTooLazy]: Resetting construction stage counter reset more than it should.
peter1138
parents: 9718
diff changeset
   222
	SB(_m[tile].m1, 7, 1, 0);
3495
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   223
}
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   224
3538
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   225
/**
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   226
 * Get the animation loop number
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   227
 * @param tile the tile to get the animation loop number of
5434
4739ee9714f5 (svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents: 4583
diff changeset
   228
 * @pre IsTileType(tile, MP_INDUSTRY)
3538
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   229
 */
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   230
static inline byte GetIndustryAnimationLoop(TileIndex tile)
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   231
{
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   232
	assert(IsTileType(tile, MP_INDUSTRY));
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   233
	return _m[tile].m4;
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   234
}
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   235
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   236
/**
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   237
 * Set the animation loop number
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   238
 * @param tile the tile to set the animation loop number of
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   239
 * @param count the new animation frame number
5434
4739ee9714f5 (svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents: 4583
diff changeset
   240
 * @pre IsTileType(tile, MP_INDUSTRY)
3538
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   241
 */
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   242
static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   243
{
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   244
	assert(IsTileType(tile, MP_INDUSTRY));
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   245
	_m[tile].m4 = count;
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   246
}
750c4ea83357 (svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents: 3499
diff changeset
   247
5435
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   248
/**
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   249
 * Get the animation state
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   250
 * @param tile the tile to get the animation state of
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   251
 * @pre IsTileType(tile, MP_INDUSTRY)
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   252
 */
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   253
static inline byte GetIndustryAnimationState(TileIndex tile)
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   254
{
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   255
	assert(IsTileType(tile, MP_INDUSTRY));
5436
b3d017be25b4 (svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents: 5435
diff changeset
   256
	return _m[tile].m3;
5435
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   257
}
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   258
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   259
/**
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   260
 * Set the animation state
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   261
 * @param tile the tile to set the animation state of
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6248
diff changeset
   262
 * @param state the new animation state
5435
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   263
 * @pre IsTileType(tile, MP_INDUSTRY)
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   264
 */
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   265
static inline void SetIndustryAnimationState(TileIndex tile, byte state)
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   266
{
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   267
	assert(IsTileType(tile, MP_INDUSTRY));
5436
b3d017be25b4 (svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents: 5435
diff changeset
   268
	_m[tile].m3 = state;
5435
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   269
}
ffb0c3620c6e (svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents: 5434
diff changeset
   270
6874
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   271
/**
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   272
 * Get the random bits for this tile.
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   273
 * Used for grf callbacks
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   274
 * @param tile TileIndex of the tile to query
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   275
 * @pre IsTileType(tile, MP_INDUSTRY)
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   276
 * @return requested bits
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   277
 */
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   278
static inline byte GetIndustryRandomBits(TileIndex tile)
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   279
{
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   280
	assert(IsTileType(tile, MP_INDUSTRY));
7621
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   281
	return _me[tile].m7;
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   282
}
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   283
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   284
/**
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   285
 * Set the random bits for this tile.
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   286
 * Used for grf callbacks
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   287
 * @param tile TileIndex of the tile to query
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   288
 * @param bits the random bits
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   289
 * @pre IsTileType(tile, MP_INDUSTRY)
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   290
 */
7689
c4d9ea16fdbe (svn r11223) -Fix[FS#1306]: Rename and refactor adequately a function that actually returns void and set bits (smatz).
belugas
parents: 7654
diff changeset
   291
static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
7621
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   292
{
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   293
	assert(IsTileType(tile, MP_INDUSTRY));
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   294
	_me[tile].m7 = bits;
6874
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   295
}
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   296
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   297
/**
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   298
 * Get the activated triggers bits for this industry tile
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   299
 * Used for grf callbacks
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   300
 * @param tile TileIndex of the tile to query
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   301
 * @pre IsTileType(tile, MP_INDUSTRY)
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   302
 * @return requested triggers
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   303
 */
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   304
static inline byte GetIndustryTriggers(TileIndex tile)
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   305
{
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   306
	assert(IsTileType(tile, MP_INDUSTRY));
7621
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   307
	return GB(_m[tile].m6, 3, 3);
6874
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   308
}
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   309
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   310
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   311
/**
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   312
 * Set the activated triggers bits for this industry tile
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   313
 * Used for grf callbacks
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   314
 * @param tile TileIndex of the tile to query
7621
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   315
 * @param triggers the triggers to set
6874
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   316
 * @pre IsTileType(tile, MP_INDUSTRY)
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   317
 */
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   318
static inline void SetIndustryTriggers(TileIndex tile, byte triggers)
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   319
{
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   320
	assert(IsTileType(tile, MP_INDUSTRY));
7621
09824471f144 (svn r11151) -Codechange: add (partial) support for randomizing industry triggers (part of the backend for it). Furthermore update the documentation of the map's bits wrt to industries.
rubidium
parents: 7473
diff changeset
   321
	SB(_m[tile].m6, 3, 3, triggers);
6874
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   322
}
4e3a49e47f01 (svn r10115) -Codechange: Create accessors to triggers and random bits for industries.
belugas
parents: 6749
diff changeset
   323
3495
6672c181ace4 (svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents: 3369
diff changeset
   324
#endif /* INDUSTRY_MAP_H */