summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--economy.c6
-rw-r--r--macros.h19
-rw-r--r--map.h1
-rw-r--r--tile.h8
-rw-r--r--train_cmd.c2
-rw-r--r--vehicle.c2
6 files changed, 13 insertions, 25 deletions
diff --git a/economy.c b/economy.c
index 66aaff6f2..8e61855a4 100644
--- a/economy.c
+++ b/economy.c
@@ -123,7 +123,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
/* Count vehicles */
{
Vehicle *v;
- int32 min_profit = MAX_INT;
+ int32 min_profit = 0;
uint num = 0;
FOR_ALL_VEHICLES(v) {
@@ -142,9 +142,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
}
_score_part[owner][SCORE_VEHICLES] = num;
-
- if (min_profit != MAX_INT && min_profit > 0)
- _score_part[owner][SCORE_MIN_PROFIT] = min_profit;
+ _score_part[owner][SCORE_MIN_PROFIT] = min_profit;
}
/* Count stations */
diff --git a/macros.h b/macros.h
index 363eb84d0..7a239c0eb 100644
--- a/macros.h
+++ b/macros.h
@@ -3,8 +3,6 @@
#include "map.h"
-#define MAX_INT 0x7FFFFFFF
-
#ifdef min
#undef min
#endif
@@ -48,21 +46,6 @@ static inline int64 BIGMULS(int32 a, int32 b) {
#define IS_INSIDE_1D(x, base, size) ( (uint)((x) - (base)) < ((uint)(size)) )
-enum {
- CORRECT_Z_BITS = 1 << 1 | 1 << 2 | 1 << 3 | 1 << 4 | 1 << 5 | 1 << 6 | 1 << 7
-};
-#define CORRECT_Z(tileh) (CORRECT_Z_BITS & (1 << tileh))
-
-#define TILE_ASSERT(x) assert( TILE_MASK(x) == (x) );
-
-//#define REMADP_COORDS(x,y,z) { int t = x; x = (y-t)*2; y+=t-z; }
-
-#define PACK_POINT(x,y) ((x) | ((y) << 16))
-#define UNPACK_POINT_X(p) ((uint16)(p))
-#define UNPACK_POINT_Y(p) ((uint16)(p>>16))
-
-#define PACK_PPOINT(p) PACK_POINT((p).x, (p).y)
-
#define HASBIT(x,y) ((x) & (1 << (y)))
#define SETBIT(x,y) ((x) |= (1 << (y)))
#define CLRBIT(x,y) ((x) &= ~(1 << (y)))
@@ -178,6 +161,4 @@ static inline void WRITE_LE_UINT16(void *b, uint16 x) {
((byte*)b)[1] = (byte)(x >> 8);
}
-#define MAX_DETOUR 6
-
#endif /* MACROS_H */
diff --git a/map.h b/map.h
index f9cff89e2..5e5b395e1 100644
--- a/map.h
+++ b/map.h
@@ -7,6 +7,7 @@
#define TILE_XY(x,y) (((y) << MapLogX()) + (x))
#define TILE_MASK(x) ((x) & ((1 << (MapLogX() + MapLogY())) - 1))
+#define TILE_ASSERT(x) assert(TILE_MASK(x) == (x));
extern byte *_map_type_and_height;
extern byte *_map_owner;
diff --git a/tile.h b/tile.h
index cb0fa1e03..3752ed29f 100644
--- a/tile.h
+++ b/tile.h
@@ -1,6 +1,7 @@
#ifndef TILE_H
#define TILE_H
+#include "macros.h"
#include "map.h"
typedef enum TileType {
@@ -23,6 +24,13 @@ uint GetMapExtraBits(TileIndex tile);
uint GetTileSlope(TileIndex tile, uint *h);
uint GetTileZ(TileIndex tile);
+static inline bool CorrectZ(uint tileh)
+{
+ /* tile height must be corrected if the north corner is not raised, but
+ * any other corner is. These are the cases 1 till 7 */
+ return IS_INT_INSIDE(tileh, 1, 8);
+}
+
static inline uint TileHeight(TileIndex tile)
{
assert(tile < MapSize());
diff --git a/train_cmd.c b/train_cmd.c
index d59fd30e9..d90594377 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -2189,7 +2189,7 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
uint tileh = GetTileSlope(tile, &height);
// correct Z position of a train going under a bridge on slopes
- if (CORRECT_Z(tileh)) height += 8;
+ if (CorrectZ(tileh)) height += 8;
if (v->z_pos != height) return true; // train is going over bridge
}
diff --git a/vehicle.c b/vehicle.c
index 2880310a5..1fdbd670c 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -98,7 +98,7 @@ static inline uint Correct_Z(uint tileh)
{
// needs z correction for slope-type graphics that have the NORTHERN tile lowered
// 1, 2, 3, 4, 5, 6 and 7
- return (CORRECT_Z(tileh)) ? 8 : 0;
+ return CorrectZ(tileh) ? 8 : 0;
}
uint GetCorrectTileHeight(TileIndex tile)