author | belugas |
Tue, 04 Mar 2008 17:07:33 +0000 | |
changeset 9168 | a35d94d8501c |
parent 9147 | 54271cd8f27f |
child 9313 | 5593ea43406b |
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" |
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
|
8 |
#include "spritecache.h" |
0 | 9 |
#include <stdarg.h> |
8721
b7971ad9bdd9
(svn r11788) -Fix (11787): makedepend doesn't mark delete files as changed...
rubidium
parents:
8647
diff
changeset
|
10 |
#include "viewport_func.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8604
diff
changeset
|
11 |
#include "command_func.h" |
6669
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
12 |
#include "landscape.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2154
diff
changeset
|
13 |
#include "variables.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3111
diff
changeset
|
14 |
#include "void_map.h" |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3078
diff
changeset
|
15 |
#include "water_map.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
16 |
#include "tgp.h" |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
17 |
#include "genworld.h" |
8615
6b91ca653bad
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8612
diff
changeset
|
18 |
#include "tile_cmd.h" |
8626
440dfcd14c4a
(svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents:
8615
diff
changeset
|
19 |
#include "core/alloc_func.hpp" |
8647
0709611186e0
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents:
8640
diff
changeset
|
20 |
#include "fios.h" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
21 |
#include "window_func.h" |
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
22 |
#include "functions.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8635
diff
changeset
|
23 |
#include "date_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8636
diff
changeset
|
24 |
#include "vehicle_func.h" |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8760
diff
changeset
|
25 |
#include "settings_type.h" |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8766
diff
changeset
|
26 |
#include "water.h" |
0 | 27 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
28 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
29 |
|
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
30 |
extern const TileTypeProcs |
0 | 31 |
_tile_type_clear_procs, |
32 |
_tile_type_rail_procs, |
|
33 |
_tile_type_road_procs, |
|
34 |
_tile_type_town_procs, |
|
35 |
_tile_type_trees_procs, |
|
36 |
_tile_type_station_procs, |
|
37 |
_tile_type_water_procs, |
|
38 |
_tile_type_dummy_procs, |
|
39 |
_tile_type_industry_procs, |
|
40 |
_tile_type_tunnelbridge_procs, |
|
41 |
_tile_type_unmovable_procs; |
|
42 |
||
43 |
const TileTypeProcs * const _tile_type_procs[16] = { |
|
44 |
&_tile_type_clear_procs, |
|
45 |
&_tile_type_rail_procs, |
|
46 |
&_tile_type_road_procs, |
|
47 |
&_tile_type_town_procs, |
|
48 |
&_tile_type_trees_procs, |
|
49 |
&_tile_type_station_procs, |
|
50 |
&_tile_type_water_procs, |
|
51 |
&_tile_type_dummy_procs, |
|
52 |
&_tile_type_industry_procs, |
|
53 |
&_tile_type_tunnelbridge_procs, |
|
54 |
&_tile_type_unmovable_procs, |
|
55 |
}; |
|
56 |
||
57 |
/* landscape slope => sprite */ |
|
58 |
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
|
59 |
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
|
60 |
0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 17, 0, 15, 18, 0, |
0 | 61 |
}; |
62 |
||
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
|
63 |
SnowLine *_snow_line = NULL; |
1958
625d71cd6898
(svn r2464) Move definition of _inclined_tileh out of variables.h
tron
parents:
1902
diff
changeset
|
64 |
|
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
|
65 |
/** |
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 |
* 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
|
67 |
* |
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 |
* @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
|
69 |
* @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
|
70 |
* @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
|
71 |
* @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
|
72 |
*/ |
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 |
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
|
74 |
{ |
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 |
|
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 |
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
|
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 |
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
|
79 |
*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
|
80 |
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
|
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 |
|
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
83 |
if (f != FOUNDATION_STEEP_BOTH && IsNonContinuousFoundation(f)) { |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
84 |
*s = HalftileSlope(*s, GetHalftileFoundationCorner(f)); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
85 |
return 0; |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
86 |
} |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
87 |
|
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
88 |
if (IsSpecialRailFoundation(f)) { |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
89 |
*s = SlopeWithThreeCornersRaised(OppositeCorner(GetRailFoundationCorner(f))); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
90 |
return 0; |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
91 |
} |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
92 |
|
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 |
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
|
94 |
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
|
95 |
|
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
|
96 |
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
|
97 |
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
|
98 |
*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
|
99 |
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
|
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 |
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
|
102 |
*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
|
103 |
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
|
104 |
|
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
|
105 |
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
|
106 |
*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
|
107 |
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
|
108 |
|
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
109 |
case FOUNDATION_STEEP_BOTH: |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
110 |
*s = HalftileSlope(SlopeWithOneCornerRaised(highest_corner), 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
|
111 |
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
|
112 |
|
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
|
113 |
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
|
114 |
} |
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
|
115 |
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
|
116 |
} |
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
|
117 |
|
0 | 118 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
119 |
uint GetPartialZ(int x, int y, Slope corners) |
0 | 120 |
{ |
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
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
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
|
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 |
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
|
128 |
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
|
129 |
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
|
130 |
|
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 |
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
|
132 |
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
|
133 |
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
|
134 |
|
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
135 |
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
|
136 |
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
|
137 |
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
|
138 |
|
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
139 |
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
|
140 |
} |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
141 |
} |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8224
diff
changeset
|
142 |
|
0 | 143 |
int z = 0; |
144 |
||
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
145 |
switch (RemoveHalftileSlope(corners)) { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
146 |
case SLOPE_W: |
0 | 147 |
if (x - y >= 0) |
148 |
z = (x - y) >> 1; |
|
149 |
break; |
|
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
150 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
151 |
case SLOPE_S: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
152 |
y ^= 0xF; |
0 | 153 |
if ( (x - y) >= 0) |
154 |
z = (x - y) >> 1; |
|
155 |
break; |
|
156 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
157 |
case SLOPE_SW: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
158 |
z = (x >> 1) + 1; |
0 | 159 |
break; |
160 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
161 |
case SLOPE_E: |
0 | 162 |
if (y - x >= 0) |
163 |
z = (y - x) >> 1; |
|
164 |
break; |
|
165 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
166 |
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
|
167 |
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
|
168 |
case SLOPE_ELEVATED: |
0 | 169 |
z = 4; |
170 |
break; |
|
171 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
172 |
case SLOPE_SE: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
173 |
z = (y >> 1) + 1; |
0 | 174 |
break; |
175 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
176 |
case SLOPE_WSE: |
0 | 177 |
z = 8; |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
178 |
y ^= 0xF; |
0 | 179 |
if (x - y < 0) |
180 |
z += (x - y) >> 1; |
|
181 |
break; |
|
182 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
183 |
case SLOPE_N: |
0 | 184 |
y ^= 0xF; |
185 |
if (y - x >= 0) |
|
186 |
z = (y - x) >> 1; |
|
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_NW: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
190 |
z = (y ^ 0xF) >> 1; |
0 | 191 |
break; |
192 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
193 |
case SLOPE_NWS: |
0 | 194 |
z = 8; |
195 |
if (x - y < 0) |
|
196 |
z += (x - y) >> 1; |
|
197 |
break; |
|
198 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
199 |
case SLOPE_NE: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
200 |
z = (x ^ 0xF) >> 1; |
0 | 201 |
break; |
202 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
203 |
case SLOPE_ENW: |
0 | 204 |
z = 8; |
205 |
y ^= 0xF; |
|
206 |
if (y - x < 0) |
|
207 |
z += (y - x) >> 1; |
|
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_SEN: |
0 | 211 |
z = 8; |
212 |
if (y - x < 0) |
|
213 |
z += (y - x) >> 1; |
|
214 |
break; |
|
215 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
216 |
case SLOPE_STEEP_S: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
217 |
z = 1 + ((x + y) >> 1); |
0 | 218 |
break; |
219 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
220 |
case SLOPE_STEEP_W: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
221 |
z = 1 + ((x + (y ^ 0xF)) >> 1); |
0 | 222 |
break; |
223 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
224 |
case SLOPE_STEEP_N: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
225 |
z = 1 + (((x ^ 0xF) + (y ^ 0xF)) >> 1); |
0 | 226 |
break; |
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
227 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
228 |
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
|
229 |
z = 1 + (((x ^ 0xF) + y) >> 1); |
0 | 230 |
break; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
231 |
|
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3529
diff
changeset
|
232 |
default: break; |
0 | 233 |
} |
234 |
||
235 |
return z; |
|
236 |
} |
|
237 |
||
2951 | 238 |
uint GetSlopeZ(int x, int y) |
0 | 239 |
{ |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
240 |
TileIndex tile = TileVirtXY(x, y); |
0 | 241 |
|
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
242 |
return _tile_type_procs[GetTileType(tile)]->get_slope_z_proc(tile, x, y); |
0 | 243 |
} |
244 |
||
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
245 |
/** |
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
246 |
* Determine the Z height of a corner relative to TileZ. |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
247 |
* |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
248 |
* @pre The slope must not be a halftile slope. |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
249 |
* |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
250 |
* @param tileh The slope. |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
251 |
* @param corner The corner. |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
252 |
* @return Z position of corner relative to TileZ. |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
253 |
*/ |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
254 |
int GetSlopeZInCorner(Slope tileh, Corner corner) |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
255 |
{ |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
256 |
assert(!IsHalftileSlope(tileh)); |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
257 |
return ((tileh & SlopeWithOneCornerRaised(corner)) != 0 ? TILE_HEIGHT : 0) + (tileh == SteepSlope(corner) ? TILE_HEIGHT : 0); |
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
258 |
} |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
259 |
|
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
260 |
/** |
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
261 |
* 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
|
262 |
* |
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
|
263 |
* @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
|
264 |
* |
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
265 |
* @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
|
266 |
* |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
267 |
* @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
|
268 |
* @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
|
269 |
* @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
|
270 |
* @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
|
271 |
*/ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
272 |
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
|
273 |
{ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
274 |
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
|
275 |
/* corner | steep slope |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
276 |
* 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
|
277 |
{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
|
278 |
{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
|
279 |
{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
|
280 |
{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
|
281 |
}; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
282 |
|
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
|
283 |
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
|
284 |
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
|
285 |
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
|
286 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
287 |
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
|
288 |
if ((tileh & corners[edge][1]) != 0) *z2 += TILE_HEIGHT; // z2 is raised |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
289 |
if (RemoveHalftileSlope(tileh) == corners[edge][2]) *z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope |
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
290 |
if (RemoveHalftileSlope(tileh) == 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
|
291 |
} |
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
|
292 |
|
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
293 |
/** |
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
294 |
* Get slope of a tile on top of a (possible) foundation |
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
295 |
* If a tile does not have a foundation, the function returns the same as GetTileSlope. |
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
296 |
* |
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
297 |
* @param tile The tile of interest. |
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
298 |
* @param z returns the z of the foundation slope. (Can be NULL, if not needed) |
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
299 |
* @return The slope on top of the foundation. |
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8876
diff
changeset
|
300 |
*/ |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8766
diff
changeset
|
301 |
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
|
302 |
{ |
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
|
303 |
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
|
304 |
Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh); |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8766
diff
changeset
|
305 |
uint z_inc = ApplyFoundationToSlope(f, &tileh); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8766
diff
changeset
|
306 |
if (z != NULL) *z += z_inc; |
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 |
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
|
308 |
} |
39 | 309 |
|
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
|
310 |
|
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
311 |
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
|
312 |
{ |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
313 |
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
|
314 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
315 |
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
|
316 |
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
|
317 |
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
|
318 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
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
|
323 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
324 |
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
|
325 |
} |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
326 |
|
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
|
327 |
|
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
328 |
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
|
329 |
{ |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
330 |
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
|
331 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
332 |
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
|
333 |
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
|
334 |
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
|
335 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
336 |
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
|
337 |
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
|
338 |
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
|
339 |
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
|
340 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8174
diff
changeset
|
341 |
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
|
342 |
} |
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
343 |
|
219f9d065a28
(svn r5351) -Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
tron
parents:
4000
diff
changeset
|
344 |
|
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
|
345 |
void DrawFoundation(TileInfo *ti, Foundation f) |
0 | 346 |
{ |
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
|
347 |
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
|
348 |
|
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
349 |
/* Two part foundations must be drawn separately */ |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
350 |
assert(f != FOUNDATION_STEEP_BOTH); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
351 |
|
8263
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
352 |
uint sprite_block = 0; |
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
|
353 |
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
|
354 |
Slope slope = GetFoundationSlope(ti->tile, &z); |
39 | 355 |
|
8263
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
356 |
/* Select the needed block of foundations sprites |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
357 |
* Block 0: Walls at NW and NE edge |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
358 |
* Block 1: Wall at NE edge |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
359 |
* Block 2: Wall at NW edge |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
360 |
* Block 3: No walls at NW or NE edge |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
361 |
*/ |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
362 |
if (!HasFoundationNW(ti->tile, slope, z)) sprite_block += 1; |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
363 |
if (!HasFoundationNE(ti->tile, slope, z)) sprite_block += 2; |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
364 |
|
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
365 |
/* Use the original slope sprites if NW and NE borders should be visible */ |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
366 |
SpriteID leveled_base = (sprite_block == 0 ? (int)SPR_FOUNDATION_BASE : (SPR_SLOPES_VIRTUAL_BASE + sprite_block * SPR_TRKFOUND_BLOCK_SIZE)); |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
367 |
SpriteID inclined_base = SPR_SLOPES_VIRTUAL_BASE + SPR_SLOPES_INCLINED_OFFSET + sprite_block * SPR_TRKFOUND_BLOCK_SIZE; |
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
368 |
SpriteID halftile_base = SPR_HALFTILE_FOUNDATION_BASE + sprite_block * SPR_HALFTILE_BLOCK_SIZE; |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
369 |
|
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
370 |
if (IsSteepSlope(ti->tileh)) { |
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
371 |
if (!IsNonContinuousFoundation(f)) { |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
372 |
/* Lower part of foundation */ |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
373 |
AddSortableSpriteToDraw( |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
374 |
leveled_base + (ti->tileh & ~SLOPE_STEEP), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
375 |
); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
376 |
} |
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
|
377 |
|
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
|
378 |
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
|
379 |
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
|
380 |
|
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
|
381 |
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
|
382 |
/* 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
|
383 |
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
|
384 |
|
8263
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
385 |
AddSortableSpriteToDraw(inclined_base + 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
|
386 |
OffsetGroundSprite(31, 9); |
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
387 |
} else if (f == FOUNDATION_STEEP_LOWER) { |
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
|
388 |
/* one corner raised */ |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
389 |
OffsetGroundSprite(31, 1); |
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
390 |
} else { |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
391 |
/* halftile foundation */ |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
392 |
int x_bb = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? 8 : 0); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
393 |
int y_bb = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? 8 : 0); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
394 |
|
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
395 |
AddSortableSpriteToDraw(halftile_base + highest_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z + TILE_HEIGHT); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
396 |
OffsetGroundSprite(31, 9); |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
397 |
} |
0 | 398 |
} 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
|
399 |
if (IsLeveledFoundation(f)) { |
8263
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
400 |
/* leveled foundation */ |
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
401 |
AddSortableSpriteToDraw(leveled_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
|
402 |
OffsetGroundSprite(31, 1); |
8266
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
403 |
} else if (IsNonContinuousFoundation(f)) { |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
404 |
/* halftile foundation */ |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
405 |
Corner halftile_corner = GetHalftileFoundationCorner(f); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
406 |
int x_bb = (((halftile_corner == CORNER_W) || (halftile_corner == CORNER_S)) ? 8 : 0); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
407 |
int y_bb = (((halftile_corner == CORNER_S) || (halftile_corner == CORNER_E)) ? 8 : 0); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
408 |
|
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
409 |
AddSortableSpriteToDraw(halftile_base + halftile_corner, PAL_NONE, ti->x + x_bb, ti->y + y_bb, 8, 8, 7, ti->z); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
410 |
OffsetGroundSprite(31, 9); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
411 |
} else if (IsSpecialRailFoundation(f)) { |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
412 |
/* anti-zig-zag foundation */ |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
413 |
SpriteID spr; |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
414 |
if (ti->tileh == SLOPE_NS || ti->tileh == SLOPE_EW) { |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
415 |
/* half of leveled foundation under track corner */ |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
416 |
spr = leveled_base + SlopeWithThreeCornersRaised(GetRailFoundationCorner(f)); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
417 |
} else { |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
418 |
/* tile-slope = sloped along X/Y, foundation-slope = three corners raised */ |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
419 |
spr = inclined_base + 2 * GetRailFoundationCorner(f) + ((ti->tileh == SLOPE_SW || ti->tileh == SLOPE_NE) ? 1 : 0); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
420 |
} |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
421 |
AddSortableSpriteToDraw(spr, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z); |
48fa6a084b98
(svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents:
8263
diff
changeset
|
422 |
OffsetGroundSprite(31, 9); |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
423 |
} 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
|
424 |
/* 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
|
425 |
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
|
426 |
|
8263
cf890c002a88
(svn r11316) -Codechange: add support for the half-tile (selection) graphics.
rubidium
parents:
8260
diff
changeset
|
427 |
AddSortableSpriteToDraw(inclined_base + 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
|
428 |
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
|
429 |
} |
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
|
430 |
ti->z += ApplyFoundationToSlope(f, &ti->tileh); |
0 | 431 |
} |
432 |
} |
|
433 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
434 |
void DoClearSquare(TileIndex tile) |
0 | 435 |
{ |
3447 | 436 |
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
|
437 |
MarkTileDirtyByTile(tile); |
0 | 438 |
} |
439 |
||
9112
ec6800eaa340
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
9092
diff
changeset
|
440 |
/** Returns information about trackdirs and signal states. |
9092
383a632de666
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8946
diff
changeset
|
441 |
* If there is any trackbit at 'side', return all trackdirbits. |
9112
ec6800eaa340
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
9092
diff
changeset
|
442 |
* For TRANSPORT_ROAD, return no trackbits if there is no roadbit (of given subtype) at given side. |
9092
383a632de666
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8946
diff
changeset
|
443 |
* @param tile tile to get info about |
383a632de666
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8946
diff
changeset
|
444 |
* @param mode transport type |
383a632de666
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8946
diff
changeset
|
445 |
* @param sub_mode for TRANSPORT_ROAD, roadtypes to check |
383a632de666
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8946
diff
changeset
|
446 |
* @param side side we are entering from, INVALID_DIAGDIR to return all trackbits |
383a632de666
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8946
diff
changeset
|
447 |
* @return trackdirbits and other info depending on 'mode' |
383a632de666
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8946
diff
changeset
|
448 |
*/ |
9112
ec6800eaa340
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
9092
diff
changeset
|
449 |
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
0 | 450 |
{ |
9092
383a632de666
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz
parents:
8946
diff
changeset
|
451 |
return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode, sub_mode, side); |
0 | 452 |
} |
453 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
454 |
void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 455 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
456 |
_tile_type_procs[GetTileType(tile)]->change_tile_owner_proc(tile, old_player, new_player); |
0 | 457 |
} |
458 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
459 |
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac) |
0 | 460 |
{ |
461 |
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
|
462 |
_tile_type_procs[GetTileType(tile)]->get_accepted_cargo_proc(tile, ac); |
0 | 463 |
} |
464 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
465 |
void AnimateTile(TileIndex tile) |
0 | 466 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
467 |
_tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile); |
0 | 468 |
} |
469 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
470 |
void ClickTile(TileIndex tile) |
0 | 471 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
472 |
_tile_type_procs[GetTileType(tile)]->click_tile_proc(tile); |
0 | 473 |
} |
474 |
||
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
475 |
void GetTileDesc(TileIndex tile, TileDesc *td) |
0 | 476 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
477 |
_tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td); |
0 | 478 |
} |
479 |
||
6669
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
480 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
481 |
* 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
|
482 |
* @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
|
483 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
484 |
bool IsSnowLineSet(void) |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
485 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
486 |
return _snow_line != NULL; |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
487 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
488 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
489 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
490 |
* 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
|
491 |
* @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
|
492 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
493 |
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
|
494 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
495 |
_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
|
496 |
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
|
497 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
498 |
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
|
499 |
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
|
500 |
_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
|
501 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
502 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
503 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
504 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
505 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
506 |
* 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
|
507 |
* @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
|
508 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
509 |
byte GetSnowLine(void) |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
510 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
511 |
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
|
512 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
513 |
YearMonthDay ymd; |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
514 |
ConvertDateToYMD(_date, &ymd); |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
515 |
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
|
516 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
517 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
518 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
519 |
* 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
|
520 |
* @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
|
521 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
522 |
byte HighestSnowLine(void) |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
523 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
524 |
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
|
525 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
526 |
|
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
527 |
/** |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
528 |
* 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
|
529 |
*/ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
530 |
void ClearSnowLine(void) |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
531 |
{ |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
532 |
free(_snow_line); |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
533 |
_snow_line = NULL; |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
534 |
} |
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6573
diff
changeset
|
535 |
|
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
|
536 |
/** 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
|
537 |
* @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
|
538 |
* @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
|
539 |
* @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
|
540 |
* @param p2 unused |
0 | 541 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7179
diff
changeset
|
542 |
CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 543 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
544 |
return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags); |
0 | 545 |
} |
546 |
||
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
547 |
/** 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
|
548 |
* @param tile end tile of area dragging |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
549 |
* @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
|
550 |
* @param flags of operation to conduct |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
551 |
* @param p2 unused |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
552 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7179
diff
changeset
|
553 |
CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 554 |
{ |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8721
diff
changeset
|
555 |
CommandCost ret, money; |
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8721
diff
changeset
|
556 |
CommandCost cost(EXPENSES_CONSTRUCTION); |
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
|
557 |
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
|
558 |
int ey; |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
559 |
int sx, sy; |
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
560 |
int x, y; |
0 | 561 |
bool success = false; |
562 |
||
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
|
563 |
if (p1 >= MapSize()) return CMD_ERROR; |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
564 |
|
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
|
565 |
/* 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
|
566 |
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
|
567 |
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
|
568 |
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
|
569 |
sy = TileY(p1); |
6432 | 570 |
if (ex < sx) Swap(ex, sx); |
571 |
if (ey < sy) Swap(ey, sy); |
|
0 | 572 |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
573 |
money.AddCost(GetAvailableMoneyForCommand()); |
0 | 574 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
575 |
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
|
576 |
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
|
577 |
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
|
578 |
if (CmdFailed(ret)) continue; |
0 | 579 |
success = true; |
580 |
||
581 |
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
|
582 |
money.AddCost(-ret.GetCost()); |
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
583 |
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
|
584 |
_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
|
585 |
return cost; |
0 | 586 |
} |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
587 |
DoCommand(TileXY(x, y), 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
0 | 588 |
|
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
|
589 |
/* draw explosion animation... */ |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
590 |
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
|
591 |
/* 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
|
592 |
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
|
593 |
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
|
594 |
); |
0 | 595 |
} |
596 |
} |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
597 |
cost.AddCost(ret); |
0 | 598 |
} |
599 |
} |
|
600 |
||
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
601 |
return (success) ? cost : CMD_ERROR; |
0 | 602 |
} |
603 |
||
604 |
||
605 |
#define TILELOOP_BITS 4 |
|
606 |
#define TILELOOP_SIZE (1 << TILELOOP_BITS) |
|
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6683
diff
changeset
|
607 |
#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
|
608 |
#define TILELOOP_CHKMASK (((1 << (MapLogX() - TILELOOP_BITS))-1) << TILELOOP_BITS) |
0 | 609 |
|
6573 | 610 |
void RunTileLoop() |
0 | 611 |
{ |
1589
58d173b56509
(svn r2093) uint -> TileIndex, remove commented out code and a local variable, which was only used once
tron
parents:
1384
diff
changeset
|
612 |
TileIndex tile; |
0 | 613 |
uint count; |
614 |
||
615 |
tile = _cur_tileloop_tile; |
|
616 |
||
617 |
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
|
618 |
count = (MapSizeX() / TILELOOP_SIZE) * (MapSizeY() / TILELOOP_SIZE); |
0 | 619 |
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
|
620 |
_tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile); |
0 | 621 |
|
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
|
622 |
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
|
623 |
tile += TILELOOP_SIZE; // no overflow |
0 | 624 |
} else { |
1981 | 625 |
tile = TILE_MASK(tile - TILELOOP_SIZE * (MapSizeX() / TILELOOP_SIZE - 1) + TileDiffXY(0, TILELOOP_SIZE)); /* x would overflow, also increase y */ |
0 | 626 |
} |
627 |
} while (--count); |
|
628 |
assert( (tile & ~TILELOOP_ASSERTMASK) == 0); |
|
629 |
||
630 |
tile += 9; |
|
631 |
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
|
632 |
tile = (tile + MapSizeX()) & TILELOOP_ASSERTMASK; |
0 | 633 |
_cur_tileloop_tile = tile; |
634 |
} |
|
635 |
||
6573 | 636 |
void InitializeLandscape() |
0 | 637 |
{ |
3078
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
638 |
uint maxx = MapMaxX(); |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
639 |
uint maxy = MapMaxY(); |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
640 |
uint sizex = MapSizeX(); |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
641 |
uint x; |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
642 |
uint y; |
1218 | 643 |
|
3078
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
644 |
for (y = 0; y < maxy; y++) { |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
645 |
for (x = 0; x < maxx; x++) { |
3447 | 646 |
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
|
647 |
SetTileHeight(sizex * y + x, 0); |
8946
85eff1ad8cda
(svn r12020) -Documentation: Correct description of TropicZone.
frosch
parents:
8909
diff
changeset
|
648 |
SetTropicZone(sizex * y + x, TROPICZONE_NORMAL); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4990
diff
changeset
|
649 |
ClearBridgeMiddle(sizex * y + x); |
3078
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
650 |
} |
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
651 |
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
|
652 |
} |
3078
ae74442bd058
(svn r3667) Fix the cause of an assertion I triggered in r3665
tron
parents:
3076
diff
changeset
|
653 |
for (x = 0; x < sizex; x++) MakeVoid(sizex * y + x); |
0 | 654 |
} |
655 |
||
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
|
656 |
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
|
657 |
static const byte _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 }; |
0 | 658 |
|
659 |
static void GenerateTerrain(int type, int flag) |
|
660 |
{ |
|
661 |
uint32 r; |
|
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
662 |
uint x; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
663 |
uint y; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
664 |
uint w; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
665 |
uint h; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
666 |
const Sprite* templ; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
667 |
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
|
668 |
Tile* tile; |
0 | 669 |
byte direction; |
670 |
||
671 |
r = Random(); |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
672 |
templ = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845); |
0 | 673 |
|
856
07dc27d0503e
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
851
diff
changeset
|
674 |
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
|
675 |
y = (r >> MapLogX()) & MapMaxY(); |
0 | 676 |
|
677 |
||
2951 | 678 |
if (x < 2 || y < 2) return; |
0 | 679 |
|
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
|
680 |
direction = GB(r, 22, 2); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
681 |
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
|
682 |
w = templ->height; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
683 |
h = templ->width; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
684 |
} else { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
685 |
w = templ->width; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
686 |
h = templ->height; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
687 |
} |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
688 |
p = templ->data; |
0 | 689 |
|
690 |
if (flag & 4) { |
|
1273
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
691 |
uint xw = x * MapSizeY(); |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
692 |
uint yw = y * MapSizeX(); |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
693 |
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
|
694 |
|
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
695 |
switch (flag & 3) { |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
696 |
case 0: |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
697 |
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
|
698 |
break; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
699 |
|
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
700 |
case 1: |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
701 |
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
|
702 |
break; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
703 |
|
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
704 |
case 2: |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
705 |
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
|
706 |
break; |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
707 |
|
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
708 |
case 3: |
240fa6848fbc
(svn r1777) Fix map generation for tropical and arctic landscape on larger/smaller maps
tron
parents:
1247
diff
changeset
|
709 |
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
|
710 |
break; |
0 | 711 |
} |
712 |
} |
|
713 |
||
2951 | 714 |
if (x + w >= MapMaxX() - 1) return; |
715 |
if (y + h >= MapMaxY() - 1) return; |
|
0 | 716 |
|
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
|
717 |
tile = &_m[TileXY(x, y)]; |
0 | 718 |
|
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
719 |
switch (direction) { |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
720 |
case 0: |
0 | 721 |
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
|
722 |
Tile* tile_cur = tile; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
723 |
uint w_cur; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
724 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
725 |
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
|
726 |
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
|
727 |
p++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
728 |
tile_cur++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
729 |
} |
1981 | 730 |
tile += TileDiffXY(0, 1); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
731 |
} while (--h != 0); |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
732 |
break; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
733 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
734 |
case 1: |
0 | 735 |
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
|
736 |
Tile* tile_cur = tile; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
737 |
uint h_cur; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
738 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
739 |
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
|
740 |
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
|
741 |
p++; |
1981 | 742 |
tile_cur += TileDiffXY(0, 1); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
743 |
} |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
744 |
tile++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
745 |
} while (--w != 0); |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
746 |
break; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
747 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
748 |
case 2: |
1981 | 749 |
tile += TileDiffXY(w - 1, 0); |
0 | 750 |
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
|
751 |
Tile* tile_cur = tile; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
752 |
uint w_cur; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
753 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
754 |
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
|
755 |
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
|
756 |
p++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
757 |
tile_cur--; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
758 |
} |
1981 | 759 |
tile += TileDiffXY(0, 1); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
760 |
} while (--h != 0); |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
761 |
break; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
762 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
763 |
case 3: |
1981 | 764 |
tile += TileDiffXY(0, h - 1); |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
765 |
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
|
766 |
Tile* tile_cur = tile; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
767 |
uint h_cur; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
768 |
|
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
769 |
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
|
770 |
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
|
771 |
p++; |
1981 | 772 |
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
|
773 |
} |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
774 |
tile++; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
775 |
} while (--w != 0); |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
776 |
break; |
0 | 777 |
} |
778 |
} |
|
779 |
||
780 |
||
781 |
#include "table/genland.h" |
|
782 |
||
6573 | 783 |
static void CreateDesertOrRainForest() |
0 | 784 |
{ |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
785 |
TileIndex tile; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
786 |
TileIndex update_freq = MapSize() / 4; |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
787 |
const TileIndexDiffC *data; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
788 |
uint i; |
0 | 789 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
790 |
for (tile = 0; tile != MapSize(); ++tile) { |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
791 |
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
|
792 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
793 |
for (data = _make_desert_or_rainforest_data; |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
794 |
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
|
795 |
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
|
796 |
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
|
797 |
} |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
798 |
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
|
799 |
SetTropicZone(tile, TROPICZONE_DESERT); |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
800 |
} |
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
801 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
802 |
for (i = 0; i != 256; i++) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
803 |
if ((i % 64) == 0) IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
804 |
|
0 | 805 |
RunTileLoop(); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
806 |
} |
0 | 807 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
808 |
for (tile = 0; tile != MapSize(); ++tile) { |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
809 |
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
|
810 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
811 |
for (data = _make_desert_or_rainforest_data; |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
812 |
data != endof(_make_desert_or_rainforest_data); ++data) { |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
813 |
TileIndex t = TILE_MASK(tile + ToTileIndexDiff(*data)); |
3447 | 814 |
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
|
815 |
} |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
816 |
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
|
817 |
SetTropicZone(tile, TROPICZONE_RAINFOREST); |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
818 |
} |
0 | 819 |
} |
820 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
821 |
void GenerateLandscape(byte mode) |
0 | 822 |
{ |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
823 |
const int gwp_desert_amount = 4 + 8; |
1275
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
824 |
uint i; |
10f4edfafb5a
(svn r1779) Make the map generation code slightly more readable
tron
parents:
1273
diff
changeset
|
825 |
uint flag; |
0 | 826 |
uint32 r; |
183
ec2b02ea4c88
(svn r184) -Fix: starting a new game in DesertLandscape crashed the game
truelight
parents:
159
diff
changeset
|
827 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
828 |
if (mode == GW_HEIGHTMAP) { |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
829 |
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
|
830 |
LoadHeightmap(_file_to_saveload.name); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
831 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
832 |
} 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
|
833 |
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
|
834 |
GenerateTerrainPerlin(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
835 |
} else { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
836 |
switch (_opt.landscape) { |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
837 |
case LT_ARCTIC: |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
838 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, 2); |
0 | 839 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
840 |
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
|
841 |
GenerateTerrain(2, 0); |
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 |
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
|
844 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
845 |
r = Random(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
846 |
flag = GB(r, 0, 2) | 4; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
847 |
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
|
848 |
GenerateTerrain(4, flag); |
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; |
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
|
852 |
|
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
853 |
case LT_TROPIC: |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
854 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, 3 + gwp_desert_amount); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
855 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
856 |
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
|
857 |
GenerateTerrain(0, 0); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
858 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
859 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
860 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
861 |
r = Random(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
862 |
flag = GB(r, 0, 2) | 4; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
863 |
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
|
864 |
GenerateTerrain(0, flag); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
865 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
866 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
867 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
868 |
flag ^= 2; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
869 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
870 |
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
|
871 |
GenerateTerrain(3, flag); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
872 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
873 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
874 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
875 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
876 |
default: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
877 |
SetGeneratingWorldProgress(GWP_LANDSCAPE, 1); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
878 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
879 |
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
|
880 |
for (; i != 0; --i) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
881 |
GenerateTerrain(_opt.diff.terrain_type, 0); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
882 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
883 |
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
884 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4253
diff
changeset
|
885 |
} |
0 | 886 |
} |
887 |
||
888 |
ConvertGroundTilesIntoWaterTiles(); |
|
889 |
||
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
890 |
if (_opt.landscape == LT_TROPIC) CreateDesertOrRainForest(); |
0 | 891 |
} |
892 |
||
6573 | 893 |
void OnTick_Town(); |
894 |
void OnTick_Trees(); |
|
895 |
void OnTick_Station(); |
|
896 |
void OnTick_Industry(); |
|
0 | 897 |
|
6573 | 898 |
void OnTick_Players(); |
899 |
void OnTick_Train(); |
|
0 | 900 |
|
6573 | 901 |
void CallLandscapeTick() |
0 | 902 |
{ |
903 |
OnTick_Town(); |
|
904 |
OnTick_Trees(); |
|
905 |
OnTick_Station(); |
|
906 |
OnTick_Industry(); |
|
907 |
||
908 |
OnTick_Players(); |
|
909 |
OnTick_Train(); |
|
910 |
} |
|
911 |
||
912 |
TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng) |
|
913 |
{ |
|
914 |
int rn = rng; |
|
915 |
uint32 r = Random(); |
|
916 |
||
1981 | 917 |
return TILE_MASK(TileXY( |
2150
010d923a81a9
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2140
diff
changeset
|
918 |
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
|
919 |
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
|
920 |
)); |
0 | 921 |
} |