clear.h
author Darkvater
Thu, 02 Mar 2006 02:22:15 +0000
changeset 3121 2e50f731567a
parent 3076 9584f34a83dc
permissions -rw-r--r--
(svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
- Remove the temporary synchronisation in during the map-transfer as this is no longer needed
- The saved patches work just like the saved gameoptions. You have a _patches and a _patches_newgame struct. The _patches_newgame struct contains the values from the configuration file and thus the defaults for new games. When a new game is started or an older game is loaded, the default values are copied over to _patches to be used. When you load a game that has PATS saved, the default values are also loaded, but immediately overwritten by the values from the savegame. This ensures that player-based values are always taken from your personal preferences.
- The current implementation also changes the default values if you change player-based settings in the game. For example changing window_snap_radius in a certain game will also change it for all next OpenTTD sessions.
- The savegame version has been increased to 22.
- The last 6 orso patches close the following reports:
[ 1366446 ] different names for patches: all patch settings have the same name as in the configuration file and are reachable from the console.
[ 1288024 ] Strange string on OTTD initial screen: configuration (and this includes patches) inputs are validated and clamped to their minimum/maximum values.
[ 1423198 ] Make "Signals on Drive side" player, not server, based: this is only visual so current setting is to save it with the savegame but not synchronise in multiplayer.
[ 1208070 ] Patches and New GRF options saved: apart from newgrf this is done
2955
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
     1
/* $Id$ */
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
     2
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
     3
#ifndef CLEAR_H
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
     4
#define CLEAR_H
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
     5
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
     6
#include "macros.h"
3076
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
     7
#include "tile.h"
2955
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
     8
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
     9
/* ground type, m5 bits 2...4
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    10
 * valid densities (bits 0...1) in comments after the enum
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    11
 */
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    12
typedef enum ClearGround {
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    13
	CL_GRASS  = 0, // 0-3
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    14
	CL_ROUGH  = 1, // 3
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    15
	CL_ROCKS  = 2, // 3
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    16
	CL_FIELDS = 3, // 3
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    17
	CL_SNOW   = 4, // 0-3
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    18
	CL_DESERT = 5  // 1,3
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    19
} ClearGround;
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    20
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    21
static inline ClearGround GetClearGround(TileIndex t) { return GB(_m[t].m5, 2, 3); }
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    22
static inline bool IsClearGround(TileIndex t, ClearGround ct) { return GetClearGround(t) == ct; }
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    23
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    24
static inline void AddClearDensity(TileIndex t, int d) { _m[t].m5 += d; }
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    25
static inline uint GetClearDensity(TileIndex t) { return GB(_m[t].m5, 0, 2); }
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    26
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    27
static inline void AddClearCounter(TileIndex t, int c) { _m[t].m5 += c << 5; }
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    28
static inline uint GetClearCounter(TileIndex t) { return GB(_m[t].m5, 5, 3); }
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    29
static inline void SetClearCounter(TileIndex t, uint c) { SB(_m[t].m5, 5, 3, c); }
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    30
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    31
/* Sets type and density in one go, also sets the counter to 0 */
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    32
static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    33
{
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    34
	_m[t].m5 = 0 << 5 | type << 2 | density;
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    35
}
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    36
2979
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    37
static inline uint GetFieldType(TileIndex t) { return GB(_m[t].m3, 0, 4); }
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    38
static inline void SetFieldType(TileIndex t, uint f) { SB(_m[t].m3, 0, 4, f); }
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    39
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    40
/* Is used by tree tiles, too */
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    41
static inline uint GetFenceSE(TileIndex t) { return GB(_m[t].m4, 2, 3); }
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    42
static inline void SetFenceSE(TileIndex t, uint h) { SB(_m[t].m4, 2, 3, h); }
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    43
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    44
static inline uint GetFenceSW(TileIndex t) { return GB(_m[t].m4, 5, 3); }
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    45
static inline void SetFenceSW(TileIndex t, uint h) { SB(_m[t].m4, 5, 3, h); }
883788245931 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    46
3076
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    47
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    48
static inline void MakeClear(TileIndex t, ClearGround g, uint density)
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    49
{
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    50
	SetTileType(t, MP_CLEAR);
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    51
	SetTileOwner(t, OWNER_NONE);
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    52
	_m[t].m2 = 0;
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    53
	_m[t].m3 = 0;
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    54
	_m[t].m4 = 0 << 5 | 0 << 2;
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    55
	_m[t].m5 = 0 << 5 | g << 2 | density;
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    56
}
9584f34a83dc (svn r3665) Add a function to turn a tile into a clear tile
tron
parents: 2979
diff changeset
    57
2955
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff changeset
    58
#endif