2005-07-24 16:12:37 +02:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-03-03 05:04:22 +01:00
|
|
|
/** @file macros.h */
|
|
|
|
|
2004-08-09 19:04:08 +02:00
|
|
|
#ifndef MACROS_H
|
|
|
|
#define MACROS_H
|
|
|
|
|
2007-11-26 18:50:22 +01:00
|
|
|
#include "core/bitmath_func.hpp"
|
2007-11-22 19:01:51 +01:00
|
|
|
#include "core/math_func.hpp"
|
|
|
|
|
2007-01-14 20:57:49 +01:00
|
|
|
#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
|
|
|
|
#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2007-09-23 12:54:11 +02:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
|
2007-12-03 10:19:19 +01:00
|
|
|
/**
|
|
|
|
* 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)
|
2004-08-09 19:04:08 +02:00
|
|
|
|
|
|
|
|
2006-02-03 22:51:42 +01:00
|
|
|
static inline uint16 ReadLE16Aligned(const void* x)
|
|
|
|
{
|
|
|
|
return FROM_LE16(*(const uint16*)x);
|
|
|
|
}
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2006-02-03 22:51:42 +01:00
|
|
|
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);
|
2004-08-09 19:04:08 +02:00
|
|
|
#endif
|
2006-02-03 22:51:42 +01:00
|
|
|
}
|
|
|
|
|
2004-08-09 19:04:08 +02:00
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
/** return the largest value that can be entered in a variable.
|
|
|
|
*/
|
|
|
|
#define MAX_UVALUE(type) ((type)~(type)0)
|
|
|
|
|
2004-08-09 19:04:08 +02:00
|
|
|
#endif /* MACROS_H */
|