mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
(svn r11851) -Codechange: A few magic numbers removal, plus a little code style
This commit is contained in:
parent
ea808b2bfa
commit
e789ee83ab
@ -297,10 +297,11 @@ enum IndustryTileCallbackMask {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result of a failed callback.
|
* Different values for Callback result evaluations
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
CALLBACK_FAILED = 0xFFFF
|
CALLBACK_FAILED = 0xFFFF, ///< Result of a failed callback.
|
||||||
|
CALLBACK_HOUSEPRODCARGO_END = 0x20FF, ///< Sentinel indicating that the loop for CBID_HOUSE_PRODUCE_CARGO has ended
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* NEWGRF_CALLBACKS_H */
|
#endif /* NEWGRF_CALLBACKS_H */
|
||||||
|
@ -435,8 +435,7 @@ static void TileLoop_Town(TileIndex tile)
|
|||||||
for (uint i = 0; i < 256; i++) {
|
for (uint i = 0; i < 256; i++) {
|
||||||
uint16 callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, r, house_id, t, tile);
|
uint16 callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, r, house_id, t, tile);
|
||||||
|
|
||||||
if (callback == CALLBACK_FAILED) break;
|
if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break;
|
||||||
if (callback == 0x20FF) break;
|
|
||||||
|
|
||||||
CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile);
|
CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile);
|
||||||
if (cargo == CT_INVALID) continue;
|
if (cargo == CT_INVALID) continue;
|
||||||
@ -1604,9 +1603,9 @@ static bool CheckBuildHouseMode(TileIndex tile, Slope tileh, int mode)
|
|||||||
int b;
|
int b;
|
||||||
Slope slope;
|
Slope slope;
|
||||||
|
|
||||||
static const byte _masks[8] = {
|
static const Slope _masks[8] = {
|
||||||
0xC,0x3,0x9,0x6,
|
SLOPE_NE, SLOPE_SW, SLOPE_NW, SLOPE_SE,
|
||||||
0x3,0xC,0x6,0x9,
|
SLOPE_SW, SLOPE_NE, SLOPE_SE, SLOPE_NW,
|
||||||
};
|
};
|
||||||
|
|
||||||
slope = GetTileSlope(tile, NULL);
|
slope = GetTileSlope(tile, NULL);
|
||||||
@ -1616,7 +1615,7 @@ static bool CheckBuildHouseMode(TileIndex tile, Slope tileh, int mode)
|
|||||||
|
|
||||||
b = 0;
|
b = 0;
|
||||||
if ((slope != SLOPE_FLAT && ~slope & _masks[mode])) b = ~b;
|
if ((slope != SLOPE_FLAT && ~slope & _masks[mode])) b = ~b;
|
||||||
if ((tileh != SLOPE_FLAT && ~tileh & _masks[mode+4])) b = ~b;
|
if ((tileh != SLOPE_FLAT && ~tileh & _masks[mode + 4])) b = ~b;
|
||||||
if (b)
|
if (b)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user