Mercurial > hg > openttd
changeset 3144:7020c2e78c6f draft
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
author | tron <tron@openttd.org> |
---|---|
date | Sun, 05 Mar 2006 10:19:33 +0000 |
parents | bfe09300a12a |
children | e1b0286c7794 |
files | ai/default/default.c ai/trolly/trolly.c clear.h clear_cmd.c clear_map.h industry_cmd.c landscape.c openttd.c order_gui.c rail_cmd.c road.h road_cmd.c road_map.h roadveh_cmd.c smallmap_gui.c terraform_gui.c town_cmd.c tree.h tree_cmd.c tree_map.h tunnelbridge_cmd.c void.h void_map.h |
diffstat | 23 files changed, 244 insertions(+), 244 deletions(-) [+] |
line wrap: on
line diff
--- a/ai/default/default.c +++ b/ai/default/default.c @@ -4,7 +4,7 @@ #include "../../openttd.h" #include "../../functions.h" #include "../../map.h" -#include "../../road.h" +#include "../../road_map.h" #include "../../tile.h" #include "../../player.h" #include "../../vehicle.h"
--- a/ai/trolly/trolly.c +++ b/ai/trolly/trolly.c @@ -21,7 +21,7 @@ #include "../../openttd.h" #include "../../debug.h" #include "../../functions.h" -#include "../../road.h" +#include "../../road_map.h" #include "../../table/strings.h" #include "../../map.h" #include "../../tile.h"
deleted file mode 100644 --- a/clear.h +++ /dev/null @@ -1,58 +0,0 @@ -/* $Id$ */ - -#ifndef CLEAR_H -#define CLEAR_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 { - CL_GRASS = 0, // 0-3 - CL_ROUGH = 1, // 3 - CL_ROCKS = 2, // 3 - CL_FIELDS = 3, // 3 - CL_SNOW = 4, // 0-3 - CL_DESERT = 5 // 1,3 -} ClearGround; - -static inline ClearGround GetClearGround(TileIndex t) { return GB(_m[t].m5, 2, 3); } -static inline bool IsClearGround(TileIndex t, ClearGround ct) { return GetClearGround(t) == ct; } - -static inline void AddClearDensity(TileIndex t, int d) { _m[t].m5 += d; } -static inline uint GetClearDensity(TileIndex t) { return GB(_m[t].m5, 0, 2); } - -static inline void AddClearCounter(TileIndex t, int c) { _m[t].m5 += c << 5; } -static inline uint GetClearCounter(TileIndex t) { return GB(_m[t].m5, 5, 3); } -static inline void SetClearCounter(TileIndex t, uint c) { 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) -{ - _m[t].m5 = 0 << 5 | type << 2 | density; -} - -static inline uint GetFieldType(TileIndex t) { return GB(_m[t].m3, 0, 4); } -static inline void SetFieldType(TileIndex t, uint f) { SB(_m[t].m3, 0, 4, f); } - -/* Is used by tree tiles, too */ -static inline uint GetFenceSE(TileIndex t) { return GB(_m[t].m4, 2, 3); } -static inline void SetFenceSE(TileIndex t, uint h) { SB(_m[t].m4, 2, 3, h); } - -static inline uint GetFenceSW(TileIndex t) { return GB(_m[t].m4, 5, 3); } -static inline void SetFenceSW(TileIndex t, uint h) { 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; - _m[t].m5 = 0 << 5 | g << 2 | density; -} - -#endif
--- a/clear_cmd.c +++ b/clear_cmd.c @@ -2,7 +2,7 @@ #include "stdafx.h" #include "openttd.h" -#include "clear.h" +#include "clear_map.h" #include "table/strings.h" #include "functions.h" #include "map.h"
new file mode 100644 --- /dev/null +++ b/clear_map.h @@ -0,0 +1,58 @@ +/* $Id$ */ + +#ifndef CLEAR_H +#define CLEAR_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 { + CL_GRASS = 0, // 0-3 + CL_ROUGH = 1, // 3 + CL_ROCKS = 2, // 3 + CL_FIELDS = 3, // 3 + CL_SNOW = 4, // 0-3 + CL_DESERT = 5 // 1,3 +} ClearGround; + +static inline ClearGround GetClearGround(TileIndex t) { return GB(_m[t].m5, 2, 3); } +static inline bool IsClearGround(TileIndex t, ClearGround ct) { return GetClearGround(t) == ct; } + +static inline void AddClearDensity(TileIndex t, int d) { _m[t].m5 += d; } +static inline uint GetClearDensity(TileIndex t) { return GB(_m[t].m5, 0, 2); } + +static inline void AddClearCounter(TileIndex t, int c) { _m[t].m5 += c << 5; } +static inline uint GetClearCounter(TileIndex t) { return GB(_m[t].m5, 5, 3); } +static inline void SetClearCounter(TileIndex t, uint c) { 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) +{ + _m[t].m5 = 0 << 5 | type << 2 | density; +} + +static inline uint GetFieldType(TileIndex t) { return GB(_m[t].m3, 0, 4); } +static inline void SetFieldType(TileIndex t, uint f) { SB(_m[t].m3, 0, 4, f); } + +/* Is used by tree tiles, too */ +static inline uint GetFenceSE(TileIndex t) { return GB(_m[t].m4, 2, 3); } +static inline void SetFenceSE(TileIndex t, uint h) { SB(_m[t].m4, 2, 3, h); } + +static inline uint GetFenceSW(TileIndex t) { return GB(_m[t].m4, 5, 3); } +static inline void SetFenceSW(TileIndex t, uint h) { 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; + _m[t].m5 = 0 << 5 | g << 2 | density; +} + +#endif
--- a/industry_cmd.c +++ b/industry_cmd.c @@ -2,7 +2,7 @@ #include "stdafx.h" #include "openttd.h" -#include "clear.h" +#include "clear_map.h" #include "table/strings.h" #include "table/sprites.h" #include "functions.h"
--- a/landscape.c +++ b/landscape.c @@ -2,7 +2,7 @@ #include "stdafx.h" #include "openttd.h" -#include "clear.h" +#include "clear_map.h" #include "functions.h" #include "map.h" #include "player.h" @@ -14,7 +14,7 @@ #include "command.h" #include "vehicle.h" #include "variables.h" -#include "void.h" +#include "void_map.h" #include "water_map.h" extern const TileTypeProcs
--- a/openttd.c +++ b/openttd.c @@ -9,7 +9,7 @@ #include "strings.h" #include "map.h" #include "tile.h" -#include "void.h" +#include "void_map.h" #define VARDEF #include "openttd.h"
--- a/order_gui.c +++ b/order_gui.c @@ -2,7 +2,7 @@ #include "stdafx.h" #include "openttd.h" -#include "road.h" +#include "road_map.h" #include "table/sprites.h" #include "table/strings.h" #include "functions.h"
--- a/rail_cmd.c +++ b/rail_cmd.c @@ -5,7 +5,7 @@ #include "debug.h" #include "functions.h" #include "rail_map.h" -#include "road.h" +#include "road_map.h" #include "table/sprites.h" #include "table/strings.h" #include "map.h"
deleted file mode 100644 --- a/road.h +++ /dev/null @@ -1,85 +0,0 @@ -/* $Id$ */ - -#ifndef ROAD_H -#define ROAD_H - -#include "macros.h" -#include "rail.h" -#include "tile.h" - -typedef enum RoadBits { - ROAD_NW = 1, - ROAD_SW = 2, - ROAD_SE = 4, - ROAD_NE = 8, - ROAD_X = ROAD_SW | ROAD_NE, - ROAD_Y = ROAD_NW | ROAD_SE, - ROAD_ALL = ROAD_X | ROAD_Y -} RoadBits; - -static inline RoadBits ComplementRoadBits(RoadBits r) -{ - return ROAD_ALL ^ r; -} - -static inline RoadBits GetRoadBits(TileIndex tile) -{ - return GB(_m[tile].m5, 0, 4); -} - -static inline RoadBits GetCrossingRoadBits(TileIndex tile) -{ - return _m[tile].m5 & 8 ? ROAD_Y : ROAD_X; -} - -static inline TrackBits GetCrossingRailBits(TileIndex tile) -{ - return _m[tile].m5 & 8 ? TRACK_BIT_X : TRACK_BIT_Y; -} - - -typedef enum RoadType { - ROAD_NORMAL, - ROAD_CROSSING, - ROAD_DEPOT -} RoadType; - -static inline RoadType GetRoadType(TileIndex tile) -{ - return GB(_m[tile].m5, 4, 4); -} - - -static inline void MakeRoadNormal(TileIndex t, Owner owner, RoadBits bits, uint town) -{ - SetTileType(t, MP_STREET); - SetTileOwner(t, owner); - _m[t].m2 = town; - _m[t].m3 = 0; - _m[t].m4 = 0 << 7 | 0 << 4 | 0; - _m[t].m5 = ROAD_NORMAL << 4 | bits; -} - - -static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner rail, Axis roaddir, RailType rt, uint town) -{ - SetTileType(t, MP_STREET); - SetTileOwner(t, rail); - _m[t].m2 = town; - _m[t].m3 = road; - _m[t].m4 = 0 << 7 | 0 << 4 | rt; - _m[t].m5 = ROAD_CROSSING << 4 | roaddir << 3 | 0 << 2; -} - - -static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir) -{ - SetTileType(t, MP_STREET); - SetTileOwner(t, owner); - _m[t].m2 = 0; - _m[t].m3 = 0; - _m[t].m4 = 0; - _m[t].m5 = ROAD_DEPOT << 4 | dir; -} - -#endif
--- a/road_cmd.c +++ b/road_cmd.c @@ -3,7 +3,7 @@ #include "stdafx.h" #include "openttd.h" #include "rail_map.h" -#include "road.h" +#include "road_map.h" #include "table/sprites.h" #include "table/strings.h" #include "functions.h"
new file mode 100644 --- /dev/null +++ b/road_map.h @@ -0,0 +1,85 @@ +/* $Id$ */ + +#ifndef ROAD_H +#define ROAD_H + +#include "macros.h" +#include "rail.h" +#include "tile.h" + +typedef enum RoadBits { + ROAD_NW = 1, + ROAD_SW = 2, + ROAD_SE = 4, + ROAD_NE = 8, + ROAD_X = ROAD_SW | ROAD_NE, + ROAD_Y = ROAD_NW | ROAD_SE, + ROAD_ALL = ROAD_X | ROAD_Y +} RoadBits; + +static inline RoadBits ComplementRoadBits(RoadBits r) +{ + return ROAD_ALL ^ r; +} + +static inline RoadBits GetRoadBits(TileIndex tile) +{ + return GB(_m[tile].m5, 0, 4); +} + +static inline RoadBits GetCrossingRoadBits(TileIndex tile) +{ + return _m[tile].m5 & 8 ? ROAD_Y : ROAD_X; +} + +static inline TrackBits GetCrossingRailBits(TileIndex tile) +{ + return _m[tile].m5 & 8 ? TRACK_BIT_X : TRACK_BIT_Y; +} + + +typedef enum RoadType { + ROAD_NORMAL, + ROAD_CROSSING, + ROAD_DEPOT +} RoadType; + +static inline RoadType GetRoadType(TileIndex tile) +{ + return GB(_m[tile].m5, 4, 4); +} + + +static inline void MakeRoadNormal(TileIndex t, Owner owner, RoadBits bits, uint town) +{ + SetTileType(t, MP_STREET); + SetTileOwner(t, owner); + _m[t].m2 = town; + _m[t].m3 = 0; + _m[t].m4 = 0 << 7 | 0 << 4 | 0; + _m[t].m5 = ROAD_NORMAL << 4 | bits; +} + + +static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner rail, Axis roaddir, RailType rt, uint town) +{ + SetTileType(t, MP_STREET); + SetTileOwner(t, rail); + _m[t].m2 = town; + _m[t].m3 = road; + _m[t].m4 = 0 << 7 | 0 << 4 | rt; + _m[t].m5 = ROAD_CROSSING << 4 | roaddir << 3 | 0 << 2; +} + + +static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir) +{ + SetTileType(t, MP_STREET); + SetTileOwner(t, owner); + _m[t].m2 = 0; + _m[t].m3 = 0; + _m[t].m4 = 0; + _m[t].m5 = ROAD_DEPOT << 4 | dir; +} + +#endif
--- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -4,7 +4,7 @@ #include "openttd.h" #include "debug.h" #include "functions.h" -#include "road.h" +#include "road_map.h" #include "table/strings.h" #include "map.h" #include "tile.h"
--- a/smallmap_gui.c +++ b/smallmap_gui.c @@ -2,7 +2,7 @@ #include "stdafx.h" #include "openttd.h" -#include "clear.h" +#include "clear_map.h" #include "functions.h" #include "spritecache.h" #include "table/strings.h" @@ -10,7 +10,7 @@ #include "map.h" #include "tile.h" #include "gui.h" -#include "tree.h" +#include "tree_map.h" #include "window.h" #include "gfx.h" #include "viewport.h"
--- a/terraform_gui.c +++ b/terraform_gui.c @@ -2,7 +2,7 @@ #include "stdafx.h" #include "openttd.h" -#include "clear.h" +#include "clear_map.h" #include "table/sprites.h" #include "table/strings.h" #include "functions.h"
--- a/town_cmd.c +++ b/town_cmd.c @@ -4,7 +4,7 @@ #include "openttd.h" #include "functions.h" #include "strings.h" -#include "road.h" +#include "road_map.h" #include "table/strings.h" #include "table/sprites.h" #include "map.h"
deleted file mode 100644 --- a/tree.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $Id$ */ - -#ifndef TREE_H -#define TREE_H - -#include "macros.h" - -typedef enum TreeType { - TR_INVALID = -1, - TR_TEMPERATE = 0, - TR_SUB_ARCTIC = 12, - TR_RAINFOREST = 20, - TR_CACTUS = 27, - TR_SUB_TROPICAL = 28, - TR_TOYLAND = 32 -} TreeType; - -enum { - TR_COUNT_TEMPERATE = TR_SUB_ARCTIC - TR_TEMPERATE, - TR_COUNT_SUB_ARCTIC = TR_RAINFOREST - TR_SUB_ARCTIC, - TR_COUNT_RAINFOREST = TR_CACTUS - TR_RAINFOREST, - TR_COUNT_SUB_TROPICAL = TR_SUB_TROPICAL - TR_CACTUS, - TR_COUNT_TOYLAND = 9 -}; - -/* ground type, m2 bits 4...5 - * valid densities (bits 6...7) in comments after the enum */ -typedef enum TreeGround { - TR_GRASS = 0, // 0 - TR_ROUGH = 1, // 0 - TR_SNOW_DESERT = 2 // 0-3 for snow, 3 for desert -} TreeGround; - -static inline TreeType GetTreeType(TileIndex t) { return _m[t].m3; } -static inline void SetTreeType(TileIndex t, TreeType r) { _m[t].m3 = r; } - -static inline TreeGround GetTreeGround(TileIndex t) { return GB(_m[t].m2, 4, 2); } - -static inline uint GetTreeDensity(TileIndex t) { return GB(_m[t].m2, 6, 2); } - -static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d) -{ - SB(_m[t].m2, 4, 2, g); - SB(_m[t].m2, 6, 2, d); -} - -static inline void AddTreeCount(TileIndex t, int c) { _m[t].m5 += c << 6; } -static inline uint GetTreeCount(TileIndex t) { return GB(_m[t].m5, 6, 2); } -static inline void SetTreeCount(TileIndex t, uint c) { SB(_m[t].m5, 6, 2, c); } - -static inline void AddTreeGrowth(TileIndex t, int a) { _m[t].m5 += a; } -static inline uint GetTreeGrowth(TileIndex t) { return GB(_m[t].m5, 0, 3); } -static inline void SetTreeGrowth(TileIndex t, uint g) { SB(_m[t].m5, 0, 3, g); } - -static inline void AddTreeCounter(TileIndex t, int a) { _m[t].m2 += a; } -static inline uint GetTreeCounter(TileIndex t) { return GB(_m[t].m2, 0, 4); } -static inline void SetTreeCounter(TileIndex t, uint c) { SB(_m[t].m2, 0, 4, c); } - - -static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density) -{ - SetTileType(t, MP_TREES); - SetTileOwner(t, OWNER_NONE); - _m[t].m2 = density << 6 | ground << 4 | 0; - _m[t].m3 = type; - _m[t].m4 = 0 << 5 | 0 << 2; - _m[t].m5 = count << 6 | growth; -} - -#endif
--- a/tree_cmd.c +++ b/tree_cmd.c @@ -2,14 +2,14 @@ #include "stdafx.h" #include "openttd.h" -#include "clear.h" +#include "clear_map.h" #include "table/strings.h" #include "table/sprites.h" #include "table/tree_land.h" #include "functions.h" #include "map.h" #include "tile.h" -#include "tree.h" +#include "tree_map.h" #include "viewport.h" #include "command.h" #include "town.h"
new file mode 100644 --- /dev/null +++ b/tree_map.h @@ -0,0 +1,70 @@ +/* $Id$ */ + +#ifndef TREE_H +#define TREE_H + +#include "macros.h" + +typedef enum TreeType { + TR_INVALID = -1, + TR_TEMPERATE = 0, + TR_SUB_ARCTIC = 12, + TR_RAINFOREST = 20, + TR_CACTUS = 27, + TR_SUB_TROPICAL = 28, + TR_TOYLAND = 32 +} TreeType; + +enum { + TR_COUNT_TEMPERATE = TR_SUB_ARCTIC - TR_TEMPERATE, + TR_COUNT_SUB_ARCTIC = TR_RAINFOREST - TR_SUB_ARCTIC, + TR_COUNT_RAINFOREST = TR_CACTUS - TR_RAINFOREST, + TR_COUNT_SUB_TROPICAL = TR_SUB_TROPICAL - TR_CACTUS, + TR_COUNT_TOYLAND = 9 +}; + +/* ground type, m2 bits 4...5 + * valid densities (bits 6...7) in comments after the enum */ +typedef enum TreeGround { + TR_GRASS = 0, // 0 + TR_ROUGH = 1, // 0 + TR_SNOW_DESERT = 2 // 0-3 for snow, 3 for desert +} TreeGround; + +static inline TreeType GetTreeType(TileIndex t) { return _m[t].m3; } +static inline void SetTreeType(TileIndex t, TreeType r) { _m[t].m3 = r; } + +static inline TreeGround GetTreeGround(TileIndex t) { return GB(_m[t].m2, 4, 2); } + +static inline uint GetTreeDensity(TileIndex t) { return GB(_m[t].m2, 6, 2); } + +static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d) +{ + SB(_m[t].m2, 4, 2, g); + SB(_m[t].m2, 6, 2, d); +} + +static inline void AddTreeCount(TileIndex t, int c) { _m[t].m5 += c << 6; } +static inline uint GetTreeCount(TileIndex t) { return GB(_m[t].m5, 6, 2); } +static inline void SetTreeCount(TileIndex t, uint c) { SB(_m[t].m5, 6, 2, c); } + +static inline void AddTreeGrowth(TileIndex t, int a) { _m[t].m5 += a; } +static inline uint GetTreeGrowth(TileIndex t) { return GB(_m[t].m5, 0, 3); } +static inline void SetTreeGrowth(TileIndex t, uint g) { SB(_m[t].m5, 0, 3, g); } + +static inline void AddTreeCounter(TileIndex t, int a) { _m[t].m2 += a; } +static inline uint GetTreeCounter(TileIndex t) { return GB(_m[t].m2, 0, 4); } +static inline void SetTreeCounter(TileIndex t, uint c) { SB(_m[t].m2, 0, 4, c); } + + +static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density) +{ + SetTileType(t, MP_TREES); + SetTileOwner(t, OWNER_NONE); + _m[t].m2 = density << 6 | ground << 4 | 0; + _m[t].m3 = type; + _m[t].m4 = 0 << 5 | 0 << 2; + _m[t].m5 = count << 6 | growth; +} + +#endif
--- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -7,7 +7,7 @@ #include "stdafx.h" #include "openttd.h" -#include "road.h" +#include "road_map.h" #include "table/sprites.h" #include "table/strings.h" #include "functions.h"