author | rubidium |
Sat, 20 Oct 2007 16:50:48 +0000 | |
changeset 8260 | c7d75cebe3f6 |
parent 8224 | 6260e98d1c6a |
child 8263 | cf890c002a88 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1793
diff
changeset
|
4 |
#include "openttd.h" |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4990
diff
changeset
|
5 |
#include "bridge_map.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
6 |
#include "heightmap.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3111
diff
changeset
|
7 |
#include "clear_map.h" |
6669
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
8 |
#include "date.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
9 |
#include "functions.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
473
diff
changeset
|
10 |
#include "map.h" |
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2150
diff
changeset
|
11 |
#include "player.h" |
1349
07514c2cc6d1
(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" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1359
diff
changeset
|
13 |
#include "table/sprites.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1202
diff
changeset
|
14 |
#include "tile.h" |
0 | 15 |
#include <stdarg.h> |
16 |
#include "viewport.h" |
|
17 |
#include "command.h" |
|
6669
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
18 |
#include "landscape.h" |
0 | 19 |
#include "vehicle.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2154
diff
changeset
|
20 |
#include "variables.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3111
diff
changeset
|
21 |
#include "void_map.h" |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3078
diff
changeset
|
22 |
#include "water_map.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
23 |
#include "tgp.h" |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
24 |
#include "genworld.h" |
0 | 25 |
|
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
26 |
extern const TileTypeProcs |
0 | 27 |
_tile_type_clear_procs, |
28 |
_tile_type_rail_procs, |
|
29 |
_tile_type_road_procs, |
|
30 |
_tile_type_town_procs, |
|
31 |
_tile_type_trees_procs, |
|
32 |
_tile_type_station_procs, |
|
33 |
_tile_type_water_procs, |
|
34 |
_tile_type_dummy_procs, |
|
35 |
_tile_type_industry_procs, |
|
36 |
_tile_type_tunnelbridge_procs, |
|
37 |
_tile_type_unmovable_procs; |
|
38 |
||
39 |
const TileTypeProcs * const _tile_type_procs[16] = { |
|
40 |
&_tile_type_clear_procs, |
|
41 |
&_tile_type_rail_procs, |
|
42 |
&_tile_type_road_procs, |
|
43 |
&_tile_type_town_procs, |
|
44 |
&_tile_type_trees_procs, |
|
45 |
&_tile_type_station_procs, |
|
46 |
&_tile_type_water_procs, |
|
47 |
&_tile_type_dummy_procs, |
|
48 |
&_tile_type_industry_procs, |
|
49 |
&_tile_type_tunnelbridge_procs, |
|
50 |
&_tile_type_unmovable_procs, |
|
51 |
}; |
|
52 |
||
53 |
/* landscape slope => sprite */ |
|
54 |
const byte _tileh_to_sprite[32] = { |
|
4344
5d0e40cd67b9
(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
|
55 |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, |
5d0e40cd67b9
(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
|
56 |
0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 17, 0, 15, 18, 0, |
0 | 57 |
}; |
58 |
||
7831
5dded9b03500
(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:
7800
diff
changeset
|
59 |
SnowLine *_snow_line = NULL; |
1958
625d71cd6898
(svn r2464) Move definition of _inclined_tileh out of variables.h
tron
parents:
1902
diff
changeset
|
60 |
|
7831
5dded9b03500
(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:
7800
diff
changeset
|
61 |
/** |
5dded9b03500
(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:
7800
diff
changeset
|
62 |
* Applys a foundation to a slope. |
5dded9b03500
(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:
7800
diff
changeset
|
63 |
* |
5dded9b03500
(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:
7800
diff
changeset
|
64 |
* @pre Foundation and slope must be valid combined. |
5dded9b03500
(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:
7800
diff
changeset
|
65 |
* @param f The #Foundation. |
5dded9b03500
(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:
7800
diff
changeset
|
66 |
* @param s The #Slope to modify. |
5dded9b03500
(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:
7800
diff
changeset
|
67 |
* @return Increment to the tile Z coordinate. |
5dded9b03500
(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:
7800
diff
changeset
|
68 |
*/ |
5dded9b03500
(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:
7800
diff
changeset
|
69 |
uint ApplyFoundationToSlope(Foundation f, Slope *s) |
5dded9b03500
(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:
7800
diff
changeset
|
70 |
{ |
5dded9b03500
(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:
7800
diff
changeset
|
71 |
|
5dded9b03500
(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:
7800
diff
changeset
|
72 |
if (!IsFoundation(f)) return 0; |
5dded9b03500
(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:
7800
diff
changeset
|
73 |
|
5dded9b03500
(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:
7800
diff
changeset
|
74 |
if (IsLeveledFoundation(f)) { |
5dded9b03500
(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:
7800
diff
changeset
|
75 |
*s = SLOPE_FLAT; |
5dded9b03500
(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:
7800
diff
changeset
|
76 |
return TILE_HEIGHT; |
5dded9b03500
(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:
7800
diff
changeset
|
77 |
} |
5dded9b03500
(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:
7800
diff
changeset
|
78 |
|
5dded9b03500
(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:
7800
diff
changeset
|
79 |
uint dz = IsSteepSlope(*s) ? TILE_HEIGHT : 0; |
8174
5343705d60f5
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
80 |
Corner highest_corner = GetHighestSlopeCorner(*s); |
7831
5dded9b03500
(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:
7800
diff
changeset
|
81 |
|
5dded9b03500
(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:
7800
diff
changeset
|
82 |
switch (f) { |
5dded9b03500
(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:
7800
diff
changeset
|
83 |
case FOUNDATION_INCLINED_X: |
8174
5343705d60f5
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
84 |
*s = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? SLOPE_SW : SLOPE_NE); |
7831
5dded9b03500
(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:
7800
diff
changeset
|
85 |
break; |
5dded9b03500
(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:
7800
diff
changeset
|
86 |
|
5dded9b03500
(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:
7800
diff
changeset
|
87 |
case FOUNDATION_INCLINED_Y: |
8174
5343705d60f5
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
88 |
*s = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? SLOPE_SE : SLOPE_NW); |
7831
5dded9b03500
(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:
7800
diff
changeset
|
89 |
break; |
5dded9b03500
(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:
7800
diff
changeset
|
90 |
|
5dded9b03500
(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:
7800
diff
changeset
|
91 |
case FOUNDATION_STEEP_LOWER: |
8174
5343705d60f5
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
92 |
*s = SlopeWithOneCornerRaised(highest_corner); |
7831
5dded9b03500
(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:
7800
diff
changeset
|
93 |
break; |
5dded9b03500
(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:
7800
diff
changeset
|
94 |
|
5dded9b03500
(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:
7800
diff
changeset
|
95 |
case FOUNDATION_STEEP_HIGHER: |
8174
5343705d60f5
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
96 |
*s = SlopeWithThreeCornersRaised(OppositeCorner(highest_corner)); |
7831
5dded9b03500
(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:
7800
diff
changeset
|
97 |
break; |
5dded9b03500
(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:
7800
diff
changeset
|
98 |
|
5dded9b03500
(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:
7800
diff
changeset
|
99 |
default: NOT_REACHED(); |
5dded9b03500
(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:
7800
diff
changeset
|
100 |
} |
5dded9b03500
(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:
7800
diff
changeset
|
101 |
return dz; |
5dded9b03500
(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:
7800
diff
changeset
|
102 |
} |
5dded9b03500
(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:
7800
diff
changeset
|
103 |
|
0 | 104 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
105 |
uint GetPartialZ(int x, int y, Slope corners) |
0 | 106 |
{ |
8260
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
107 |
if (IsHalftileSlope(corners)) { |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
108 |
switch (GetHalftileSlopeCorner(corners)) { |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
109 |
case CORNER_W: |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
110 |
if (x - y >= 0) return GetSlopeMaxZ(corners); |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
111 |
break; |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
112 |
|
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
113 |
case CORNER_S: |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
114 |
if (x - (y ^ 0xF) >= 0) return GetSlopeMaxZ(corners); |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
115 |
break; |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
116 |
|
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
117 |
case CORNER_E: |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
118 |
if (y - x >= 0) return GetSlopeMaxZ(corners); |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
119 |
break; |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
120 |
|
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
121 |
case CORNER_N: |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
122 |
if ((y ^ 0xF) - x >= 0) return GetSlopeMaxZ(corners); |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
123 |
break; |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
124 |
|
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
125 |
default: NOT_REACHED(); |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
126 |
} |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
127 |
} |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
128 |
|
0 | 129 |
int z = 0; |
130 |
||
8260
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
131 |
switch (corners & ~SLOPE_HALFTILE_MASK) { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
132 |
case SLOPE_W: |
0 | 133 |
if (x - y >= 0) |
134 |
z = (x - y) >> 1; |
|
135 |
break; |
|
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
136 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
137 |
case SLOPE_S: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
138 |
y ^= 0xF; |
0 | 139 |
if ( (x - y) >= 0) |
140 |
z = (x - y) >> 1; |
|
141 |
break; |
|
142 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
143 |
case SLOPE_SW: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
144 |
z = (x >> 1) + 1; |
0 | 145 |
break; |
146 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
147 |
case SLOPE_E: |
0 | 148 |
if (y - x >= 0) |
149 |
z = (y - x) >> 1; |
|
150 |
break; |
|
151 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
152 |
case SLOPE_EW: |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
153 |
case SLOPE_NS: |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
154 |
case SLOPE_ELEVATED: |
0 | 155 |
z = 4; |
156 |
break; |
|
157 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
158 |
case SLOPE_SE: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
159 |
z = (y >> 1) + 1; |
0 | 160 |
break; |
161 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
162 |
case SLOPE_WSE: |
0 | 163 |
z = 8; |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
164 |
y ^= 0xF; |
0 | 165 |
if (x - y < 0) |
166 |
z += (x - y) >> 1; |
|
167 |
break; |
|
168 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
169 |
case SLOPE_N: |
0 | 170 |
y ^= 0xF; |
171 |
if (y - x >= 0) |
|
172 |
z = (y - x) >> 1; |
|
173 |
break; |
|
174 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
175 |
case SLOPE_NW: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
176 |
z = (y ^ 0xF) >> 1; |
0 | 177 |
break; |
178 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
179 |
case SLOPE_NWS: |
0 | 180 |
z = 8; |
181 |
if (x - y < 0) |
|
182 |
z += (x - y) >> 1; |
|
183 |
break; |
|
184 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
185 |
case SLOPE_NE: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
186 |
z = (x ^ 0xF) >> 1; |
0 | 187 |
break; |
188 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
189 |
case SLOPE_ENW: |
0 | 190 |
z = 8; |
191 |
y ^= 0xF; |
|
192 |
if (y - x < 0) |
|
193 |
z += (y - x) >> 1; |
|
194 |
break; |
|
195 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
196 |
case SLOPE_SEN: |
0 | 197 |
z = 8; |
198 |
if (y - x < 0) |
|
199 |
z += (y - x) >> 1; |
|
200 |
break; |
|
201 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
202 |
case SLOPE_STEEP_S: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
203 |
z = 1 + ((x + y) >> 1); |
0 | 204 |
break; |
205 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
206 |
case SLOPE_STEEP_W: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
207 |
z = 1 + ((x + (y ^ 0xF)) >> 1); |
0 | 208 |
break; |
209 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
210 |
case SLOPE_STEEP_N: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
211 |
z = 1 + (((x ^ 0xF) + (y ^ 0xF)) >> 1); |
0 | 212 |
break; |
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
213 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
214 |
case SLOPE_STEEP_E: |
7800
d169a75aff9a
(svn r10656) -Fix [FS#1068]: GetPartialZ returned wrong value for SLOPE_STEEP_E (frosch)
truelight
parents:
7539
diff
changeset
|
215 |
z = 1 + (((x ^ 0xF) + y) >> 1); |
0 | 216 |
break; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
217 |
|
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
218 |
default: break; |
0 | 219 |
} |
220 |
||
221 |
return z; |
|
222 |
} |
|
223 |
||
2951 | 224 |
uint GetSlopeZ(int x, int y) |
0 | 225 |
{ |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
226 |
TileIndex tile = TileVirtXY(x, y); |
0 | 227 |
|
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
228 |
return _tile_type_procs[GetTileType(tile)]->get_slope_z_proc(tile, x, y); |
0 | 229 |
} |
230 |
||
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
231 |
/** |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
232 |
* Determine the Z height of the corners of a specific tile edge |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
233 |
* |
8260
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
234 |
* @note If a tile has a non-continuous halftile foundation, a corner can have different heights wrt. it's edges. |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
235 |
* |
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
236 |
* @pre z1 and z2 must be initialized (typ. with TileZ). The corner heights just get added. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
237 |
* |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
238 |
* @param tileh The slope of the tile. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
239 |
* @param edge The edge of interest. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
240 |
* @param z1 Gets incremented by the height of the first corner of the edge. (near corner wrt. the camera) |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
241 |
* @param z2 Gets incremented by the height of the second corner of the edge. (far corner wrt. the camera) |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
242 |
*/ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
243 |
void GetSlopeZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2) |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
244 |
{ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
245 |
static const Slope corners[4][4] = { |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
246 |
/* corner | steep slope |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
247 |
* z1 z2 | z1 z2 */ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
248 |
{SLOPE_E, SLOPE_N, SLOPE_STEEP_E, SLOPE_STEEP_N}, // DIAGDIR_NE, z1 = E, z2 = N |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
249 |
{SLOPE_S, SLOPE_E, SLOPE_STEEP_S, SLOPE_STEEP_E}, // DIAGDIR_SE, z1 = S, z2 = E |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
250 |
{SLOPE_S, SLOPE_W, SLOPE_STEEP_S, SLOPE_STEEP_W}, // DIAGDIR_SW, z1 = S, z2 = W |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
251 |
{SLOPE_W, SLOPE_N, SLOPE_STEEP_W, SLOPE_STEEP_N}, // DIAGDIR_NW, z1 = W, z2 = N |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
252 |
}; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
253 |
|
8260
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
254 |
int halftile_test = (IsHalftileSlope(tileh) ? SlopeWithOneCornerRaised(GetHalftileSlopeCorner(tileh)) : 0); |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
255 |
if (halftile_test == corners[edge][0]) *z2 += TILE_HEIGHT; // The slope is non-continuous in z2. z2 is on the upper side. |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
256 |
if (halftile_test == corners[edge][1]) *z1 += TILE_HEIGHT; // The slope is non-continuous in z1. z1 is on the upper side. |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
257 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
258 |
if ((tileh & corners[edge][0]) != 0) *z1 += TILE_HEIGHT; // z1 is raised |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
259 |
if ((tileh & corners[edge][1]) != 0) *z2 += TILE_HEIGHT; // z2 is raised |
8260
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
260 |
if ((tileh & ~SLOPE_HALFTILE_MASK) == corners[edge][2]) *z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
261 |
if ((tileh & ~SLOPE_HALFTILE_MASK) == corners[edge][3]) *z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope |
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
262 |
} |
4061
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
263 |
|
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
264 |
static 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
|
265 |
{ |
4061
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
266 |
Slope tileh = GetTileSlope(tile, z); |
7831
5dded9b03500
(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:
7800
diff
changeset
|
267 |
Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh); |
5dded9b03500
(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:
7800
diff
changeset
|
268 |
*z += ApplyFoundationToSlope(f, &tileh); |
5dded9b03500
(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:
7800
diff
changeset
|
269 |
return tileh; |
4061
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
270 |
} |
39 | 271 |
|
4061
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
272 |
|
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
273 |
static bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here) |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
274 |
{ |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
275 |
uint z; |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
276 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
277 |
int z_W_here = z_here; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
278 |
int z_N_here = z_here; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
279 |
GetSlopeZOnEdge(slope_here, DIAGDIR_NW, &z_W_here, &z_N_here); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
280 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
281 |
Slope slope = GetFoundationSlope(TILE_ADDXY(tile, 0, -1), &z); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
282 |
int z_W = z; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
283 |
int z_N = z; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
284 |
GetSlopeZOnEdge(slope, DIAGDIR_SE, &z_W, &z_N); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
285 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
286 |
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
|
287 |
} |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
288 |
|
4061
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
289 |
|
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
290 |
static bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here) |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
291 |
{ |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
292 |
uint z; |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
293 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
294 |
int z_E_here = z_here; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
295 |
int z_N_here = z_here; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
296 |
GetSlopeZOnEdge(slope_here, DIAGDIR_NE, &z_E_here, &z_N_here); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
297 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
298 |
Slope slope = GetFoundationSlope(TILE_ADDXY(tile, -1, 0), &z); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
299 |
int z_E = z; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
300 |
int z_N = z; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
301 |
GetSlopeZOnEdge(slope, DIAGDIR_SW, &z_E, &z_N); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
302 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
303 |
return (z_N_here > z_N) || (z_E_here > z_E); |
4061
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
304 |
} |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
305 |
|
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
306 |
|
7831
5dded9b03500
(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:
7800
diff
changeset
|
307 |
void DrawFoundation(TileInfo *ti, Foundation f) |
0 | 308 |
{ |
7831
5dded9b03500
(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:
7800
diff
changeset
|
309 |
if (!IsFoundation(f)) return; |
5dded9b03500
(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:
7800
diff
changeset
|
310 |
|
5dded9b03500
(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:
7800
diff
changeset
|
311 |
SpriteID sprite_base = SPR_SLOPES_VIRTUAL_BASE; |
4061
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
312 |
uint z; |
7831
5dded9b03500
(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:
7800
diff
changeset
|
313 |
Slope slope = GetFoundationSlope(ti->tile, &z); |
39 | 314 |
|
7831
5dded9b03500
(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:
7800
diff
changeset
|
315 |
if (!HasFoundationNW(ti->tile, slope, z)) sprite_base += SPR_SLOPES_NO_FOUNDATION_NW_OFFSET; |
5dded9b03500
(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:
7800
diff
changeset
|
316 |
if (!HasFoundationNE(ti->tile, slope, z)) sprite_base += SPR_SLOPES_NO_FOUNDATION_NE_OFFSET; |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
317 |
|
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
318 |
if (IsSteepSlope(ti->tileh)) { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5847
diff
changeset
|
319 |
SpriteID lower_base; |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
320 |
|
7831
5dded9b03500
(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:
7800
diff
changeset
|
321 |
/* Lower part of foundation |
5dded9b03500
(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:
7800
diff
changeset
|
322 |
* Use the original slope sprites if NW and NE borders should be visible |
5dded9b03500
(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:
7800
diff
changeset
|
323 |
*/ |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
324 |
lower_base = sprite_base; |
7831
5dded9b03500
(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:
7800
diff
changeset
|
325 |
if (lower_base == SPR_SLOPES_VIRTUAL_BASE) lower_base = SPR_FOUNDATION_BASE; |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
326 |
AddSortableSpriteToDraw( |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5847
diff
changeset
|
327 |
lower_base + (ti->tileh & ~SLOPE_STEEP), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
328 |
); |
7831
5dded9b03500
(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:
7800
diff
changeset
|
329 |
|
8174
5343705d60f5
(svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
330 |
Corner highest_corner = GetHighestSlopeCorner(ti->tileh); |
7831
5dded9b03500
(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:
7800
diff
changeset
|
331 |
ti->z += ApplyFoundationToSlope(f, &ti->tileh); |
5dded9b03500
(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:
7800
diff
changeset
|
332 |
|
5dded9b03500
(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:
7800
diff
changeset
|
333 |
if (IsInclinedFoundation(f)) { |
5dded9b03500
(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:
7800
diff
changeset
|
334 |
/* inclined foundation */ |
5dded9b03500
(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:
7800
diff
changeset
|
335 |
byte inclined = highest_corner * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0); |
5dded9b03500
(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:
7800
diff
changeset
|
336 |
|
5dded9b03500
(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:
7800
diff
changeset
|
337 |
AddSortableSpriteToDraw(sprite_base + SPR_SLOPES_INCLINED_OFFSET + inclined, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z); |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
338 |
OffsetGroundSprite(31, 9); |
7831
5dded9b03500
(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:
7800
diff
changeset
|
339 |
} else if (f >= FOUNDATION_STEEP_HIGHER) { |
5dded9b03500
(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:
7800
diff
changeset
|
340 |
/* three corners raised: |
5dded9b03500
(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:
7800
diff
changeset
|
341 |
* Draw inclined foundations for both axes, that results in the needed image. |
5dded9b03500
(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:
7800
diff
changeset
|
342 |
*/ |
5dded9b03500
(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:
7800
diff
changeset
|
343 |
SpriteID upper = sprite_base + SPR_SLOPES_INCLINED_OFFSET + highest_corner * 2; |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
344 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5847
diff
changeset
|
345 |
AddSortableSpriteToDraw(upper, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5847
diff
changeset
|
346 |
AddChildSpriteScreen(upper + 1, PAL_NONE, 31, 9); |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
347 |
OffsetGroundSprite(31, 9); |
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
348 |
} else { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6432
diff
changeset
|
349 |
/* one corner raised */ |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
350 |
OffsetGroundSprite(31, 1); |
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
351 |
} |
0 | 352 |
} else { |
7831
5dded9b03500
(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:
7800
diff
changeset
|
353 |
if (IsLeveledFoundation(f)) { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6432
diff
changeset
|
354 |
/* leveled foundation |
7831
5dded9b03500
(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:
7800
diff
changeset
|
355 |
* Use the original slope sprites if NW and NE borders should be visible |
5dded9b03500
(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:
7800
diff
changeset
|
356 |
*/ |
5dded9b03500
(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:
7800
diff
changeset
|
357 |
if (sprite_base == SPR_SLOPES_VIRTUAL_BASE) sprite_base = SPR_FOUNDATION_BASE; |
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4240
diff
changeset
|
358 |
|
7831
5dded9b03500
(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:
7800
diff
changeset
|
359 |
AddSortableSpriteToDraw(sprite_base + ti->tileh, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z); |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
360 |
OffsetGroundSprite(31, 1); |
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
361 |
} else { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6432
diff
changeset
|
362 |
/* inclined foundation */ |
7831
5dded9b03500
(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:
7800
diff
changeset
|
363 |
byte inclined = GetHighestSlopeCorner(ti->tileh) * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0); |
5dded9b03500
(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:
7800
diff
changeset
|
364 |
|
5dded9b03500
(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:
7800
diff
changeset
|
365 |
AddSortableSpriteToDraw(sprite_base + SPR_SLOPES_INCLINED_OFFSET + inclined, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z); |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
366 |
OffsetGroundSprite(31, 9); |
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4240
diff
changeset
|
367 |
} |
7831
5dded9b03500
(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:
7800
diff
changeset
|
368 |
ti->z += ApplyFoundationToSlope(f, &ti->tileh); |
0 | 369 |
} |
370 |
} |
|
371 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
372 |
void DoClearSquare(TileIndex tile) |
0 | 373 |
{ |
3447 | 374 |
MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0); |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
375 |
MarkTileDirtyByTile(tile); |
0 | 376 |
} |
377 |
||
7179
3e123c2b7c93
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents:
6987
diff
changeset
|
378 |
uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode) |
0 | 379 |
{ |
7179
3e123c2b7c93
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents:
6987
diff
changeset
|
380 |
return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode, sub_mode); |
0 | 381 |
} |
382 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
383 |
void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 384 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
385 |
_tile_type_procs[GetTileType(tile)]->change_tile_owner_proc(tile, old_player, new_player); |
0 | 386 |
} |
387 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
388 |
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac) |
0 | 389 |
{ |
390 |
memset(ac, 0, sizeof(AcceptedCargo)); |
|
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
391 |
_tile_type_procs[GetTileType(tile)]->get_accepted_cargo_proc(tile, ac); |
0 | 392 |
} |
393 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
394 |
void AnimateTile(TileIndex tile) |
0 | 395 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
396 |
_tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile); |
0 | 397 |
} |
398 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
399 |
void ClickTile(TileIndex tile) |
0 | 400 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
401 |
_tile_type_procs[GetTileType(tile)]->click_tile_proc(tile); |
0 | 402 |
} |
403 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
404 |
void GetTileDesc(TileIndex tile, TileDesc *td) |
0 | 405 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
406 |
_tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td); |
0 | 407 |
} |
408 |
||
6669
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
409 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
410 |
* Has a snow line table already been loaded. |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
411 |
* @return true if the table has been loaded already. |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
412 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
413 |
bool IsSnowLineSet(void) |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
414 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
415 |
return _snow_line != NULL; |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
416 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
417 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
418 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
419 |
* Set a variable snow line, as loaded from a newgrf file. |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
420 |
* @param table the 12 * 32 byte table containing the snowline for each day |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
421 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
422 |
void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]) |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
423 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
424 |
_snow_line = CallocT<SnowLine>(1); |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
425 |
memcpy(_snow_line->table, table, sizeof(_snow_line->table)); |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
426 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
427 |
for (uint i = 0; i < SNOW_LINE_MONTHS; i++) { |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
428 |
for (uint j = 0; j < SNOW_LINE_DAYS; j++) { |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
429 |
_snow_line->highest_value = max(_snow_line->highest_value, table[i][j]); |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
430 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
431 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
432 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
433 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
434 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
435 |
* Get the current snow line, either variable or static. |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
436 |
* @return the snow line height. |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
437 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
438 |
byte GetSnowLine(void) |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
439 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
440 |
if (_snow_line == NULL) return _opt.snow_line; |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
441 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
442 |
YearMonthDay ymd; |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
443 |
ConvertDateToYMD(_date, &ymd); |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
444 |
return _snow_line->table[ymd.month][ymd.day]; |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
445 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
446 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
447 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
448 |
* Get the highest possible snow line height, either variable or static. |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
449 |
* @return the highest snow line height. |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
450 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
451 |
byte HighestSnowLine(void) |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
452 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
453 |
return _snow_line == NULL ? _opt.snow_line : _snow_line->highest_value; |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
454 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
455 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
456 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
457 |
* Clear the variable snow line table and free the memory. |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
458 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
459 |
void ClearSnowLine(void) |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
460 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
461 |
free(_snow_line); |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
462 |
_snow_line = NULL; |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
463 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
464 |
|
1775
08ff0f12ccdc
(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
|
465 |
/** Clear a piece of landscape |
3491
4c8427796c64
(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
|
466 |
* @param tile tile to clear |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6432
diff
changeset
|
467 |
* @param flags of operation to conduct |
1775
08ff0f12ccdc
(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
|
468 |
* @param p1 unused |
08ff0f12ccdc
(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
|
469 |
* @param p2 unused |
0 | 470 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7179
diff
changeset
|
471 |
CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 472 |
{ |
473 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
474 |
||
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
475 |
return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags); |
0 | 476 |
} |
477 |
||
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
478 |
/** Clear a big piece of landscape |
3491
4c8427796c64
(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
|
479 |
* @param tile end tile of area dragging |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
480 |
* @param p1 start tile of area dragging |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6432
diff
changeset
|
481 |
* @param flags of operation to conduct |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
482 |
* @param p2 unused |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
483 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7179
diff
changeset
|
484 |
CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 485 |
{ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7179
diff
changeset
|
486 |
CommandCost cost, ret, money; |
3491
4c8427796c64
(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
|
487 |
int ex; |
4c8427796c64
(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
|
488 |
int ey; |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
489 |
int sx, sy; |
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
490 |
int x, y; |
0 | 491 |
bool success = false; |
492 |
||
2934
3b7eef9871f8
(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
|
493 |
if (p1 >= MapSize()) return CMD_ERROR; |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
494 |
|
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
863
diff
changeset
|
495 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
863
diff
changeset
|
496 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6432
diff
changeset
|
497 |
/* make sure sx,sy are smaller than ex,ey */ |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
498 |
ex = TileX(tile); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
499 |
ey = TileY(tile); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
500 |
sx = TileX(p1); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
501 |
sy = TileY(p1); |
6432 | 502 |
if (ex < sx) Swap(ex, sx); |
503 |
if (ey < sy) Swap(ey, sy); |
|
0 | 504 |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
505 |
money.AddCost(GetAvailableMoneyForCommand()); |
0 | 506 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
507 |
for (x = sx; x <= ex; ++x) { |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
508 |
for (y = sy; y <= ey; ++y) { |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
509 |
ret = DoCommand(TileXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR); |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
510 |
if (CmdFailed(ret)) continue; |
0 | 511 |
success = true; |
512 |
||
513 |
if (flags & DC_EXEC) { |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
514 |
money.AddCost(-ret.GetCost()); |
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
515 |
if (ret.GetCost() > 0 && money.GetCost() < 0) { |
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
516 |
_additional_cash_required = ret.GetCost(); |
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
517 |
return cost; |
0 | 518 |
} |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
519 |
DoCommand(TileXY(x, y), 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
0 | 520 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6432
diff
changeset
|
521 |
/* draw explosion animation... */ |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
522 |
if ((x == sx || x == ex) && (y == sy || y == ey)) { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6432
diff
changeset
|
523 |
/* big explosion in each corner, or small explosion for single tiles */ |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3636
diff
changeset
|
524 |
CreateEffectVehicleAbove(x * TILE_SIZE + TILE_SIZE / 2, y * TILE_SIZE + TILE_SIZE / 2, 2, |
1359
8ba976aed634
(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
|
525 |
sy == ey && sx == ex ? EV_EXPLOSION_SMALL : EV_EXPLOSION_LARGE |
8ba976aed634
(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
|
526 |
); |
0 | 527 |
} |
528 |
} |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
529 |
cost.AddCost(ret); |
0 | 530 |
} |
531 |
} |
|
532 |
||
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
533 |
return (success) ? cost : CMD_ERROR; |
0 | 534 |
} |
535 |
||
536 |
||
537 |
#define TILELOOP_BITS 4 |
|
538 |
#define TILELOOP_SIZE (1 << TILELOOP_BITS) |
|
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
539 |
#define TILELOOP_ASSERTMASK ((TILELOOP_SIZE - 1) + ((TILELOOP_SIZE - 1) << MapLogX())) |
927
28f45a22a564
(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
|
540 |
#define TILELOOP_CHKMASK (((1 << (MapLogX() - TILELOOP_BITS))-1) << TILELOOP_BITS) |
0 | 541 |
|
6573 | 542 |
void RunTileLoop() |
0 | 543 |
{ |
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
544 |
TileIndex tile; |
0 | 545 |
uint count; |
546 |
||
547 |
tile = _cur_tileloop_tile; |
|
548 |
||
549 |
assert( (tile & ~TILELOOP_ASSERTMASK) == 0); |
|
863
8d09f9331a80
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
857
diff
changeset
|
550 |
count = (MapSizeX() / TILELOOP_SIZE) * (MapSizeY() / TILELOOP_SIZE); |
0 | 551 |
do { |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
552 |
_tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile); |
0 | 553 |
|
926
bd4312619522
(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
|
554 |
if (TileX(tile) < MapSizeX() - TILELOOP_SIZE) { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6432
diff
changeset
|
555 |
tile += TILELOOP_SIZE; // no overflow |
0 | 556 |
} else { |
1981 | 557 |
tile = TILE_MASK(tile - TILELOOP_SIZE * (MapSizeX() / TILELOOP_SIZE - 1) + TileDiffXY(0, TILELOOP_SIZE)); /* x would overflow, also increase y */ |
0 | 558 |
} |
559 |
} while (--count); |
|
560 |
assert( (tile & ~TILELOOP_ASSERTMASK) == 0); |
|
561 |
||
562 |
tile += 9; |
|
563 |
if (tile & TILELOOP_CHKMASK) |
|
863
8d09f9331a80
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
857
diff
changeset
|
564 |
tile = (tile + MapSizeX()) & TILELOOP_ASSERTMASK; |
0 | 565 |
_cur_tileloop_tile = tile; |
566 |
} |
|
567 |
||
6573 | 568 |
void InitializeLandscape() |
0 | 569 |
{ |
3078
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
570 |
uint maxx = MapMaxX(); |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
571 |
uint maxy = MapMaxY(); |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
572 |
uint sizex = MapSizeX(); |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
573 |
uint x; |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
574 |
uint y; |
1218 | 575 |
|
3078
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
576 |
for (y = 0; y < maxy; y++) { |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
577 |
for (x = 0; x < maxx; x++) { |
3447 | 578 |
MakeClear(sizex * y + x, CLEAR_GRASS, 3); |
3078
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
579 |
SetTileHeight(sizex * y + x, 0); |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
580 |
SetTropicZone(sizex * y + x, TROPICZONE_INVALID); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4990
diff
changeset
|
581 |
ClearBridgeMiddle(sizex * y + x); |
3078
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
582 |
} |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
583 |
MakeVoid(sizex * y + x); |
2049
ad0d49c916d4
(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
|
584 |
} |
3078
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
585 |
for (x = 0; x < sizex; x++) MakeVoid(sizex * y + x); |
0 | 586 |
} |
587 |
||
6573 | 588 |
void ConvertGroundTilesIntoWaterTiles() |
0 | 589 |
{ |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
590 |
TileIndex tile; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
591 |
uint z; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
592 |
Slope slope; |
0 | 593 |
|
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
594 |
for (tile = 0; tile < MapSize(); ++tile) { |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
595 |
slope = GetTileSlope(tile, &z); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
596 |
if (IsTileType(tile, MP_CLEAR) && z == 0) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
597 |
/* Make both water for tiles at level 0 |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
598 |
* and make shore, as that looks much better |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
599 |
* during the generation. */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
600 |
switch (slope) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
601 |
case SLOPE_FLAT: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
602 |
MakeWater(tile); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
603 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
604 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
605 |
case SLOPE_N: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
606 |
case SLOPE_E: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
607 |
case SLOPE_S: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
608 |
case SLOPE_W: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
609 |
case SLOPE_NW: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
610 |
case SLOPE_SW: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
611 |
case SLOPE_SE: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
612 |
case SLOPE_NE: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
613 |
MakeShore(tile); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
614 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
615 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
616 |
default: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
617 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
618 |
} |
0 | 619 |
} |
620 |
} |
|
621 |
} |
|
622 |
||
4344
5d0e40cd67b9
(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
|
623 |
static const byte _genterrain_tbl_1[5] = { 10, 22, 33, 37, 4 }; |
5d0e40cd67b9
(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
|
624 |
static const byte _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 }; |
0 | 625 |
|
626 |
static void GenerateTerrain(int type, int flag) |
|
627 |
{ |
|
628 |
uint32 r; |
|
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
629 |
uint x; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
630 |
uint y; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
631 |
uint w; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
632 |
uint h; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
633 |
const Sprite* templ; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
634 |
const byte *p; |
2049
ad0d49c916d4
(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
|
635 |
Tile* tile; |
0 | 636 |
byte direction; |
637 |
||
638 |
r = Random(); |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
639 |
templ = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845); |
0 | 640 |
|
856
07dc27d0503e
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
851
diff
changeset
|
641 |
x = r & MapMaxX(); |
927
28f45a22a564
(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
|
642 |
y = (r >> MapLogX()) & MapMaxY(); |
0 | 643 |
|
644 |
||
2951 | 645 |
if (x < 2 || y < 2) return; |
0 | 646 |
|
2140
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
2055
diff
changeset
|
647 |
direction = GB(r, 22, 2); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
648 |
if (direction & 1) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
649 |
w = templ->height; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
650 |
h = templ->width; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
651 |
} else { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
652 |
w = templ->width; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
653 |
h = templ->height; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
654 |
} |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
655 |
p = templ->data; |
0 | 656 |
|
657 |
if (flag & 4) { |
|
1273
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
658 |
uint xw = x * MapSizeY(); |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
659 |
uint yw = y * MapSizeX(); |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
660 |
uint bias = (MapSizeX() + MapSizeY()) * 16; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
661 |
|
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
662 |
switch (flag & 3) { |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
663 |
case 0: |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
664 |
if (xw + yw > MapSize() - bias) return; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
665 |
break; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
666 |
|
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
667 |
case 1: |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
668 |
if (yw < xw + bias) return; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
669 |
break; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
670 |
|
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
671 |
case 2: |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
672 |
if (xw + yw < MapSize() + bias) return; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
673 |
break; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
674 |
|
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
675 |
case 3: |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
676 |
if (xw < yw + bias) return; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
677 |
break; |
0 | 678 |
} |
679 |
} |
|
680 |
||
2951 | 681 |
if (x + w >= MapMaxX() - 1) return; |
682 |
if (y + h >= MapMaxY() - 1) return; |
|
0 | 683 |
|
2049
ad0d49c916d4
(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
|
684 |
tile = &_m[TileXY(x, y)]; |
0 | 685 |
|
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
686 |
switch (direction) { |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
687 |
case 0: |
0 | 688 |
do { |
2049
ad0d49c916d4
(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
|
689 |
Tile* tile_cur = tile; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
690 |
uint w_cur; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
691 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
692 |
for (w_cur = w; w_cur != 0; --w_cur) { |
2049
ad0d49c916d4
(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
|
693 |
if (*p >= tile_cur->type_height) tile_cur->type_height = *p; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
694 |
p++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
695 |
tile_cur++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
696 |
} |
1981 | 697 |
tile += TileDiffXY(0, 1); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
698 |
} while (--h != 0); |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
699 |
break; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
700 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
701 |
case 1: |
0 | 702 |
do { |
2049
ad0d49c916d4
(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
|
703 |
Tile* tile_cur = tile; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
704 |
uint h_cur; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
705 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
706 |
for (h_cur = h; h_cur != 0; --h_cur) { |
2049
ad0d49c916d4
(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
|
707 |
if (*p >= tile_cur->type_height) tile_cur->type_height = *p; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
708 |
p++; |
1981 | 709 |
tile_cur += TileDiffXY(0, 1); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
710 |
} |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
711 |
tile++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
712 |
} while (--w != 0); |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
713 |
break; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
714 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
715 |
case 2: |
1981 | 716 |
tile += TileDiffXY(w - 1, 0); |
0 | 717 |
do { |
2049
ad0d49c916d4
(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
|
718 |
Tile* tile_cur = tile; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
719 |
uint w_cur; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
720 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
721 |
for (w_cur = w; w_cur != 0; --w_cur) { |
2049
ad0d49c916d4
(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
|
722 |
if (*p >= tile_cur->type_height) tile_cur->type_height = *p; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
723 |
p++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
724 |
tile_cur--; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
725 |
} |
1981 | 726 |
tile += TileDiffXY(0, 1); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
727 |
} while (--h != 0); |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
728 |
break; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
729 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
730 |
case 3: |
1981 | 731 |
tile += TileDiffXY(0, h - 1); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
732 |
do { |
2049
ad0d49c916d4
(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
|
733 |
Tile* tile_cur = tile; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
734 |
uint h_cur; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
735 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
736 |
for (h_cur = h; h_cur != 0; --h_cur) { |
2049
ad0d49c916d4
(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
|
737 |
if (*p >= tile_cur->type_height) tile_cur->type_height = *p; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
738 |
p++; |
1981 | 739 |
tile_cur -= TileDiffXY(0, 1); |
1278
1fbb6cf8d3f1
(svn r1782) Remove line which should've been removed in r1779 and caused map generation to hang infinitely
tron
parents:
1275
diff
changeset
|
740 |
} |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
741 |
tile++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
742 |
} while (--w != 0); |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
743 |
break; |
0 | 744 |
} |
745 |
} |
|
746 |
||
747 |
||
748 |
#include "table/genland.h" |
|
749 |
||
6573 | 750 |
static void CreateDesertOrRainForest() |
0 | 751 |
{ |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
752 |
TileIndex tile; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
753 |
TileIndex update_freq = MapSize() / 4; |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
754 |
const TileIndexDiffC *data; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
755 |
uint i; |
0 | 756 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
757 |
for (tile = 0; tile != MapSize(); ++tile) { |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
758 |
if ((tile % update_freq) == 0) IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
759 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
760 |
for (data = _make_desert_or_rainforest_data; |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
761 |
data != endof(_make_desert_or_rainforest_data); ++data) { |
1184
7f0ac9482dad
(svn r1686) Fix (Work around?) crash when generating tropical maps
tron
parents:
1181
diff
changeset
|
762 |
TileIndex t = TILE_MASK(tile + ToTileIndexDiff(*data)); |
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
763 |
if (TileHeight(t) >= 4 || IsTileType(t, MP_WATER)) break; |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
764 |
} |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
765 |
if (data == endof(_make_desert_or_rainforest_data)) |
3379
ea8aa9e71328
(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
|
766 |
SetTropicZone(tile, TROPICZONE_DESERT); |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
767 |
} |
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
768 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
769 |
for (i = 0; i != 256; i++) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
770 |
if ((i % 64) == 0) IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
771 |
|
0 | 772 |
RunTileLoop(); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
773 |
} |
0 | 774 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
775 |
for (tile = 0; tile != MapSize(); ++tile) { |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
776 |
if ((tile % update_freq) == 0) IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
777 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
778 |
for (data = _make_desert_or_rainforest_data; |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
779 |
data != endof(_make_desert_or_rainforest_data); ++data) { |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
780 |
TileIndex t = TILE_MASK(tile + ToTileIndexDiff(*data)); |
3447 | 781 |
if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_DESERT)) break; |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
782 |
} |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
783 |
if (data == endof(_make_desert_or_rainforest_data)) |
3379
ea8aa9e71328
(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
|
784 |
SetTropicZone(tile, TROPICZONE_RAINFOREST); |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
785 |
} |
0 | 786 |
} |
787 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
788 |
void GenerateLandscape(byte mode) |
0 | 789 |
{ |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
790 |
const int gwp_desert_amount = 4 + 8; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
791 |
uint i; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
792 |
uint flag; |
0 | 793 |
uint32 r; |
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
794 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
795 |
if (mode == GW_HEIGHTMAP) { |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
796 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, (_opt.landscape == LT_TROPIC) ? 1 + gwp_desert_amount : 1); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
797 |
LoadHeightmap(_file_to_saveload.name); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
798 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
799 |
} else if (_patches.land_generator == LG_TERRAGENESIS) { |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
800 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, (_opt.landscape == LT_TROPIC) ? 3 + gwp_desert_amount : 3); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
801 |
GenerateTerrainPerlin(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
802 |
} else { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
803 |
switch (_opt.landscape) { |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
804 |
case LT_ARCTIC: |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
805 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, 2); |
0 | 806 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
807 |
for (i = ScaleByMapSize((Random() & 0x7F) + 950); i != 0; --i) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
808 |
GenerateTerrain(2, 0); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
809 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
810 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
3017
915fae59d5e0
(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
|
811 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
812 |
r = Random(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
813 |
flag = GB(r, 0, 2) | 4; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
814 |
for (i = ScaleByMapSize(GB(r, 16, 7) + 450); i != 0; --i) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
815 |
GenerateTerrain(4, flag); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
816 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
817 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
818 |
break; |
3017
915fae59d5e0
(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
|
819 |
|
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
820 |
case LT_TROPIC: |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
821 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, 3 + gwp_desert_amount); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
822 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
823 |
for (i = ScaleByMapSize((Random() & 0x7F) + 170); i != 0; --i) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
824 |
GenerateTerrain(0, 0); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
825 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
826 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
827 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
828 |
r = Random(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
829 |
flag = GB(r, 0, 2) | 4; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
830 |
for (i = ScaleByMapSize(GB(r, 16, 8) + 1700); i != 0; --i) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
831 |
GenerateTerrain(0, flag); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
832 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
833 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
834 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
835 |
flag ^= 2; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
836 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
837 |
for (i = ScaleByMapSize((Random() & 0x7F) + 410); i != 0; --i) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
838 |
GenerateTerrain(3, flag); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
839 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
840 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
841 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
842 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
843 |
default: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
844 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, 1); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
845 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
846 |
i = ScaleByMapSize((Random() & 0x7F) + (3 - _opt.diff.quantity_sea_lakes) * 256 + 100); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
847 |
for (; i != 0; --i) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
848 |
GenerateTerrain(_opt.diff.terrain_type, 0); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
849 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
850 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
851 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
852 |
} |
0 | 853 |
} |
854 |
||
855 |
ConvertGroundTilesIntoWaterTiles(); |
|
856 |
||
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
857 |
if (_opt.landscape == LT_TROPIC) CreateDesertOrRainForest(); |
0 | 858 |
} |
859 |
||
6573 | 860 |
void OnTick_Town(); |
861 |
void OnTick_Trees(); |
|
862 |
void OnTick_Station(); |
|
863 |
void OnTick_Industry(); |
|
0 | 864 |
|
6573 | 865 |
void OnTick_Players(); |
866 |
void OnTick_Train(); |
|
0 | 867 |
|
6573 | 868 |
void CallLandscapeTick() |
0 | 869 |
{ |
870 |
OnTick_Town(); |
|
871 |
OnTick_Trees(); |
|
872 |
OnTick_Station(); |
|
873 |
OnTick_Industry(); |
|
874 |
||
875 |
OnTick_Players(); |
|
876 |
OnTick_Train(); |
|
877 |
} |
|
878 |
||
879 |
TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng) |
|
880 |
{ |
|
881 |
int rn = rng; |
|
882 |
uint32 r = Random(); |
|
883 |
||
1981 | 884 |
return TILE_MASK(TileXY( |
2150
010d923a81a9
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2140
diff
changeset
|
885 |
TileX(a) + (GB(r, 0, 8) * rn * 2 >> 8) - rn, |
010d923a81a9
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2140
diff
changeset
|
886 |
TileY(a) + (GB(r, 8, 8) * rn * 2 >> 8) - rn |
1174
27e386195965
(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
|
887 |
)); |
0 | 888 |
} |
889 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
890 |
bool IsValidTile(TileIndex tile) |
0 | 891 |
{ |
926
bd4312619522
(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
|
892 |
return (tile < MapSizeX() * MapMaxY() && TileX(tile) != MapMaxX()); |
0 | 893 |
} |