From 013df98f79866a75f367853c9e436f3c5c79f645 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 2 Jan 2007 19:19:48 +0000 Subject: (svn r7759) -Merge: makefile rewrite. This merge features: - A proper ./configure, so everything needs to be configured only once, not for every make. - Usage of makedepend when available. This greatly reduces the time needed for generating the dependencies. - A generator for all project files. There is a single file with sources, which is used to generate Makefiles and the project files for MSVC. - Proper support for OSX universal binaries. - Object files for non-MSVC compiles are also placed in separate directories, making is faster to switch between debug and release compiles and it does not touch the directory with the source files. - Functionality to make a bundle of all needed files for for example a nightly or distribution of a binary with all needed GRFs and language files. Note: as this merge moves almost all files, it is recommended to make a backup of your working copy before updating your working copy. --- src/clear_map.h | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 src/clear_map.h (limited to 'src/clear_map.h') diff --git a/src/clear_map.h b/src/clear_map.h new file mode 100644 index 000000000..50ae63b1b --- /dev/null +++ b/src/clear_map.h @@ -0,0 +1,145 @@ +/* $Id$ */ + +#ifndef CLEAR_MAP_H +#define CLEAR_MAP_H + +#include "macros.h" +#include "tile.h" + +/* ground type, m5 bits 2...4 + * valid densities (bits 0...1) in comments after the enum + */ +typedef enum ClearGround { + CLEAR_GRASS = 0, // 0-3 + CLEAR_ROUGH = 1, // 3 + CLEAR_ROCKS = 2, // 3 + CLEAR_FIELDS = 3, // 3 + CLEAR_SNOW = 4, // 0-3 + CLEAR_DESERT = 5 // 1,3 +} ClearGround; + + +static inline ClearGround GetClearGround(TileIndex t) +{ + assert(IsTileType(t, MP_CLEAR)); + return GB(_m[t].m5, 2, 3); +} + +static inline bool IsClearGround(TileIndex t, ClearGround ct) +{ + return GetClearGround(t) == ct; +} + + +static inline uint GetClearDensity(TileIndex t) +{ + assert(IsTileType(t, MP_CLEAR)); + return GB(_m[t].m5, 0, 2); +} + +static inline void AddClearDensity(TileIndex t, int d) +{ + assert(IsTileType(t, MP_CLEAR)); // XXX incomplete + _m[t].m5 += d; +} + + +static inline uint GetClearCounter(TileIndex t) +{ + assert(IsTileType(t, MP_CLEAR)); + return GB(_m[t].m5, 5, 3); +} + +static inline void AddClearCounter(TileIndex t, int c) +{ + assert(IsTileType(t, MP_CLEAR)); // XXX incomplete + _m[t].m5 += c << 5; +} + +static inline void SetClearCounter(TileIndex t, uint c) +{ + assert(IsTileType(t, MP_CLEAR)); // XXX incomplete + SB(_m[t].m5, 5, 3, c); +} + + +/* Sets type and density in one go, also sets the counter to 0 */ +static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density) +{ + assert(IsTileType(t, MP_CLEAR)); // XXX incomplete + _m[t].m5 = 0 << 5 | type << 2 | density; +} + + +static inline uint GetFieldType(TileIndex t) +{ + assert(GetClearGround(t) == CLEAR_FIELDS); + return GB(_m[t].m3, 0, 4); +} + +static inline void SetFieldType(TileIndex t, uint f) +{ + assert(GetClearGround(t) == CLEAR_FIELDS); // XXX incomplete + SB(_m[t].m3, 0, 4, f); +} + +static inline uint16 GetIndustryIndexOfField(TileIndex t) +{ + assert(GetClearGround(t) == CLEAR_FIELDS); + return _m[t].m2; +} + +static inline void SetIndustryIndexOfField(TileIndex t, uint16 i) +{ + assert(GetClearGround(t) == CLEAR_FIELDS); + _m[t].m2 = i; +} + +/* Is used by tree tiles, too */ +static inline uint GetFenceSE(TileIndex t) +{ + assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); + return GB(_m[t].m4, 2, 3); +} + +static inline void SetFenceSE(TileIndex t, uint h) +{ + assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete + SB(_m[t].m4, 2, 3, h); +} + +static inline uint GetFenceSW(TileIndex t) +{ + assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); + return GB(_m[t].m4, 5, 3); +} + +static inline void SetFenceSW(TileIndex t, uint h) +{ + assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete + SB(_m[t].m4, 5, 3, h); +} + + +static inline void MakeClear(TileIndex t, ClearGround g, uint density) +{ + SetTileType(t, MP_CLEAR); + SetTileOwner(t, OWNER_NONE); + _m[t].m2 = 0; + _m[t].m3 = 0; + _m[t].m4 = 0 << 5 | 0 << 2; + SetClearGroundDensity(t, g, density); +} + + +static inline void MakeField(TileIndex t, uint field_type, uint16 industry) +{ + SetTileType(t, MP_CLEAR); + SetTileOwner(t, OWNER_NONE); + _m[t].m2 = industry; + _m[t].m3 = field_type; + _m[t].m4 = 0 << 5 | 0 << 2; + SetClearGroundDensity(t, CLEAR_FIELDS, 3); +} + +#endif /* CLEAR_MAP_H */ -- cgit v1.2.3-54-g00ecf