author | rubidium |
Sat, 29 Nov 2008 01:28:13 +0000 | |
changeset 10390 | 0c2cc4c7b91f |
parent 10311 | 44b12fe10656 |
child 10438 | 51bff16a04c9 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9009
diff
changeset
|
3 |
/** @file landscape.cpp Functions related to the landscape (slopes etc.). */ |
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9009
diff
changeset
|
4 |
|
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
5 |
/** @defgroup SnowLineGroup Snowline functions and data structures */ |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
6 |
|
0 | 7 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1793
diff
changeset
|
8 |
#include "openttd.h" |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4990
diff
changeset
|
9 |
#include "bridge_map.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
10 |
#include "heightmap.h" |
3144
33e42feae531
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3111
diff
changeset
|
11 |
#include "clear_map.h" |
1349
15979a2e9001
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
1335
diff
changeset
|
12 |
#include "spritecache.h" |
0 | 13 |
#include <stdarg.h> |
8225
cd84a95b6630
(svn r11788) -Fix (11787): makedepend doesn't mark delete files as changed...
rubidium
parents:
8151
diff
changeset
|
14 |
#include "viewport_func.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8108
diff
changeset
|
15 |
#include "command_func.h" |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
16 |
#include "landscape.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2154
diff
changeset
|
17 |
#include "variables.h" |
3144
33e42feae531
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3111
diff
changeset
|
18 |
#include "void_map.h" |
3111
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3078
diff
changeset
|
19 |
#include "water_map.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
20 |
#include "tgp.h" |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
21 |
#include "genworld.h" |
8119
52b48108425a
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8116
diff
changeset
|
22 |
#include "tile_cmd.h" |
8130
d2eb7d04f6e1
(svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents:
8119
diff
changeset
|
23 |
#include "core/alloc_func.hpp" |
8151
4cefeef74c28
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents:
8144
diff
changeset
|
24 |
#include "fios.h" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8130
diff
changeset
|
25 |
#include "window_func.h" |
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8130
diff
changeset
|
26 |
#include "functions.h" |
8140
0d0d8c94f84b
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8139
diff
changeset
|
27 |
#include "date_func.h" |
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8140
diff
changeset
|
28 |
#include "vehicle_func.h" |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8264
diff
changeset
|
29 |
#include "settings_type.h" |
8380
174326093caa
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8270
diff
changeset
|
30 |
#include "water.h" |
9009
6684576ef32b
(svn r12804) -Codechange: move the effect vehicle handling out of vehicle.cpp
rubidium
parents:
8973
diff
changeset
|
31 |
#include "effectvehicle_func.h" |
9126
5648d696456b
(svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium
parents:
9111
diff
changeset
|
32 |
#include "landscape_type.h" |
0 | 33 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
34 |
#include "table/sprites.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
35 |
|
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
36 |
extern const TileTypeProcs |
0 | 37 |
_tile_type_clear_procs, |
38 |
_tile_type_rail_procs, |
|
39 |
_tile_type_road_procs, |
|
40 |
_tile_type_town_procs, |
|
41 |
_tile_type_trees_procs, |
|
42 |
_tile_type_station_procs, |
|
43 |
_tile_type_water_procs, |
|
44 |
_tile_type_dummy_procs, |
|
45 |
_tile_type_industry_procs, |
|
46 |
_tile_type_tunnelbridge_procs, |
|
47 |
_tile_type_unmovable_procs; |
|
48 |
||
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
49 |
/** Tile callback functions for each type of tile. |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
50 |
* @ingroup TileCallbackGroup |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
51 |
* @see TileType */ |
0 | 52 |
const TileTypeProcs * const _tile_type_procs[16] = { |
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
53 |
&_tile_type_clear_procs, ///< Callback functions for MP_CLEAR tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
54 |
&_tile_type_rail_procs, ///< Callback functions for MP_RAILWAY tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
55 |
&_tile_type_road_procs, ///< Callback functions for MP_ROAD tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
56 |
&_tile_type_town_procs, ///< Callback functions for MP_HOUSE tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
57 |
&_tile_type_trees_procs, ///< Callback functions for MP_TREES tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
58 |
&_tile_type_station_procs, ///< Callback functions for MP_STATION tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
59 |
&_tile_type_water_procs, ///< Callback functions for MP_WATER tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
60 |
&_tile_type_dummy_procs, ///< Callback functions for MP_VOID tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
61 |
&_tile_type_industry_procs, ///< Callback functions for MP_INDUSTRY tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
62 |
&_tile_type_tunnelbridge_procs, ///< Callback functions for MP_TUNNELBRIDGE tiles |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
63 |
&_tile_type_unmovable_procs, ///< Callback functions for MP_UNMOVABLE tiles |
0 | 64 |
}; |
65 |
||
66 |
/* landscape slope => sprite */ |
|
67 |
const byte _tileh_to_sprite[32] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
68 |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
69 |
0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 17, 0, 15, 18, 0, |
0 | 70 |
}; |
71 |
||
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
72 |
/** |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
73 |
* Description of the snow line throughout the year. |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
74 |
* |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
75 |
* If it is \c NULL, a static snowline height is used, as set by \c _settings_game.game_creation.snow_line. |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
76 |
* Otherwise it points to a table loaded from a newGRF file, that describes the variable snowline |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
77 |
* @ingroup SnowLineGroup |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
78 |
* @see GetSnowLine() GameCreationSettings */ |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
79 |
SnowLine *_snow_line = NULL; |
1958
0266bb01a1e6
(svn r2464) Move definition of _inclined_tileh out of variables.h
tron
parents:
1902
diff
changeset
|
80 |
|
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
81 |
/** |
10233
ac41e2898d9b
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium
parents:
10207
diff
changeset
|
82 |
* Applies a foundation to a slope. |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
83 |
* |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
84 |
* @pre Foundation and slope must be valid combined. |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
85 |
* @param f The #Foundation. |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
86 |
* @param s The #Slope to modify. |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
87 |
* @return Increment to the tile Z coordinate. |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
88 |
*/ |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
89 |
uint ApplyFoundationToSlope(Foundation f, Slope *s) |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
90 |
{ |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
91 |
if (!IsFoundation(f)) return 0; |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
92 |
|
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
93 |
if (IsLeveledFoundation(f)) { |
9509
f6d513c5c7e4
(svn r13499) -Codechange: Allow drawing (ugly) leveled foundations on steep slopes, just in case someone needs them for fallback.
frosch
parents:
9413
diff
changeset
|
94 |
uint dz = TILE_HEIGHT + (IsSteepSlope(*s) ? TILE_HEIGHT : 0); |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
95 |
*s = SLOPE_FLAT; |
9509
f6d513c5c7e4
(svn r13499) -Codechange: Allow drawing (ugly) leveled foundations on steep slopes, just in case someone needs them for fallback.
frosch
parents:
9413
diff
changeset
|
96 |
return dz; |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
97 |
} |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
98 |
|
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
99 |
if (f != FOUNDATION_STEEP_BOTH && IsNonContinuousFoundation(f)) { |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
100 |
*s = HalftileSlope(*s, GetHalftileFoundationCorner(f)); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
101 |
return 0; |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
102 |
} |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
103 |
|
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
104 |
if (IsSpecialRailFoundation(f)) { |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
105 |
*s = SlopeWithThreeCornersRaised(OppositeCorner(GetRailFoundationCorner(f))); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
106 |
return 0; |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
107 |
} |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
108 |
|
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
109 |
uint dz = IsSteepSlope(*s) ? TILE_HEIGHT : 0; |
7678
8917067dde87
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7335
diff
changeset
|
110 |
Corner highest_corner = GetHighestSlopeCorner(*s); |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
111 |
|
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
112 |
switch (f) { |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
113 |
case FOUNDATION_INCLINED_X: |
7678
8917067dde87
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7335
diff
changeset
|
114 |
*s = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? SLOPE_SW : SLOPE_NE); |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
115 |
break; |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
116 |
|
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
117 |
case FOUNDATION_INCLINED_Y: |
7678
8917067dde87
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7335
diff
changeset
|
118 |
*s = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? SLOPE_SE : SLOPE_NW); |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
119 |
break; |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
120 |
|
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
121 |
case FOUNDATION_STEEP_LOWER: |
7678
8917067dde87
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7335
diff
changeset
|
122 |
*s = SlopeWithOneCornerRaised(highest_corner); |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
123 |
break; |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
124 |
|
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
125 |
case FOUNDATION_STEEP_BOTH: |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
126 |
*s = HalftileSlope(SlopeWithOneCornerRaised(highest_corner), highest_corner); |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
127 |
break; |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
128 |
|
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
129 |
default: NOT_REACHED(); |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
130 |
} |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
131 |
return dz; |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
132 |
} |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
133 |
|
0 | 134 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
135 |
/** |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
136 |
* Determines height at given coordinate of a slope |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
137 |
* @param x x coordinate |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
138 |
* @param y y coordinate |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
139 |
* @param corners slope to examine |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
140 |
* @return height of given point of given slope |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
141 |
*/ |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
142 |
uint GetPartialZ(int x, int y, Slope corners) |
0 | 143 |
{ |
7764
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
144 |
if (IsHalftileSlope(corners)) { |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
145 |
switch (GetHalftileSlopeCorner(corners)) { |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
146 |
case CORNER_W: |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
147 |
if (x - y >= 0) return GetSlopeMaxZ(corners); |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
148 |
break; |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
149 |
|
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
150 |
case CORNER_S: |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
151 |
if (x - (y ^ 0xF) >= 0) return GetSlopeMaxZ(corners); |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
152 |
break; |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
153 |
|
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
154 |
case CORNER_E: |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
155 |
if (y - x >= 0) return GetSlopeMaxZ(corners); |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
156 |
break; |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
157 |
|
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
158 |
case CORNER_N: |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
159 |
if ((y ^ 0xF) - x >= 0) return GetSlopeMaxZ(corners); |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
160 |
break; |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
161 |
|
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
162 |
default: NOT_REACHED(); |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
163 |
} |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
164 |
} |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
165 |
|
0 | 166 |
int z = 0; |
167 |
||
8413
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
168 |
switch (RemoveHalftileSlope(corners)) { |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
169 |
case SLOPE_W: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
170 |
if (x - y >= 0) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
171 |
z = (x - y) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
172 |
} |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
173 |
break; |
0 | 174 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
175 |
case SLOPE_S: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
176 |
y ^= 0xF; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
177 |
if ((x - y) >= 0) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
178 |
z = (x - y) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
179 |
} |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
180 |
break; |
0 | 181 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
182 |
case SLOPE_SW: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
183 |
z = (x >> 1) + 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
184 |
break; |
0 | 185 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
186 |
case SLOPE_E: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
187 |
if (y - x >= 0) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
188 |
z = (y - x) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
189 |
} |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
190 |
break; |
0 | 191 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
192 |
case SLOPE_EW: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
193 |
case SLOPE_NS: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
194 |
case SLOPE_ELEVATED: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
195 |
z = 4; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
196 |
break; |
0 | 197 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
198 |
case SLOPE_SE: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
199 |
z = (y >> 1) + 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
200 |
break; |
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
201 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
202 |
case SLOPE_WSE: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
203 |
z = 8; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
204 |
y ^= 0xF; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
205 |
if (x - y < 0) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
206 |
z += (x - y) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
207 |
} |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
208 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
209 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
210 |
case SLOPE_N: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
211 |
y ^= 0xF; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
212 |
if (y - x >= 0) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
213 |
z = (y - x) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
214 |
} |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
215 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
216 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
217 |
case SLOPE_NW: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
218 |
z = (y ^ 0xF) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
219 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
220 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
221 |
case SLOPE_NWS: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
222 |
z = 8; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
223 |
if (x - y < 0) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
224 |
z += (x - y) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
225 |
} |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
226 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
227 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
228 |
case SLOPE_NE: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
229 |
z = (x ^ 0xF) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
230 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
231 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
232 |
case SLOPE_ENW: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
233 |
z = 8; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
234 |
y ^= 0xF; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
235 |
if (y - x < 0) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
236 |
z += (y - x) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
237 |
} |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
238 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
239 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
240 |
case SLOPE_SEN: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
241 |
z = 8; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
242 |
if (y - x < 0) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
243 |
z += (y - x) >> 1; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
244 |
} |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
245 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
246 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
247 |
case SLOPE_STEEP_S: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
248 |
z = 1 + ((x + y) >> 1); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
249 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
250 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
251 |
case SLOPE_STEEP_W: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
252 |
z = 1 + ((x + (y ^ 0xF)) >> 1); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
253 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
254 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
255 |
case SLOPE_STEEP_N: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
256 |
z = 1 + (((x ^ 0xF) + (y ^ 0xF)) >> 1); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
257 |
break; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
258 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
259 |
case SLOPE_STEEP_E: |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
260 |
z = 1 + (((x ^ 0xF) + y) >> 1); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
261 |
break; |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
262 |
|
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
263 |
default: break; |
0 | 264 |
} |
265 |
||
266 |
return z; |
|
267 |
} |
|
268 |
||
2951 | 269 |
uint GetSlopeZ(int x, int y) |
0 | 270 |
{ |
4231
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
271 |
TileIndex tile = TileVirtXY(x, y); |
0 | 272 |
|
4231
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
273 |
return _tile_type_procs[GetTileType(tile)]->get_slope_z_proc(tile, x, y); |
0 | 274 |
} |
275 |
||
7728
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
276 |
/** |
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
277 |
* Determine the Z height of a corner relative to TileZ. |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
278 |
* |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
279 |
* @pre The slope must not be a halftile slope. |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
280 |
* |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
281 |
* @param tileh The slope. |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
282 |
* @param corner The corner. |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
283 |
* @return Z position of corner relative to TileZ. |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
284 |
*/ |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
285 |
int GetSlopeZInCorner(Slope tileh, Corner corner) |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
286 |
{ |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
287 |
assert(!IsHalftileSlope(tileh)); |
8413
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
288 |
return ((tileh & SlopeWithOneCornerRaised(corner)) != 0 ? TILE_HEIGHT : 0) + (tileh == SteepSlope(corner) ? TILE_HEIGHT : 0); |
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
289 |
} |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
290 |
|
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
291 |
/** |
7728
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
292 |
* Determine the Z height of the corners of a specific tile edge |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
293 |
* |
7764
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
294 |
* @note If a tile has a non-continuous halftile foundation, a corner can have different heights wrt. it's edges. |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
295 |
* |
7728
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
296 |
* @pre z1 and z2 must be initialized (typ. with TileZ). The corner heights just get added. |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
297 |
* |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
298 |
* @param tileh The slope of the tile. |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
299 |
* @param edge The edge of interest. |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
300 |
* @param z1 Gets incremented by the height of the first corner of the edge. (near corner wrt. the camera) |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
301 |
* @param z2 Gets incremented by the height of the second corner of the edge. (far corner wrt. the camera) |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
302 |
*/ |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
303 |
void GetSlopeZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2) |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
304 |
{ |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
305 |
static const Slope corners[4][4] = { |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
306 |
/* corner | steep slope |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
307 |
* z1 z2 | z1 z2 */ |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
308 |
{SLOPE_E, SLOPE_N, SLOPE_STEEP_E, SLOPE_STEEP_N}, // DIAGDIR_NE, z1 = E, z2 = N |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
309 |
{SLOPE_S, SLOPE_E, SLOPE_STEEP_S, SLOPE_STEEP_E}, // DIAGDIR_SE, z1 = S, z2 = E |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
310 |
{SLOPE_S, SLOPE_W, SLOPE_STEEP_S, SLOPE_STEEP_W}, // DIAGDIR_SW, z1 = S, z2 = W |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
311 |
{SLOPE_W, SLOPE_N, SLOPE_STEEP_W, SLOPE_STEEP_N}, // DIAGDIR_NW, z1 = W, z2 = N |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
312 |
}; |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
313 |
|
7764
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
314 |
int halftile_test = (IsHalftileSlope(tileh) ? SlopeWithOneCornerRaised(GetHalftileSlopeCorner(tileh)) : 0); |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
315 |
if (halftile_test == corners[edge][0]) *z2 += TILE_HEIGHT; // The slope is non-continuous in z2. z2 is on the upper side. |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
316 |
if (halftile_test == corners[edge][1]) *z1 += TILE_HEIGHT; // The slope is non-continuous in z1. z1 is on the upper side. |
e594296e90f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
7728
diff
changeset
|
317 |
|
7728
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
318 |
if ((tileh & corners[edge][0]) != 0) *z1 += TILE_HEIGHT; // z1 is raised |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
319 |
if ((tileh & corners[edge][1]) != 0) *z2 += TILE_HEIGHT; // z2 is raised |
8413
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
320 |
if (RemoveHalftileSlope(tileh) == corners[edge][2]) *z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope |
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
321 |
if (RemoveHalftileSlope(tileh) == corners[edge][3]) *z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope |
7728
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
322 |
} |
4061
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
323 |
|
8413
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
324 |
/** |
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
325 |
* Get slope of a tile on top of a (possible) foundation |
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
326 |
* If a tile does not have a foundation, the function returns the same as GetTileSlope. |
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
327 |
* |
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
328 |
* @param tile The tile of interest. |
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
329 |
* @param z returns the z of the foundation slope. (Can be NULL, if not needed) |
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
330 |
* @return The slope on top of the foundation. |
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8380
diff
changeset
|
331 |
*/ |
8380
174326093caa
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8270
diff
changeset
|
332 |
Slope GetFoundationSlope(TileIndex tile, uint* z) |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
333 |
{ |
4061
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
334 |
Slope tileh = GetTileSlope(tile, z); |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
335 |
Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh); |
8380
174326093caa
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8270
diff
changeset
|
336 |
uint z_inc = ApplyFoundationToSlope(f, &tileh); |
174326093caa
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8270
diff
changeset
|
337 |
if (z != NULL) *z += z_inc; |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
338 |
return tileh; |
4061
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
339 |
} |
39 | 340 |
|
4061
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
341 |
|
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
342 |
static bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here) |
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
343 |
{ |
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
344 |
uint z; |
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
345 |
|
7728
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
346 |
int z_W_here = z_here; |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
347 |
int z_N_here = z_here; |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
348 |
GetSlopeZOnEdge(slope_here, DIAGDIR_NW, &z_W_here, &z_N_here); |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
349 |
|
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
350 |
Slope slope = GetFoundationSlope(TILE_ADDXY(tile, 0, -1), &z); |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
351 |
int z_W = z; |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
352 |
int z_N = z; |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
353 |
GetSlopeZOnEdge(slope, DIAGDIR_SE, &z_W, &z_N); |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
354 |
|
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
355 |
return (z_N_here > z_N) || (z_W_here > z_W); |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
356 |
} |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
357 |
|
4061
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
358 |
|
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
359 |
static bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here) |
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
360 |
{ |
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
361 |
uint z; |
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
362 |
|
7728
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
363 |
int z_E_here = z_here; |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
364 |
int z_N_here = z_here; |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
365 |
GetSlopeZOnEdge(slope_here, DIAGDIR_NE, &z_E_here, &z_N_here); |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
366 |
|
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
367 |
Slope slope = GetFoundationSlope(TILE_ADDXY(tile, -1, 0), &z); |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
368 |
int z_E = z; |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
369 |
int z_N = z; |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
370 |
GetSlopeZOnEdge(slope, DIAGDIR_SW, &z_E, &z_N); |
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
371 |
|
68e794385dc9
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
7678
diff
changeset
|
372 |
return (z_N_here > z_N) || (z_E_here > z_E); |
4061
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
373 |
} |
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
374 |
|
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
375 |
/** |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
376 |
* Draw foundation \a f at tile \a ti. Updates \a ti. |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
377 |
* @param ti Tile to draw foundation on |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
378 |
* @param f Foundation to draw |
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
379 |
*/ |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
380 |
void DrawFoundation(TileInfo *ti, Foundation f) |
0 | 381 |
{ |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
382 |
if (!IsFoundation(f)) return; |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
383 |
|
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
384 |
/* Two part foundations must be drawn separately */ |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
385 |
assert(f != FOUNDATION_STEEP_BOTH); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
386 |
|
7767
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
387 |
uint sprite_block = 0; |
4061
b90ec503a589
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
388 |
uint z; |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
389 |
Slope slope = GetFoundationSlope(ti->tile, &z); |
39 | 390 |
|
7767
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
391 |
/* Select the needed block of foundations sprites |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
392 |
* Block 0: Walls at NW and NE edge |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
393 |
* Block 1: Wall at NE edge |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
394 |
* Block 2: Wall at NW edge |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
395 |
* Block 3: No walls at NW or NE edge |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
396 |
*/ |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
397 |
if (!HasFoundationNW(ti->tile, slope, z)) sprite_block += 1; |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
398 |
if (!HasFoundationNE(ti->tile, slope, z)) sprite_block += 2; |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
399 |
|
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
400 |
/* Use the original slope sprites if NW and NE borders should be visible */ |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
401 |
SpriteID leveled_base = (sprite_block == 0 ? (int)SPR_FOUNDATION_BASE : (SPR_SLOPES_VIRTUAL_BASE + sprite_block * SPR_TRKFOUND_BLOCK_SIZE)); |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
402 |
SpriteID inclined_base = SPR_SLOPES_VIRTUAL_BASE + SPR_SLOPES_INCLINED_OFFSET + sprite_block * SPR_TRKFOUND_BLOCK_SIZE; |
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
403 |
SpriteID halftile_base = SPR_HALFTILE_FOUNDATION_BASE + sprite_block * SPR_HALFTILE_BLOCK_SIZE; |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
404 |
|
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
405 |
if (IsSteepSlope(ti->tileh)) { |
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
406 |
if (!IsNonContinuousFoundation(f)) { |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
407 |
/* Lower part of foundation */ |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
408 |
AddSortableSpriteToDraw( |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
409 |
leveled_base + (ti->tileh & ~SLOPE_STEEP), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
410 |
); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
411 |
} |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
412 |
|
7678
8917067dde87
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7335
diff
changeset
|
413 |
Corner highest_corner = GetHighestSlopeCorner(ti->tileh); |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
414 |
ti->z += ApplyFoundationToSlope(f, &ti->tileh); |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
415 |
|
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
416 |
if (IsInclinedFoundation(f)) { |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
417 |
/* inclined foundation */ |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
418 |
byte inclined = highest_corner * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0); |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
419 |
|
10294
748d6a359208
(svn r14533) -Fix: ...hopefully most glitches wrt. inclined foundations.
frosch
parents:
10260
diff
changeset
|
420 |
AddSortableSpriteToDraw(inclined_base + inclined, PAL_NONE, ti->x, ti->y, |
748d6a359208
(svn r14533) -Fix: ...hopefully most glitches wrt. inclined foundations.
frosch
parents:
10260
diff
changeset
|
421 |
f == FOUNDATION_INCLINED_X ? 16 : 1, |
748d6a359208
(svn r14533) -Fix: ...hopefully most glitches wrt. inclined foundations.
frosch
parents:
10260
diff
changeset
|
422 |
f == FOUNDATION_INCLINED_Y ? 16 : 1, |
10311
44b12fe10656
(svn r14556) -Fix (r14533): Bounding box with height > TILE_HEIGHT could cause circular dependencies with surrounding bridges.
frosch
parents:
10294
diff
changeset
|
423 |
TILE_HEIGHT, ti->z |
10294
748d6a359208
(svn r14533) -Fix: ...hopefully most glitches wrt. inclined foundations.
frosch
parents:
10260
diff
changeset
|
424 |
); |
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
425 |
OffsetGroundSprite(31, 9); |
9509
f6d513c5c7e4
(svn r13499) -Codechange: Allow drawing (ugly) leveled foundations on steep slopes, just in case someone needs them for fallback.
frosch
parents:
9413
diff
changeset
|
426 |
} else if (IsLeveledFoundation(f)) { |
f6d513c5c7e4
(svn r13499) -Codechange: Allow drawing (ugly) leveled foundations on steep slopes, just in case someone needs them for fallback.
frosch
parents:
9413
diff
changeset
|
427 |
AddSortableSpriteToDraw(leveled_base + SlopeWithOneCornerRaised(highest_corner), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z - TILE_HEIGHT); |
f6d513c5c7e4
(svn r13499) -Codechange: Allow drawing (ugly) leveled foundations on steep slopes, just in case someone needs them for fallback.
frosch
parents:
9413
diff
changeset
|
428 |
OffsetGroundSprite(31, 1); |
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
429 |
} else if (f == FOUNDATION_STEEP_LOWER) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6106
diff
changeset
|
430 |
/* one corner raised */ |
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
431 |
OffsetGroundSprite(31, 1); |
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
432 |
} else { |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
433 |
/* halftile foundation */ |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
434 |
int x_bb = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? 8 : 0); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
435 |
int y_bb = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? 8 : 0); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
436 |
|
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
437 |
AddSortableSpriteToDraw(halftile_base + highest_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z + TILE_HEIGHT); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
438 |
OffsetGroundSprite(31, 9); |
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
439 |
} |
0 | 440 |
} else { |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
441 |
if (IsLeveledFoundation(f)) { |
7767
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
442 |
/* leveled foundation */ |
9866e9700e62
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
7764
diff
changeset
|
443 |
AddSortableSpriteToDraw(leveled_base + ti->tileh, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z); |
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
444 |
OffsetGroundSprite(31, 1); |
7770
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
445 |
} else if (IsNonContinuousFoundation(f)) { |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
446 |
/* halftile foundation */ |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
447 |
Corner halftile_corner = GetHalftileFoundationCorner(f); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
448 |
int x_bb = (((halftile_corner == CORNER_W) || (halftile_corner == CORNER_S)) ? 8 : 0); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
449 |
int y_bb = (((halftile_corner == CORNER_S) || (halftile_corner == CORNER_E)) ? 8 : 0); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
450 |
|
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
451 |
AddSortableSpriteToDraw(halftile_base + halftile_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
452 |
OffsetGroundSprite(31, 9); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
453 |
} else if (IsSpecialRailFoundation(f)) { |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
454 |
/* anti-zig-zag foundation */ |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
455 |
SpriteID spr; |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
456 |
if (ti->tileh == SLOPE_NS || ti->tileh == SLOPE_EW) { |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
457 |
/* half of leveled foundation under track corner */ |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
458 |
spr = leveled_base + SlopeWithThreeCornersRaised(GetRailFoundationCorner(f)); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
459 |
} else { |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
460 |
/* tile-slope = sloped along X/Y, foundation-slope = three corners raised */ |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
461 |
spr = inclined_base + 2 * GetRailFoundationCorner(f) + ((ti->tileh == SLOPE_SW || ti->tileh == SLOPE_NE) ? 1 : 0); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
462 |
} |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
463 |
AddSortableSpriteToDraw(spr, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z); |
320d260ff1a1
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
7767
diff
changeset
|
464 |
OffsetGroundSprite(31, 9); |
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
465 |
} else { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6106
diff
changeset
|
466 |
/* inclined foundation */ |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
467 |
byte inclined = GetHighestSlopeCorner(ti->tileh) * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0); |
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
468 |
|
10294
748d6a359208
(svn r14533) -Fix: ...hopefully most glitches wrt. inclined foundations.
frosch
parents:
10260
diff
changeset
|
469 |
AddSortableSpriteToDraw(inclined_base + inclined, PAL_NONE, ti->x, ti->y, |
748d6a359208
(svn r14533) -Fix: ...hopefully most glitches wrt. inclined foundations.
frosch
parents:
10260
diff
changeset
|
470 |
f == FOUNDATION_INCLINED_X ? 16 : 1, |
748d6a359208
(svn r14533) -Fix: ...hopefully most glitches wrt. inclined foundations.
frosch
parents:
10260
diff
changeset
|
471 |
f == FOUNDATION_INCLINED_Y ? 16 : 1, |
10311
44b12fe10656
(svn r14556) -Fix (r14533): Bounding box with height > TILE_HEIGHT could cause circular dependencies with surrounding bridges.
frosch
parents:
10294
diff
changeset
|
472 |
TILE_HEIGHT, ti->z |
10294
748d6a359208
(svn r14533) -Fix: ...hopefully most glitches wrt. inclined foundations.
frosch
parents:
10260
diff
changeset
|
473 |
); |
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
474 |
OffsetGroundSprite(31, 9); |
4246
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4240
diff
changeset
|
475 |
} |
7335
141c6b86ec1f
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7304
diff
changeset
|
476 |
ti->z += ApplyFoundationToSlope(f, &ti->tileh); |
0 | 477 |
} |
478 |
} |
|
479 |
||
1589
bac29165710f
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
480 |
void DoClearSquare(TileIndex tile) |
0 | 481 |
{ |
3447 | 482 |
MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0); |
2955
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
483 |
MarkTileDirtyByTile(tile); |
0 | 484 |
} |
485 |
||
8616
fd862a55c47f
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
8596
diff
changeset
|
486 |
/** Returns information about trackdirs and signal states. |
8596
c3404405f3f5
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8450
diff
changeset
|
487 |
* If there is any trackbit at 'side', return all trackdirbits. |
8616
fd862a55c47f
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
8596
diff
changeset
|
488 |
* For TRANSPORT_ROAD, return no trackbits if there is no roadbit (of given subtype) at given side. |
8596
c3404405f3f5
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8450
diff
changeset
|
489 |
* @param tile tile to get info about |
c3404405f3f5
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8450
diff
changeset
|
490 |
* @param mode transport type |
c3404405f3f5
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8450
diff
changeset
|
491 |
* @param sub_mode for TRANSPORT_ROAD, roadtypes to check |
c3404405f3f5
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8450
diff
changeset
|
492 |
* @param side side we are entering from, INVALID_DIAGDIR to return all trackbits |
c3404405f3f5
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8450
diff
changeset
|
493 |
* @return trackdirbits and other info depending on 'mode' |
c3404405f3f5
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8450
diff
changeset
|
494 |
*/ |
8616
fd862a55c47f
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
8596
diff
changeset
|
495 |
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
0 | 496 |
{ |
8596
c3404405f3f5
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8450
diff
changeset
|
497 |
return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode, sub_mode, side); |
0 | 498 |
} |
499 |
||
10233
ac41e2898d9b
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium
parents:
10207
diff
changeset
|
500 |
/** |
ac41e2898d9b
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium
parents:
10207
diff
changeset
|
501 |
* Change the owner of a tile |
ac41e2898d9b
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium
parents:
10207
diff
changeset
|
502 |
* @param tile Tile to change |
ac41e2898d9b
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium
parents:
10207
diff
changeset
|
503 |
* @param old_owner Current owner of the tile |
ac41e2898d9b
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium
parents:
10207
diff
changeset
|
504 |
* @param new_owner New owner of the tile |
ac41e2898d9b
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium
parents:
10207
diff
changeset
|
505 |
*/ |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10056
diff
changeset
|
506 |
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner) |
0 | 507 |
{ |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10056
diff
changeset
|
508 |
_tile_type_procs[GetTileType(tile)]->change_tile_owner_proc(tile, old_owner, new_owner); |
0 | 509 |
} |
510 |
||
1589
bac29165710f
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
511 |
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac) |
0 | 512 |
{ |
513 |
memset(ac, 0, sizeof(AcceptedCargo)); |
|
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
514 |
_tile_type_procs[GetTileType(tile)]->get_accepted_cargo_proc(tile, ac); |
0 | 515 |
} |
516 |
||
1589
bac29165710f
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
517 |
void AnimateTile(TileIndex tile) |
0 | 518 |
{ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
519 |
_tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile); |
0 | 520 |
} |
521 |
||
1589
bac29165710f
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
522 |
void ClickTile(TileIndex tile) |
0 | 523 |
{ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
524 |
_tile_type_procs[GetTileType(tile)]->click_tile_proc(tile); |
0 | 525 |
} |
526 |
||
1589
bac29165710f
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
527 |
void GetTileDesc(TileIndex tile, TileDesc *td) |
0 | 528 |
{ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
529 |
_tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td); |
0 | 530 |
} |
531 |
||
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
532 |
/** |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
533 |
* Has a snow line table already been loaded. |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
534 |
* @return true if the table has been loaded already. |
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
535 |
* @ingroup SnowLineGroup |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
536 |
*/ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
537 |
bool IsSnowLineSet(void) |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
538 |
{ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
539 |
return _snow_line != NULL; |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
540 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
541 |
|
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
542 |
/** |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
543 |
* Set a variable snow line, as loaded from a newgrf file. |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
544 |
* @param table the 12 * 32 byte table containing the snowline for each day |
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
545 |
* @ingroup SnowLineGroup |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
546 |
*/ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
547 |
void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]) |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
548 |
{ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
549 |
_snow_line = CallocT<SnowLine>(1); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
550 |
memcpy(_snow_line->table, table, sizeof(_snow_line->table)); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
551 |
|
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
552 |
for (uint i = 0; i < SNOW_LINE_MONTHS; i++) { |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
553 |
for (uint j = 0; j < SNOW_LINE_DAYS; j++) { |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
554 |
_snow_line->highest_value = max(_snow_line->highest_value, table[i][j]); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
555 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
556 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
557 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
558 |
|
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
559 |
/** |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
560 |
* Get the current snow line, either variable or static. |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
561 |
* @return the snow line height. |
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
562 |
* @ingroup SnowLineGroup |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
563 |
*/ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
564 |
byte GetSnowLine(void) |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
565 |
{ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
566 |
if (_snow_line == NULL) return _settings_game.game_creation.snow_line; |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
567 |
|
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
568 |
YearMonthDay ymd; |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
569 |
ConvertDateToYMD(_date, &ymd); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
570 |
return _snow_line->table[ymd.month][ymd.day]; |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
571 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
572 |
|
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
573 |
/** |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
574 |
* Get the highest possible snow line height, either variable or static. |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
575 |
* @return the highest snow line height. |
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
576 |
* @ingroup SnowLineGroup |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
577 |
*/ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
578 |
byte HighestSnowLine(void) |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
579 |
{ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
580 |
return _snow_line == NULL ? _settings_game.game_creation.snow_line : _snow_line->highest_value; |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
581 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
582 |
|
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
583 |
/** |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
584 |
* Clear the variable snow line table and free the memory. |
10260
c6ec6b3c1b18
(svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents:
10233
diff
changeset
|
585 |
* @ingroup SnowLineGroup |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
586 |
*/ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
587 |
void ClearSnowLine(void) |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
588 |
{ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
589 |
free(_snow_line); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
590 |
_snow_line = NULL; |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
591 |
} |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6247
diff
changeset
|
592 |
|
1775
548dc04d50e2
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1589
diff
changeset
|
593 |
/** Clear a piece of landscape |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
594 |
* @param tile tile to clear |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6106
diff
changeset
|
595 |
* @param flags of operation to conduct |
1775
548dc04d50e2
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1589
diff
changeset
|
596 |
* @param p1 unused |
548dc04d50e2
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1589
diff
changeset
|
597 |
* @param p2 unused |
0 | 598 |
*/ |
6943
1914f26aee04
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
6683
diff
changeset
|
599 |
CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 600 |
{ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
601 |
return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags); |
0 | 602 |
} |
603 |
||
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
604 |
/** Clear a big piece of landscape |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
605 |
* @param tile end tile of area dragging |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
606 |
* @param p1 start tile of area dragging |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6106
diff
changeset
|
607 |
* @param flags of operation to conduct |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
608 |
* @param p2 unused |
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
609 |
*/ |
6943
1914f26aee04
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
6683
diff
changeset
|
610 |
CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 611 |
{ |
2934
3f29a7212713
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
tron
parents:
2639
diff
changeset
|
612 |
if (p1 >= MapSize()) return CMD_ERROR; |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
613 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6106
diff
changeset
|
614 |
/* make sure sx,sy are smaller than ex,ey */ |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
615 |
int ex = TileX(tile); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
616 |
int ey = TileY(tile); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
617 |
int sx = TileX(p1); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
618 |
int sy = TileY(p1); |
6106 | 619 |
if (ex < sx) Swap(ex, sx); |
620 |
if (ey < sy) Swap(ey, sy); |
|
0 | 621 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
622 |
Money money = GetAvailableMoneyForCommand(); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
623 |
CommandCost cost(EXPENSES_CONSTRUCTION); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
624 |
bool success = false; |
0 | 625 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
626 |
for (int x = sx; x <= ex; ++x) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
627 |
for (int y = sy; y <= ey; ++y) { |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
628 |
CommandCost ret = DoCommand(TileXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR); |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
629 |
if (CmdFailed(ret)) continue; |
0 | 630 |
success = true; |
631 |
||
632 |
if (flags & DC_EXEC) { |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
633 |
money -= ret.GetCost(); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
634 |
if (ret.GetCost() > 0 && money < 0) { |
6950
14ecb0acdfb4
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
6943
diff
changeset
|
635 |
_additional_cash_required = ret.GetCost(); |
14ecb0acdfb4
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
6943
diff
changeset
|
636 |
return cost; |
0 | 637 |
} |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
638 |
DoCommand(TileXY(x, y), 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
0 | 639 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6106
diff
changeset
|
640 |
/* draw explosion animation... */ |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
641 |
if ((x == sx || x == ex) && (y == sy || y == ey)) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6106
diff
changeset
|
642 |
/* big explosion in each corner, or small explosion for single tiles */ |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3636
diff
changeset
|
643 |
CreateEffectVehicleAbove(x * TILE_SIZE + TILE_SIZE / 2, y * TILE_SIZE + TILE_SIZE / 2, 2, |
1359
52782e5cf7c9
(svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents:
1350
diff
changeset
|
644 |
sy == ey && sx == ex ? EV_EXPLOSION_SMALL : EV_EXPLOSION_LARGE |
52782e5cf7c9
(svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents:
1350
diff
changeset
|
645 |
); |
0 | 646 |
} |
647 |
} |
|
6950
14ecb0acdfb4
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
6943
diff
changeset
|
648 |
cost.AddCost(ret); |
0 | 649 |
} |
650 |
} |
|
651 |
||
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
652 |
return (success) ? cost : CMD_ERROR; |
0 | 653 |
} |
654 |
||
655 |
||
8973
749e572f9378
(svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium
parents:
8817
diff
changeset
|
656 |
TileIndex _cur_tileloop_tile; |
0 | 657 |
#define TILELOOP_BITS 4 |
658 |
#define TILELOOP_SIZE (1 << TILELOOP_BITS) |
|
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6357
diff
changeset
|
659 |
#define TILELOOP_ASSERTMASK ((TILELOOP_SIZE - 1) + ((TILELOOP_SIZE - 1) << MapLogX())) |
927
94fec9843fd3
(svn r1415) Move TILE_FROM_XY and TILE_XY to map.h and push TILE_[XY] bits from map.h into map.c.
tron
parents:
926
diff
changeset
|
660 |
#define TILELOOP_CHKMASK (((1 << (MapLogX() - TILELOOP_BITS))-1) << TILELOOP_BITS) |
0 | 661 |
|
6247 | 662 |
void RunTileLoop() |
0 | 663 |
{ |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
664 |
TileIndex tile = _cur_tileloop_tile; |
0 | 665 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
666 |
assert((tile & ~TILELOOP_ASSERTMASK) == 0); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
667 |
uint count = (MapSizeX() / TILELOOP_SIZE) * (MapSizeY() / TILELOOP_SIZE); |
0 | 668 |
do { |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
669 |
_tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile); |
0 | 670 |
|
926
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
925
diff
changeset
|
671 |
if (TileX(tile) < MapSizeX() - TILELOOP_SIZE) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6106
diff
changeset
|
672 |
tile += TILELOOP_SIZE; // no overflow |
0 | 673 |
} else { |
1981 | 674 |
tile = TILE_MASK(tile - TILELOOP_SIZE * (MapSizeX() / TILELOOP_SIZE - 1) + TileDiffXY(0, TILELOOP_SIZE)); /* x would overflow, also increase y */ |
0 | 675 |
} |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
676 |
} while (--count != 0); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
677 |
assert((tile & ~TILELOOP_ASSERTMASK) == 0); |
0 | 678 |
|
679 |
tile += 9; |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
680 |
if (tile & TILELOOP_CHKMASK) { |
863
6a1444534f62
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
857
diff
changeset
|
681 |
tile = (tile + MapSizeX()) & TILELOOP_ASSERTMASK; |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
682 |
} |
0 | 683 |
_cur_tileloop_tile = tile; |
684 |
} |
|
685 |
||
6247 | 686 |
void InitializeLandscape() |
0 | 687 |
{ |
3078
cfce0beffa16
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
688 |
uint maxx = MapMaxX(); |
cfce0beffa16
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
689 |
uint maxy = MapMaxY(); |
cfce0beffa16
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
690 |
uint sizex = MapSizeX(); |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
691 |
|
3078
cfce0beffa16
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
692 |
uint y; |
cfce0beffa16
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
693 |
for (y = 0; y < maxy; y++) { |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
694 |
uint x; |
3078
cfce0beffa16
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
695 |
for (x = 0; x < maxx; x++) { |
3447 | 696 |
MakeClear(sizex * y + x, CLEAR_GRASS, 3); |
3078
cfce0beffa16
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
697 |
SetTileHeight(sizex * y + x, 0); |
8450
73371bb82922
(svn r12020) -Documentation: Correct description of TropicZone.
frosch
parents:
8413
diff
changeset
|
698 |
SetTropicZone(sizex * y + x, TROPICZONE_NORMAL); |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4990
diff
changeset
|
699 |
ClearBridgeMiddle(sizex * y + x); |
3078
cfce0beffa16
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
700 |
} |
cfce0beffa16
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
701 |
MakeVoid(sizex * y + x); |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
702 |
} |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
703 |
for (uint x = 0; x < sizex; x++) MakeVoid(sizex * y + x); |
0 | 704 |
} |
705 |
||
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
706 |
static const byte _genterrain_tbl_1[5] = { 10, 22, 33, 37, 4 }; |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
707 |
static const byte _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 }; |
0 | 708 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
709 |
static void GenerateTerrain(int type, uint flag) |
0 | 710 |
{ |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
711 |
uint32 r = Random(); |
0 | 712 |
|
10056
48659f7d4fa5
(svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium
parents:
9509
diff
changeset
|
713 |
const Sprite *templ = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845, ST_MAPGEN); |
0 | 714 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
715 |
uint x = r & MapMaxX(); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
716 |
uint y = (r >> MapLogX()) & MapMaxY(); |
0 | 717 |
|
2951 | 718 |
if (x < 2 || y < 2) return; |
0 | 719 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
720 |
DiagDirection direction = (DiagDirection)GB(r, 22, 2); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
721 |
uint w = templ->width; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
722 |
uint h = templ->height; |
0 | 723 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
724 |
if (DiagDirToAxis(direction) == AXIS_Y) Swap(w, h); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
725 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
726 |
const byte *p = templ->data; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
727 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
728 |
if ((flag & 4) != 0) { |
1273
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
729 |
uint xw = x * MapSizeY(); |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
730 |
uint yw = y * MapSizeX(); |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
731 |
uint bias = (MapSizeX() + MapSizeY()) * 16; |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
732 |
|
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
733 |
switch (flag & 3) { |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
734 |
default: NOT_REACHED(); |
1273
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
735 |
case 0: |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
736 |
if (xw + yw > MapSize() - bias) return; |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
737 |
break; |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
738 |
|
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
739 |
case 1: |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
740 |
if (yw < xw + bias) return; |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
741 |
break; |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
742 |
|
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
743 |
case 2: |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
744 |
if (xw + yw < MapSize() + bias) return; |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
745 |
break; |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
746 |
|
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
747 |
case 3: |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
748 |
if (xw < yw + bias) return; |
e4849a568647
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
749 |
break; |
0 | 750 |
} |
751 |
} |
|
752 |
||
2951 | 753 |
if (x + w >= MapMaxX() - 1) return; |
754 |
if (y + h >= MapMaxY() - 1) return; |
|
0 | 755 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
756 |
Tile *tile = &_m[TileXY(x, y)]; |
0 | 757 |
|
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
758 |
switch (direction) { |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
759 |
default: NOT_REACHED(); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
760 |
case DIAGDIR_NE: |
0 | 761 |
do { |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
762 |
Tile *tile_cur = tile; |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
763 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
764 |
for (uint w_cur = w; w_cur != 0; --w_cur) { |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
765 |
if (*p >= tile_cur->type_height) tile_cur->type_height = *p; |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
766 |
p++; |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
767 |
tile_cur++; |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
768 |
} |
1981 | 769 |
tile += TileDiffXY(0, 1); |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
770 |
} while (--h != 0); |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
771 |
break; |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
772 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
773 |
case DIAGDIR_SE: |
0 | 774 |
do { |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
775 |
Tile *tile_cur = tile; |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
776 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
777 |
for (uint h_cur = h; h_cur != 0; --h_cur) { |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
778 |
if (*p >= tile_cur->type_height) tile_cur->type_height = *p; |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
779 |
p++; |
1981 | 780 |
tile_cur += TileDiffXY(0, 1); |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
781 |
} |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
782 |
tile += TileDiffXY(1, 0); |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
783 |
} while (--w != 0); |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
784 |
break; |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
785 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
786 |
case DIAGDIR_SW: |
1981 | 787 |
tile += TileDiffXY(w - 1, 0); |
0 | 788 |
do { |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
789 |
Tile *tile_cur = tile; |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
790 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
791 |
for (uint w_cur = w; w_cur != 0; --w_cur) { |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
792 |
if (*p >= tile_cur->type_height) tile_cur->type_height = *p; |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
793 |
p++; |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
794 |
tile_cur--; |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
795 |
} |
1981 | 796 |
tile += TileDiffXY(0, 1); |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
797 |
} while (--h != 0); |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
798 |
break; |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
799 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
800 |
case DIAGDIR_NW: |
1981 | 801 |
tile += TileDiffXY(0, h - 1); |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
802 |
do { |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
803 |
Tile *tile_cur = tile; |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
804 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
805 |
for (uint h_cur = h; h_cur != 0; --h_cur) { |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
806 |
if (*p >= tile_cur->type_height) tile_cur->type_height = *p; |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
807 |
p++; |
1981 | 808 |
tile_cur -= TileDiffXY(0, 1); |
1278
952095d83a1a
(svn r1782) Remove line which should've been removed in r1779 and caused map generation to hang infinitely
tron
parents:
1275
diff
changeset
|
809 |
} |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
810 |
tile += TileDiffXY(1, 0); |
1275
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
811 |
} while (--w != 0); |
5d1b5fe31c78
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
812 |
break; |
0 | 813 |
} |
814 |
} |
|
815 |
||
816 |
||
817 |
#include "table/genland.h" |
|
818 |
||
6247 | 819 |
static void CreateDesertOrRainForest() |
0 | 820 |
{ |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
821 |
TileIndex update_freq = MapSize() / 4; |
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
822 |
const TileIndexDiffC *data; |
0 | 823 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
824 |
for (TileIndex tile = 0; tile != MapSize(); ++tile) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
825 |
if ((tile % update_freq) == 0) IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
826 |
|
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
827 |
for (data = _make_desert_or_rainforest_data; |
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
828 |
data != endof(_make_desert_or_rainforest_data); ++data) { |
1184
9792417da988
(svn r1686) Fix (Work around?) crash when generating tropical maps
tron
parents:
1181
diff
changeset
|
829 |
TileIndex t = TILE_MASK(tile + ToTileIndexDiff(*data)); |
1044
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
830 |
if (TileHeight(t) >= 4 || IsTileType(t, MP_WATER)) break; |
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
831 |
} |
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
832 |
if (data == endof(_make_desert_or_rainforest_data)) |
3379
50b253bb9819
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3297
diff
changeset
|
833 |
SetTropicZone(tile, TROPICZONE_DESERT); |
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
834 |
} |
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
835 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
836 |
for (uint i = 0; i != 256; i++) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
837 |
if ((i % 64) == 0) IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
838 |
|
0 | 839 |
RunTileLoop(); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
840 |
} |
0 | 841 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
842 |
for (TileIndex tile = 0; tile != MapSize(); ++tile) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
843 |
if ((tile % update_freq) == 0) IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
844 |
|
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
845 |
for (data = _make_desert_or_rainforest_data; |
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
846 |
data != endof(_make_desert_or_rainforest_data); ++data) { |
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
847 |
TileIndex t = TILE_MASK(tile + ToTileIndexDiff(*data)); |
3447 | 848 |
if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_DESERT)) break; |
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
849 |
} |
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
850 |
if (data == endof(_make_desert_or_rainforest_data)) |
3379
50b253bb9819
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3297
diff
changeset
|
851 |
SetTropicZone(tile, TROPICZONE_RAINFOREST); |
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
852 |
} |
0 | 853 |
} |
854 |
||
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
855 |
void GenerateLandscape(byte mode) |
0 | 856 |
{ |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
857 |
static const int gwp_desert_amount = 4 + 8; |
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
858 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
859 |
if (mode == GW_HEIGHTMAP) { |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
860 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, (_settings_game.game_creation.landscape == LT_TROPIC) ? 1 + gwp_desert_amount : 1); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
861 |
LoadHeightmap(_file_to_saveload.name); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
862 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
863 |
} else if (_settings_game.game_creation.land_generator == LG_TERRAGENESIS) { |
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
864 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, (_settings_game.game_creation.landscape == LT_TROPIC) ? 3 + gwp_desert_amount : 3); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
865 |
GenerateTerrainPerlin(); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
866 |
} else { |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
867 |
switch (_settings_game.game_creation.landscape) { |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
868 |
case LT_ARCTIC: { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
869 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, 2); |
0 | 870 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
871 |
uint32 r = Random(); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
872 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
873 |
for (uint i = ScaleByMapSize(GB(r, 0, 7) + 950); i != 0; --i) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
874 |
GenerateTerrain(2, 0); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
875 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
876 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
3017
a75caf4efa2d
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2955
diff
changeset
|
877 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
878 |
uint flag = GB(r, 7, 2) | 4; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
879 |
for (uint i = ScaleByMapSize(GB(r, 9, 7) + 450); i != 0; --i) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
880 |
GenerateTerrain(4, flag); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
881 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
882 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
883 |
} break; |
3017
a75caf4efa2d
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2955
diff
changeset
|
884 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
885 |
case LT_TROPIC: { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
886 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, 3 + gwp_desert_amount); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
887 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
888 |
uint32 r = Random(); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
889 |
|
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
890 |
for (uint i = ScaleByMapSize(GB(r, 0, 7) + 170); i != 0; --i) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
891 |
GenerateTerrain(0, 0); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
892 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
893 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
894 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
895 |
uint flag = GB(r, 7, 2) | 4; |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
896 |
for (uint i = ScaleByMapSize(GB(r, 9, 8) + 1700); i != 0; --i) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
897 |
GenerateTerrain(0, flag); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
898 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
899 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
900 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
901 |
flag ^= 2; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
902 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
903 |
for (uint i = ScaleByMapSize(GB(r, 17, 7) + 410); i != 0; --i) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
904 |
GenerateTerrain(3, flag); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
905 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
906 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
907 |
} break; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
908 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
909 |
default: { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
910 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, 1); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
911 |
|
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
912 |
uint32 r = Random(); |
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
913 |
|
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
914 |
uint i = ScaleByMapSize(GB(r, 0, 7) + (3 - _settings_game.difficulty.quantity_sea_lakes) * 256 + 100); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
915 |
for (; i != 0; --i) { |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
916 |
GenerateTerrain(_settings_game.difficulty.terrain_type, 0); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
917 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
918 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
8817
952aeb4bdbfb
(svn r12563) -Cleanup: variable scope and a bit of coding style in landscape.cpp
smatz
parents:
8651
diff
changeset
|
919 |
} break; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
920 |
} |
0 | 921 |
} |
922 |
||
923 |
ConvertGroundTilesIntoWaterTiles(); |
|
924 |
||
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
925 |
if (_settings_game.game_creation.landscape == LT_TROPIC) CreateDesertOrRainForest(); |
0 | 926 |
} |
927 |
||
6247 | 928 |
void OnTick_Town(); |
929 |
void OnTick_Trees(); |
|
930 |
void OnTick_Station(); |
|
931 |
void OnTick_Industry(); |
|
0 | 932 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10056
diff
changeset
|
933 |
void OnTick_Companies(); |
6247 | 934 |
void OnTick_Train(); |
0 | 935 |
|
6247 | 936 |
void CallLandscapeTick() |
0 | 937 |
{ |
938 |
OnTick_Town(); |
|
939 |
OnTick_Trees(); |
|
940 |
OnTick_Station(); |
|
941 |
OnTick_Industry(); |
|
942 |
||
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
10056
diff
changeset
|
943 |
OnTick_Companies(); |
0 | 944 |
OnTick_Train(); |
945 |
} |
|
946 |
||
947 |
TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng) |
|
948 |
{ |
|
949 |
int rn = rng; |
|
950 |
uint32 r = Random(); |
|
951 |
||
1981 | 952 |
return TILE_MASK(TileXY( |
2150
f710b959b1c4
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2140
diff
changeset
|
953 |
TileX(a) + (GB(r, 0, 8) * rn * 2 >> 8) - rn, |
f710b959b1c4
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2140
diff
changeset
|
954 |
TileY(a) + (GB(r, 8, 8) * rn * 2 >> 8) - rn |
1174
6a5e747f3ba6
(svn r1676) Increase the size of TileIndex and TileIndexDiff to 32bits and adapt the save/load data and some other parts of the code to that change
tron
parents:
1140
diff
changeset
|
955 |
)); |
0 | 956 |
} |