Changeset - r14474:aa12474cff10
[Not reviewed]
master
0 4 0
frosch - 15 years ago 2010-02-07 12:04:44
frosch@openttd.org
(svn r19053) -Codechange: Add an enum for the special flags of industry tiles. (based on andythenorth' work)
4 files changed with 13 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/industrytype.h
Show inline comments
 
@@ -52,12 +52,13 @@ enum IndustryConstructionType {
 
	ICT_UNKNOWN,          ///< in previous game version or without newindustries activated
 
	ICT_NORMAL_GAMEPLAY,  ///< either by user or random creation proccess
 
	ICT_MAP_GENERATION,   ///< during random map creation
 
	ICT_SCENARIO_EDITOR   ///< while scenarion edition
 
};
 

	
 
/** Various industry behaviours mostly to represent original TTD specialities */
 
enum IndustryBehaviour {
 
	INDUSTRYBEH_NONE                  =      0,
 
	INDUSTRYBEH_PLANT_FIELDS          = 1 << 0,  ///< periodically plants fileds around itself (temp and artic farms)
 
	INDUSTRYBEH_CUT_TREES             = 1 << 1,  ///< cuts trees and produce first output cargo from them (lumber mill)
 
	INDUSTRYBEH_BUILT_ONWATER         = 1 << 2,  ///< is built on water (oil rig)
 
	INDUSTRYBEH_TOWN1200_MORE         = 1 << 3,  ///< can only be built in towns larger than 1200 inhabitants (temperate bank)
 
@@ -76,12 +77,19 @@ enum IndustryBehaviour {
 
	INDUSTRYBEH_PRODCALLBACK_RANDOM   = 1 << 15, ///< Production callback needs random bits in var 10
 
	INDUSTRYBEH_NOBUILT_MAPCREATION   = 1 << 16, ///< Do not force one instance of this type to appear on map generation
 
	INDUSTRYBEH_CANCLOSE_LASTINSTANCE = 1 << 17, ///< Allow closing down the last instance of this type
 
};
 
DECLARE_ENUM_AS_BIT_SET(IndustryBehaviour);
 

	
 
/** Flags for miscellaneous industry tile specialities */
 
enum IndustryTileSpecialFlags {
 
	INDTILE_SPECIAL_NONE                  = 0,
 
	INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS  = 1 << 0, ///< Callback 0x26 needs random bits
 
};
 
DECLARE_ENUM_AS_BIT_SET(IndustryTileSpecialFlags);
 

	
 
struct IndustryTileTable {
 
	TileIndexDiffC ti;
 
	IndustryGfx gfx;
 
};
 

	
 
/** Data related to the handling of grf files.  Common to both industry and industry tile */
 
@@ -164,13 +172,13 @@ struct IndustryTileSpec {
 
	                                      ///< state instead of the construction state
 
	/* Newgrf data */
 
	uint8 callback_mask;                  ///< Bitmask of industry tile callbacks that have to be called
 
	uint16 animation_info;                ///< Information about the animation (is it looping, how many loops etc)
 
	uint8 animation_speed;                ///< The speed of the animation
 
	uint8 animation_triggers;             ///< When to start the animation
 
	uint8 animation_special_flags;        ///< Extra flags to influence the animation
 
	IndustryTileSpecialFlags special_flags; ///< Bitmask of extra flags used by the tile
 
	bool enabled;                         ///< entity still avaible (by default true).newgrf can disable it, though
 
	struct GRFFileProps grf_prop;
 
};
 

	
 
/* industry_cmd.cpp*/
 
const IndustrySpec *GetIndustrySpec(IndustryType thistype);    ///< Array of industries data
src/newgrf.cpp
Show inline comments
 
@@ -2157,13 +2157,13 @@ static ChangeInfoResult IndustrytilesCha
 

	
 
			case 0x11: // Triggers for callback 25
 
				tsp->animation_triggers = buf->ReadByte();
 
				break;
 

	
 
			case 0x12: // Special flags
 
				tsp->animation_special_flags = buf->ReadByte();
 
				tsp->special_flags = (IndustryTileSpecialFlags)buf->ReadByte();
 
				break;
 

	
 
			default:
 
				ret = CIR_UNKNOWN;
 
				break;
 
		}
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -288,13 +288,14 @@ void AnimateNewIndustryTile(TileIndex ti
 

	
 
	bool frame_set_by_callback = false;
 
	byte frame = GetIndustryAnimationState(tile);
 
	uint16 num_frames = GB(itspec->animation_info, 0, 8);
 

	
 
	if (HasBit(itspec->callback_mask, CBM_INDT_ANIM_NEXT_FRAME)) {
 
		uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_ANIM_NEXT_FRAME, HasBit(itspec->animation_special_flags, 0) ? Random() : 0, 0, gfx, ind, tile);
 
		uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_ANIM_NEXT_FRAME,
 
				(itspec->special_flags & INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS) ? Random() : 0, 0, gfx, ind, tile);
 

	
 
		if (callback_res != CALLBACK_FAILED) {
 
			frame_set_by_callback = true;
 

	
 
			switch (callback_res & 0xFF) {
 
				case 0xFF:
src/table/build_industry.h
Show inline comments
 
@@ -1577,13 +1577,13 @@ static const IndustrySpec _origin_indust
 
 * @param c3  and third cargo. Those three are in an array
 
 * @param sl  slope refused upon choosing a place to build
 
 * @param a1  animation frame on production
 
 * @param a2  next frame of animation
 
 * @param a3  chooses between animation or construction state
 
 */
 
#define MT(ca1, c1, ca2, c2, ca3, c3, sl, a1, a2, a3) {{c1, c2, c3}, {ca1, ca2, ca3}, sl, a1, a2, a3, 0, 0xFFFF, 2, 0, 0, true, {INVALID_INDUSTRYTILE, 0, NULL, NULL, INVALID_INDUSTRYTILE}}
 
#define MT(ca1, c1, ca2, c2, ca3, c3, sl, a1, a2, a3) {{c1, c2, c3}, {ca1, ca2, ca3}, sl, a1, a2, a3, 0, 0xFFFF, 2, 0, INDTILE_SPECIAL_NONE, true, {INVALID_INDUSTRYTILE, 0, NULL, NULL, INVALID_INDUSTRYTILE}}
 
static const IndustryTileSpec _origin_industry_tile_specs[NEW_INDUSTRYTILEOFFSET] = {
 
	/* Coal Mine */
 
	MT(0, CT_INVALID,      0, CT_INVALID,      0, CT_INVALID,     SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
 
	MT(0, CT_INVALID,      0, CT_INVALID,      0, CT_INVALID,     SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, true),
 
	MT(0, CT_INVALID,      0, CT_INVALID,      0, CT_INVALID,     SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
 
	MT(1, CT_PASSENGERS,   0, CT_INVALID,      0, CT_INVALID,     SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
0 comments (0 inline, 0 general)