3 #include "stdafx.h" |
3 #include "stdafx.h" |
4 #include "openttd.h" |
4 #include "openttd.h" |
5 #include "bridge_map.h" |
5 #include "bridge_map.h" |
6 #include "heightmap.h" |
6 #include "heightmap.h" |
7 #include "clear_map.h" |
7 #include "clear_map.h" |
|
8 #include "date.h" |
8 #include "functions.h" |
9 #include "functions.h" |
9 #include "map.h" |
10 #include "map.h" |
10 #include "player.h" |
11 #include "player.h" |
11 #include "spritecache.h" |
12 #include "spritecache.h" |
12 #include "table/sprites.h" |
13 #include "table/sprites.h" |
13 #include "tile.h" |
14 #include "tile.h" |
14 #include <stdarg.h> |
15 #include <stdarg.h> |
15 #include "viewport.h" |
16 #include "viewport.h" |
16 #include "command.h" |
17 #include "command.h" |
|
18 #include "landscape.h" |
17 #include "vehicle.h" |
19 #include "vehicle.h" |
18 #include "variables.h" |
20 #include "variables.h" |
19 #include "void_map.h" |
21 #include "void_map.h" |
20 #include "water_map.h" |
22 #include "water_map.h" |
21 #include "tgp.h" |
23 #include "tgp.h" |
59 SLOPE_SW, SLOPE_NW, SLOPE_SW, SLOPE_SE, SLOPE_NE, SLOPE_SE, SLOPE_NE, SLOPE_NW, |
61 SLOPE_SW, SLOPE_NW, SLOPE_SW, SLOPE_SE, SLOPE_NE, SLOPE_SE, SLOPE_NE, SLOPE_NW, |
60 SLOPE_E, SLOPE_N, SLOPE_W, SLOPE_S, |
62 SLOPE_E, SLOPE_N, SLOPE_W, SLOPE_S, |
61 SLOPE_NWS, SLOPE_WSE, SLOPE_SEN, SLOPE_ENW |
63 SLOPE_NWS, SLOPE_WSE, SLOPE_SEN, SLOPE_ENW |
62 }; |
64 }; |
63 |
65 |
|
66 SnowLine *_snow_line = NULL; |
64 |
67 |
65 uint GetPartialZ(int x, int y, Slope corners) |
68 uint GetPartialZ(int x, int y, Slope corners) |
66 { |
69 { |
67 int z = 0; |
70 int z = 0; |
68 |
71 |
300 void GetTileDesc(TileIndex tile, TileDesc *td) |
303 void GetTileDesc(TileIndex tile, TileDesc *td) |
301 { |
304 { |
302 _tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td); |
305 _tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td); |
303 } |
306 } |
304 |
307 |
|
308 /** |
|
309 * Has a snow line table already been loaded. |
|
310 * @return true if the table has been loaded already. |
|
311 */ |
|
312 bool IsSnowLineSet(void) |
|
313 { |
|
314 return _snow_line != NULL; |
|
315 } |
|
316 |
|
317 /** |
|
318 * Set a variable snow line, as loaded from a newgrf file. |
|
319 * @param table the 12 * 32 byte table containing the snowline for each day |
|
320 */ |
|
321 void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]) |
|
322 { |
|
323 _snow_line = CallocT<SnowLine>(1); |
|
324 memcpy(_snow_line->table, table, sizeof(_snow_line->table)); |
|
325 |
|
326 for (uint i = 0; i < SNOW_LINE_MONTHS; i++) { |
|
327 for (uint j = 0; j < SNOW_LINE_DAYS; j++) { |
|
328 _snow_line->highest_value = max(_snow_line->highest_value, table[i][j]); |
|
329 } |
|
330 } |
|
331 } |
|
332 |
|
333 /** |
|
334 * Get the current snow line, either variable or static. |
|
335 * @return the snow line height. |
|
336 */ |
|
337 byte GetSnowLine(void) |
|
338 { |
|
339 if (_snow_line == NULL) return _opt.snow_line; |
|
340 |
|
341 YearMonthDay ymd; |
|
342 ConvertDateToYMD(_date, &ymd); |
|
343 return _snow_line->table[ymd.month][ymd.day]; |
|
344 } |
|
345 |
|
346 /** |
|
347 * Get the highest possible snow line height, either variable or static. |
|
348 * @return the highest snow line height. |
|
349 */ |
|
350 byte HighestSnowLine(void) |
|
351 { |
|
352 return _snow_line == NULL ? _opt.snow_line : _snow_line->highest_value; |
|
353 } |
|
354 |
|
355 /** |
|
356 * Clear the variable snow line table and free the memory. |
|
357 */ |
|
358 void ClearSnowLine(void) |
|
359 { |
|
360 free(_snow_line); |
|
361 _snow_line = NULL; |
|
362 } |
|
363 |
305 /** Clear a piece of landscape |
364 /** Clear a piece of landscape |
306 * @param tile tile to clear |
365 * @param tile tile to clear |
307 * @param flags of operation to conduct |
366 * @param flags of operation to conduct |
308 * @param p1 unused |
367 * @param p1 unused |
309 * @param p2 unused |
368 * @param p2 unused |