mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations.
This commit is contained in:
parent
d5c4ba8246
commit
01e20c9140
@ -7,11 +7,10 @@
|
||||
#include "debug.h"
|
||||
#include "map.h"
|
||||
#include "airport.h"
|
||||
#include "macros.h"
|
||||
#include "variables.h"
|
||||
#include "airport_movement.h"
|
||||
#include "date.h"
|
||||
#include "helpers.hpp"
|
||||
#include "core/bitmath_func.hpp"
|
||||
|
||||
/* Uncomment this to print out a full report of the airport-structure
|
||||
* You should either use
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define BLITTER_32BPP_BASE_HPP
|
||||
|
||||
#include "base.hpp"
|
||||
#include "../core/bitmath_func.hpp"
|
||||
|
||||
class Blitter_32bppBase : public Blitter {
|
||||
public:
|
||||
|
@ -6,8 +6,7 @@
|
||||
#include "openttd.h"
|
||||
#include "gfx.h"
|
||||
#include "bmp.h"
|
||||
#include "macros.h"
|
||||
#include "helpers.hpp"
|
||||
#include "core/bitmath_func.hpp"
|
||||
|
||||
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file)
|
||||
{
|
||||
|
@ -6,7 +6,6 @@
|
||||
#define BRIDGE_MAP_H
|
||||
|
||||
#include "direction_func.h"
|
||||
#include "macros.h"
|
||||
#include "map.h"
|
||||
#include "rail_type.h"
|
||||
#include "road_map.h"
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "macros.h"
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
#include "newgrf_cargo.h"
|
||||
#include "cargotype.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
|
||||
#include "table/cargo_const.h"
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#ifndef CLEAR_MAP_H
|
||||
#define CLEAR_MAP_H
|
||||
|
||||
#include "macros.h"
|
||||
#include "bridge_map.h"
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,6 @@
|
||||
#define CMD_HELPER_H
|
||||
|
||||
#include "direction_type.h"
|
||||
#include "macros.h"
|
||||
#include "road_type.h"
|
||||
|
||||
|
||||
|
@ -276,4 +276,19 @@ template<typename T> static inline T ROR(const T x, const uint8 n)
|
||||
return (T)(x >> n | x << (sizeof(x) * 8 - n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Do an operation for each set set bit in a value.
|
||||
*
|
||||
* This macros is used to do an operation for each set
|
||||
* bit in a variable. The first variable can be reused
|
||||
* in the operation due to it's the bit position counter.
|
||||
* The second variable will be cleared during the usage
|
||||
*
|
||||
* @param i The position counter
|
||||
* @param b The value which we check for set bits
|
||||
*/
|
||||
#define FOR_EACH_SET_BIT(i, b) \
|
||||
for (i = 0; b != 0; i++, b >>= 1) \
|
||||
if (b & 1)
|
||||
|
||||
#endif /* BITMATH_FUNC_HPP */
|
||||
|
22
src/core/endian_func.hpp
Normal file
22
src/core/endian_func.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file endian_func.hpp */
|
||||
|
||||
#ifndef ENDIAN_FUNC_H
|
||||
#define ENDIAN_FUNC_H
|
||||
|
||||
static inline uint16 ReadLE16Aligned(const void *x)
|
||||
{
|
||||
return FROM_LE16(*(const uint16*)x);
|
||||
}
|
||||
|
||||
static inline uint16 ReadLE16Unaligned(const void *x)
|
||||
{
|
||||
#ifdef OTTD_ALIGNMENT
|
||||
return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
|
||||
#else
|
||||
return FROM_LE16(*(const uint16*)x);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ENDIAN_FUNC_H */
|
@ -17,6 +17,12 @@
|
||||
#undef abs
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The largest value that can be entered in a variable
|
||||
* @param type the type of the variable
|
||||
*/
|
||||
#define MAX_UVALUE(type) ((type)~(type)0)
|
||||
|
||||
/**
|
||||
* Returns the maximum of two values.
|
||||
*
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef OVERFLOWSAFE_TYPE_HPP
|
||||
#define OVERFLOWSAFE_TYPE_HPP
|
||||
|
||||
#include "math_func.hpp"
|
||||
|
||||
/**
|
||||
* Overflow safe template for integers, i.e. integers that will never overflow
|
||||
* you multiply the maximum value with 2, or add 2, or substract somethng from
|
||||
|
@ -3,9 +3,9 @@
|
||||
/** @file random_func.cpp */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../macros.h"
|
||||
#include "../variables.h"
|
||||
#include "random_func.hpp"
|
||||
#include "bitmath_func.hpp"
|
||||
|
||||
uint32 InteractiveRandom()
|
||||
{
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "openttd.h"
|
||||
#include "date.h"
|
||||
#include "variables.h"
|
||||
#include "macros.h"
|
||||
#include "vehicle.h"
|
||||
#include "network/network.h"
|
||||
#include "network/network_data.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "fileio.h"
|
||||
#include "functions.h"
|
||||
#include "string.h"
|
||||
#include "macros.h"
|
||||
#include "variables.h"
|
||||
#include "debug.h"
|
||||
#include "fios.h"
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
#include "macros.h"
|
||||
#include "debug.h"
|
||||
#include "table/sprites.h"
|
||||
#include "table/control_codes.h"
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
#include "macros.h"
|
||||
#include "spritecache.h"
|
||||
#include "strings.h"
|
||||
#include "string.h"
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define GFX_H
|
||||
|
||||
#include "openttd.h"
|
||||
#include "core/math_func.hpp"
|
||||
#include "zoom.hpp"
|
||||
|
||||
enum WindowKeyCodes {
|
||||
|
@ -6,7 +6,6 @@
|
||||
#define INDUSTRY_MAP_H
|
||||
|
||||
#include "industry.h"
|
||||
#include "macros.h"
|
||||
#include "tile_map.h"
|
||||
|
||||
|
||||
|
58
src/macros.h
58
src/macros.h
@ -1,58 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file macros.h */
|
||||
|
||||
#ifndef MACROS_H
|
||||
#define MACROS_H
|
||||
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "core/math_func.hpp"
|
||||
|
||||
#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
|
||||
#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
|
||||
|
||||
/**
|
||||
* Whether a sprite comes from the original graphics files or a new grf file
|
||||
* (either supplied by OpenTTD or supplied by the user).
|
||||
*
|
||||
* @param sprite The sprite to check
|
||||
* @return True if it is a new sprite, or false if it is original.
|
||||
*/
|
||||
#define IS_CUSTOM_SPRITE(sprite) ((sprite) >= SPR_SIGNALS_BASE)
|
||||
|
||||
/**
|
||||
* Do an operation for each set set bit in a value.
|
||||
*
|
||||
* This macros is used to do an operation for each set
|
||||
* bit in a variable. The first variable can be reused
|
||||
* in the operation due to it's the bit position counter.
|
||||
* The second variable will be cleared during the usage
|
||||
*
|
||||
* @param i The position counter
|
||||
* @param b The value which we check for set bits
|
||||
*/
|
||||
#define FOR_EACH_SET_BIT(i, b) \
|
||||
for (i = 0; b != 0; i++, b >>= 1) \
|
||||
if (b & 1)
|
||||
|
||||
|
||||
static inline uint16 ReadLE16Aligned(const void* x)
|
||||
{
|
||||
return FROM_LE16(*(const uint16*)x);
|
||||
}
|
||||
|
||||
static inline uint16 ReadLE16Unaligned(const void* x)
|
||||
{
|
||||
#ifdef OTTD_ALIGNMENT
|
||||
return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
|
||||
#else
|
||||
return FROM_LE16(*(const uint16*)x);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** return the largest value that can be entered in a variable.
|
||||
*/
|
||||
#define MAX_UVALUE(type) ((type)~(type)0)
|
||||
|
||||
#endif /* MACROS_H */
|
@ -6,10 +6,10 @@
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "macros.h"
|
||||
#include "map.h"
|
||||
#include "direction_func.h"
|
||||
#include "helpers.hpp"
|
||||
#include "direction_func.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 /* VStudio 2005 is stupid! */
|
||||
/* Why the hell is that not in all MSVC headers?? */
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "fileio.h"
|
||||
#include "gfx.h"
|
||||
#include "sound.h"
|
||||
#include "macros.h"
|
||||
#include "variables.h"
|
||||
#include "music.h"
|
||||
#include "music/music_driver.hpp"
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
#include "macros.h"
|
||||
#include "namegen.h"
|
||||
#include "table/namegen.h"
|
||||
#include "string.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "../../macros.h"
|
||||
#include "../../string.h"
|
||||
#include "../../helpers.hpp"
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "../../debug.h"
|
||||
#include "../../macros.h"
|
||||
#include "../../helpers.hpp"
|
||||
#include "../../core/bitmath_func.hpp"
|
||||
#include "../../core/math_func.hpp"
|
||||
#include "packet.h"
|
||||
#include "udp.h"
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
#include "macros.h"
|
||||
#include "debug.h"
|
||||
#include "variables.h"
|
||||
#include "string.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "macros.h"
|
||||
#include "variables.h"
|
||||
#include "landscape.h"
|
||||
#include "table/strings.h"
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "variables.h"
|
||||
#include "macros.h"
|
||||
#include "landscape.h"
|
||||
#include "oldpool.h"
|
||||
#include "newgrf_callbacks.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "string.h"
|
||||
#include "strings.h"
|
||||
#include "variables.h"
|
||||
#include "macros.h"
|
||||
#include "table/strings.h"
|
||||
#include "newgrf.h"
|
||||
#include "newgrf_text.h"
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "landscape.h"
|
||||
#include "npf.h"
|
||||
#include "aystar.h"
|
||||
#include "macros.h"
|
||||
#include "pathfind.h"
|
||||
#include "station.h"
|
||||
#include "station_map.h"
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef OLDPOOL_H
|
||||
#define OLDPOOL_H
|
||||
|
||||
#include "core/math_func.hpp"
|
||||
|
||||
/* The function that is called after a new block is added
|
||||
start_item is the first item of the new made block */
|
||||
typedef void OldMemoryPoolNewBlock(uint start_item);
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define VARDEF extern
|
||||
#endif
|
||||
|
||||
#include "macros.h"
|
||||
#include "helpers.hpp"
|
||||
|
||||
struct Oblong {
|
||||
|
@ -5,8 +5,8 @@
|
||||
#ifndef ORDER_H
|
||||
#define ORDER_H
|
||||
|
||||
#include "macros.h"
|
||||
#include "oldpool.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
|
||||
enum {
|
||||
INVALID_VEH_ORDER_ID = 0xFF,
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "gfx.h"
|
||||
#include "rail_type.h"
|
||||
#include "track_type.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "variables.h"
|
||||
|
||||
/** This struct contains all the info that is needed to draw and construct tracks.
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "road_map.h"
|
||||
#include "road_internal.h"
|
||||
#include "water_map.h"
|
||||
#include "macros.h"
|
||||
|
||||
bool IsPossibleCrossing(const TileIndex tile, Axis ax)
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef ROAD_FUNC_H
|
||||
#define ROAD_FUNC_H
|
||||
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "road_type.h"
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,6 @@
|
||||
#ifndef ROAD_MAP_H
|
||||
#define ROAD_MAP_H
|
||||
|
||||
#include "macros.h"
|
||||
#include "track_func.h"
|
||||
#include "rail_type.h"
|
||||
#include "road_func.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "openttd.h"
|
||||
#include "currency.h"
|
||||
#include "functions.h"
|
||||
#include "macros.h"
|
||||
#include "screenshot.h"
|
||||
#include "sound.h"
|
||||
#include "string.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef SLOPE_FUNC_H
|
||||
#define SLOPE_FUNC_H
|
||||
|
||||
#include "core/math_func.hpp"
|
||||
#include "slope_type.h"
|
||||
#include "direction_type.h"
|
||||
|
||||
|
11
src/sprite.h
11
src/sprite.h
@ -5,6 +5,17 @@
|
||||
#ifndef SPRITE_H
|
||||
#define SPRITE_H
|
||||
|
||||
#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
|
||||
#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
|
||||
|
||||
/**
|
||||
* Whether a sprite comes from the original graphics files or a new grf file
|
||||
* (either supplied by OpenTTD or supplied by the user).
|
||||
*
|
||||
* @param sprite The sprite to check
|
||||
* @return True if it is a new sprite, or false if it is original.
|
||||
*/
|
||||
#define IS_CUSTOM_SPRITE(sprite) ((sprite) >= SPR_SIGNALS_BASE)
|
||||
|
||||
/* The following describes bunch of sprites to be drawn together in a single 3D
|
||||
* bounding box. Used especially for various multi-sprite buildings (like
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "string.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "macros.h"
|
||||
#include "spritecache.h"
|
||||
#include "table/sprites.h"
|
||||
#include "fileio.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
#include "string.h"
|
||||
#include "macros.h"
|
||||
#include "table/control_codes.h"
|
||||
#include "helpers.hpp"
|
||||
#include "debug.h"
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef STRING_H
|
||||
#define STRING_H
|
||||
|
||||
#include "macros.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
|
||||
/**
|
||||
* usage ttd_strlcpy(dst, src, lengthof(dst));
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
#include "macros.h"
|
||||
#include "strings.h"
|
||||
#include "gfx.h"
|
||||
#include "landscape.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "tile_map.h"
|
||||
#include "core/math_func.hpp"
|
||||
|
||||
Slope GetTileSlope(TileIndex tile, uint *h)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "tile_type.h"
|
||||
#include "slope_type.h"
|
||||
#include "map.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
|
||||
/**
|
||||
* Returns the height of a tile
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef TRACK_FUNC_H
|
||||
#define TRACK_FUNC_H
|
||||
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "track_type.h"
|
||||
#include "direction_type.h"
|
||||
#include "slope_func.h"
|
||||
|
@ -5,8 +5,6 @@
|
||||
#ifndef TREE_MAP_H
|
||||
#define TREE_MAP_H
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
/**
|
||||
* List of tree types along all landscape types.
|
||||
*
|
||||
|
@ -6,7 +6,6 @@
|
||||
#define TUNNEL_MAP_H
|
||||
|
||||
#include "direction_func.h"
|
||||
#include "macros.h"
|
||||
#include "map.h"
|
||||
#include "rail_type.h"
|
||||
#include "road_type.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "../debug.h"
|
||||
#include "../functions.h"
|
||||
#include "../gfx.h"
|
||||
#include "../macros.h"
|
||||
#include "../sdl.h"
|
||||
#include "../variables.h"
|
||||
#include "../blitter/factory.hpp"
|
||||
|
@ -5,7 +5,6 @@
|
||||
#ifndef WINDOW_GUI_H
|
||||
#define WINDOW_GUI_H
|
||||
|
||||
#include "macros.h"
|
||||
#include "string.h"
|
||||
#include "order.h"
|
||||
#include "rail_type.h"
|
||||
|
Loading…
Reference in New Issue
Block a user