author | Tero Marttila <terom@fixme.fi> |
Fri, 18 Jul 2008 21:28:42 +0300 | |
changeset 11175 | 020c61e39c94 |
parent 10633 | 72128af00ac8 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
8706
e76561c3dd66
(svn r11773) -Codechange: move some non-clear-land functions from clear_cmd.cpp to a more correct location.
rubidium
parents:
8692
diff
changeset
|
3 |
/** @file terraform_cmd.cpp Commands related to terraforming. */ |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1878
diff
changeset
|
6 |
#include "openttd.h" |
8706
e76561c3dd66
(svn r11773) -Codechange: move some non-clear-land functions from clear_cmd.cpp to a more correct location.
rubidium
parents:
8692
diff
changeset
|
7 |
#include "strings_type.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8604
diff
changeset
|
8 |
#include "command_func.h" |
8706
e76561c3dd66
(svn r11773) -Codechange: move some non-clear-land functions from clear_cmd.cpp to a more correct location.
rubidium
parents:
8692
diff
changeset
|
9 |
#include "tile_map.h" |
3156
028b6756b279
(svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents:
3144
diff
changeset
|
10 |
#include "tunnel_map.h" |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4815
diff
changeset
|
11 |
#include "bridge_map.h" |
2153
91e89aa8c299
(svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents:
2150
diff
changeset
|
12 |
#include "variables.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:
8615
diff
changeset
|
13 |
#include "functions.h" |
8634
5ffca02f9115
(svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents:
8627
diff
changeset
|
14 |
#include "economy_func.h" |
0 | 15 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8726
diff
changeset
|
16 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8726
diff
changeset
|
17 |
|
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
18 |
/* |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
19 |
* In one terraforming command all four corners of a initial tile can be raised/lowered (though this is not available to the player). |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
20 |
* The maximal amount of height modifications is archieved when raising a complete flat land from sea level to MAX_TILE_HEIGHT or vice versa. |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
21 |
* This affects all corners with a manhatten distance smaller than MAX_TILE_HEIGHT to one of the initial 4 corners. |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
22 |
* Their maximal amount is computed to 4 * \sum_{i=1}^{h_max} i = 2 * h_max * (h_max + 1). |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
23 |
*/ |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
24 |
static const int TERRAFORMER_MODHEIGHT_SIZE = 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 1); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
25 |
|
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
26 |
/* |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
27 |
* The maximal amount of affected tiles (i.e. the tiles that incident with one of the corners above, is computed similiar to |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
28 |
* 1 + 4 * \sum_{i=1}^{h_max} (i+1) = 1 + 2 * h_max + (h_max + 3). |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
29 |
*/ |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
30 |
static const int TERRAFORMER_TILE_TABLE_SIZE = 1 + 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 3); |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
31 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
32 |
struct TerraformerHeightMod { |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
33 |
TileIndex tile; ///< Referenced tile. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
34 |
byte height; ///< New TileHeight (height of north corner) of the tile. |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
35 |
}; |
0 | 36 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
37 |
struct TerraformerState { |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
38 |
int modheight_count; ///< amount of entries in "modheight". |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
39 |
int tile_table_count; ///< amount of entries in "tile_table". |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
40 |
|
8041
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
41 |
/** |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
42 |
* Dirty tiles, i.e.\ at least one corner changed. |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
43 |
* |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
44 |
* This array contains the tiles which are or will be marked as dirty. |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
45 |
* |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
46 |
* @ingroup dirty |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
47 |
*/ |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
48 |
TileIndex tile_table[TERRAFORMER_TILE_TABLE_SIZE]; |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
49 |
TerraformerHeightMod modheight[TERRAFORMER_MODHEIGHT_SIZE]; ///< Height modifications. |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
50 |
}; |
0 | 51 |
|
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
52 |
TileIndex _terraform_err_tile; ///< first tile we couldn't terraform |
8706
e76561c3dd66
(svn r11773) -Codechange: move some non-clear-land functions from clear_cmd.cpp to a more correct location.
rubidium
parents:
8692
diff
changeset
|
53 |
|
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
54 |
/** |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
55 |
* Gets the TileHeight (height of north corner) of a tile as of current terraforming progress. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
56 |
* |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
57 |
* @param ts TerraformerState. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
58 |
* @param tile Tile. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
59 |
* @return TileHeight. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
60 |
*/ |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
61 |
static int TerraformGetHeightOfTile(const TerraformerState *ts, TileIndex tile) |
0 | 62 |
{ |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
63 |
const TerraformerHeightMod *mod = ts->modheight; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
64 |
|
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
65 |
for (int count = ts->modheight_count; count != 0; count--, mod++) { |
2639 | 66 |
if (mod->tile == tile) return mod->height; |
0 | 67 |
} |
68 |
||
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
69 |
/* TileHeight unchanged so far, read value from map. */ |
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
70 |
return TileHeight(tile); |
0 | 71 |
} |
72 |
||
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
73 |
/** |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
74 |
* Stores the TileHeight (height of north corner) of a tile in a TerraformerState. |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
75 |
* |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
76 |
* @param ts TerraformerState. |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
77 |
* @param tile Tile. |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
78 |
* @param height New TileHeight. |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
79 |
*/ |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
80 |
static void TerraformSetHeightOfTile(TerraformerState *ts, TileIndex tile, int height) |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
81 |
{ |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
82 |
/* Find tile in the "modheight" table. |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
83 |
* Note: In a normal user-terraform command the tile will not be found in the "modheight" table. |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
84 |
* But during house- or industry-construction multiple corners can be terraformed at once. */ |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
85 |
TerraformerHeightMod *mod = ts->modheight; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
86 |
int count = ts->modheight_count; |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
87 |
|
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
88 |
while ((count > 0) && (mod->tile != tile)) { |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
89 |
mod++; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
90 |
count--; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
91 |
} |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
92 |
|
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
93 |
/* New entry? */ |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
94 |
if (count == 0) { |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
95 |
assert(ts->modheight_count < TERRAFORMER_MODHEIGHT_SIZE); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
96 |
ts->modheight_count++; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
97 |
} |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
98 |
|
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
99 |
/* Finally store the new value */ |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
100 |
mod->tile = tile; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
101 |
mod->height = (byte)height; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
102 |
} |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
103 |
|
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
104 |
/** |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
105 |
* Adds a tile to the "tile_table" in a TerraformerState. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
106 |
* |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
107 |
* @param ts TerraformerState. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
108 |
* @param tile Tile. |
8041
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
109 |
* @ingroup dirty |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
110 |
*/ |
0 | 111 |
static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile) |
112 |
{ |
|
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
113 |
int count = ts->tile_table_count; |
0 | 114 |
|
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
115 |
for (TileIndex *t = ts->tile_table; count != 0; count--, t++) { |
2639 | 116 |
if (*t == tile) return; |
0 | 117 |
} |
118 |
||
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
119 |
assert(ts->tile_table_count < TERRAFORMER_TILE_TABLE_SIZE); |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
120 |
|
0 | 121 |
ts->tile_table[ts->tile_table_count++] = tile; |
122 |
} |
|
123 |
||
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
124 |
/** |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
125 |
* Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a TerraformerState. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
126 |
* |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
127 |
* @param ts TerraformerState. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
128 |
* @param tile Tile. |
8041
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
8013
diff
changeset
|
129 |
* @ingroup dirty |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
130 |
*/ |
0 | 131 |
static void TerraformAddDirtyTileAround(TerraformerState *ts, TileIndex tile) |
132 |
{ |
|
1981 | 133 |
TerraformAddDirtyTile(ts, tile + TileDiffXY( 0, -1)); |
134 |
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, -1)); |
|
135 |
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, 0)); |
|
0 | 136 |
TerraformAddDirtyTile(ts, tile); |
137 |
} |
|
138 |
||
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
139 |
/** |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
140 |
* Terraform the north corner of a tile to a specific height. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
141 |
* |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
142 |
* @param ts TerraformerState. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
143 |
* @param tile Tile. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
144 |
* @param height Aimed height. |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
145 |
* @param return Error code or cost. |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
146 |
*/ |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
147 |
static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height) |
0 | 148 |
{ |
863
8d09f9331a80
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
856
diff
changeset
|
149 |
assert(tile < MapSize()); |
0 | 150 |
|
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
151 |
/* Check range of destination height */ |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
152 |
if (height < 0) return_cmd_error(STR_1003_ALREADY_AT_SEA_LEVEL); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
153 |
if (height > MAX_TILE_HEIGHT) return_cmd_error(STR_1004_TOO_HIGH); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
154 |
|
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
155 |
/* |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
156 |
* Check if the terraforming has any effect. |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
157 |
* This can only be true, if multiple corners of the start-tile are terraformed (i.e. the terraforming is done by towns/industries etc.). |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
158 |
* In this case the terraforming should fail. (Don't know why.) |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
159 |
*/ |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
160 |
if (height == TerraformGetHeightOfTile(ts, tile)) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
161 |
|
7983
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
162 |
/* Check "too close to edge of map" */ |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
163 |
uint x = TileX(tile); |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
164 |
uint y = TileY(tile); |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
165 |
if ((x <= 1) || (y <= 1) || (x >= MapMaxX() - 1) || (y >= MapMaxY() - 1)) { |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
166 |
/* |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
167 |
* Determine a sensible error tile |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
168 |
* Note: If x and y are both zero this will disable the error tile. (Tile 0 cannot be highlighted :( ) |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
169 |
*/ |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
170 |
if ((x == 1) && (y != 0)) x = 0; |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
171 |
if ((y == 1) && (x != 0)) y = 0; |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
172 |
_terraform_err_tile = TileXY(x, y); |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
173 |
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP); |
7983
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
174 |
} |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
175 |
|
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
176 |
/* Mark incident tiles, that are involved in the terraforming */ |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
177 |
TerraformAddDirtyTileAround(ts, tile); |
0 | 178 |
|
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
179 |
/* Store the height modification */ |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
180 |
TerraformSetHeightOfTile(ts, tile, height); |
0 | 181 |
|
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
182 |
CommandCost total_cost(EXPENSES_CONSTRUCTION); |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
183 |
|
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
184 |
/* Increment cost */ |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
185 |
total_cost.AddCost(_price.terraform); |
0 | 186 |
|
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
187 |
/* Recurse to neighboured corners if height difference is larger than 1 */ |
0 | 188 |
{ |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
189 |
const TileIndexDiffC *ttm; |
0 | 190 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
191 |
static const TileIndexDiffC _terraform_tilepos[] = { |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
192 |
{ 1, 0}, // move to tile in SE |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
193 |
{-2, 0}, // undo last move, and move to tile in NW |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
194 |
{ 1, 1}, // undo last move, and move to tile in SW |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
195 |
{ 0, -2} // undo last move, and move to tile in NE |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
196 |
}; |
0 | 197 |
|
2952 | 198 |
for (ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) { |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
199 |
tile += ToTileIndexDiff(*ttm); |
0 | 200 |
|
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
201 |
/* Get TileHeight of neighboured tile as of current terraform progress */ |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
202 |
int r = TerraformGetHeightOfTile(ts, tile); |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
203 |
int height_diff = height - r; |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
204 |
|
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
205 |
/* Is the height difference to the neighboured corner greater than 1? */ |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
206 |
if (abs(height_diff) > 1) { |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
207 |
/* Terraform the neighboured corner. The resulting height difference should be 1. */ |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
208 |
height_diff += (height_diff < 0 ? 1 : -1); |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
209 |
CommandCost cost = TerraformTileHeight(ts, tile, r + height_diff); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
210 |
if (CmdFailed(cost)) return cost; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
211 |
total_cost.AddCost(cost); |
0 | 212 |
} |
213 |
} |
|
214 |
} |
|
215 |
||
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
216 |
return total_cost; |
0 | 217 |
} |
218 |
||
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:
1571
diff
changeset
|
219 |
/** Terraform land |
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
|
220 |
* @param tile tile to terraform |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
221 |
* @param flags for this command type |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
222 |
* @param p1 corners to terraform (SLOPE_xxx) |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
223 |
* @param p2 direction; eg up (non-zero) or down (zero) |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
224 |
* @return error or cost of terraforming |
0 | 225 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7214
diff
changeset
|
226 |
CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 227 |
{ |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
228 |
/* Make an extra check for map-bounds cause we add tiles to the originating tile */ |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
229 |
if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR; |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
230 |
|
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
231 |
_terraform_err_tile = INVALID_TILE; |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
232 |
|
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8706
diff
changeset
|
233 |
CommandCost total_cost(EXPENSES_CONSTRUCTION); |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
234 |
int direction = (p2 != 0 ? 1 : -1); |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
235 |
TerraformerState ts; |
0 | 236 |
|
237 |
ts.modheight_count = ts.tile_table_count = 0; |
|
238 |
||
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
239 |
/* Compute the costs and the terraforming result in a model of the landscape */ |
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
240 |
if ((p1 & SLOPE_W) != 0) { |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
241 |
TileIndex t = tile + TileDiffXY(1, 0); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
242 |
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
243 |
if (CmdFailed(cost)) return cost; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
244 |
total_cost.AddCost(cost); |
0 | 245 |
} |
246 |
||
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
247 |
if ((p1 & SLOPE_S) != 0) { |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
248 |
TileIndex t = tile + TileDiffXY(1, 1); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
249 |
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
250 |
if (CmdFailed(cost)) return cost; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
251 |
total_cost.AddCost(cost); |
0 | 252 |
} |
253 |
||
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
254 |
if ((p1 & SLOPE_E) != 0) { |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
255 |
TileIndex t = tile + TileDiffXY(0, 1); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
256 |
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
257 |
if (CmdFailed(cost)) return cost; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
258 |
total_cost.AddCost(cost); |
0 | 259 |
} |
260 |
||
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
261 |
if ((p1 & SLOPE_N) != 0) { |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
262 |
TileIndex t = tile + TileDiffXY(0, 0); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
263 |
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction); |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
264 |
if (CmdFailed(cost)) return cost; |
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
265 |
total_cost.AddCost(cost); |
0 | 266 |
} |
267 |
||
7983
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
268 |
/* Check if the terraforming is valid wrt. tunnels, bridges and objects on the surface */ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4815
diff
changeset
|
269 |
{ |
0 | 270 |
TileIndex *ti = ts.tile_table; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
271 |
|
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
272 |
for (int count = ts.tile_table_count; count != 0; count--, ti++) { |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
273 |
TileIndex tile = *ti; |
0 | 274 |
|
7983
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
275 |
/* Find new heights of tile corners */ |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
276 |
uint z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0)); |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
277 |
uint z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0)); |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
278 |
uint z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1)); |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
279 |
uint z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1)); |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
280 |
|
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
281 |
/* Find min and max height of tile */ |
7983
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
282 |
uint z_min = min(min(z_N, z_W), min(z_S, z_E)); |
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
283 |
uint z_max = max(max(z_N, z_W), max(z_S, z_E)); |
7214
ae8dcfa02ec8
(svn r9950) -Feature(tte): allow terraforming under bridges.
rubidium
parents:
7179
diff
changeset
|
284 |
|
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7983
diff
changeset
|
285 |
/* Compute tile slope */ |
9297
94a4efa5de6e
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents:
8760
diff
changeset
|
286 |
Slope tileh = (z_max > z_min + 1 ? SLOPE_STEEP : SLOPE_FLAT); |
94a4efa5de6e
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents:
8760
diff
changeset
|
287 |
if (z_W > z_min) tileh |= SLOPE_W; |
94a4efa5de6e
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents:
8760
diff
changeset
|
288 |
if (z_S > z_min) tileh |= SLOPE_S; |
94a4efa5de6e
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents:
8760
diff
changeset
|
289 |
if (z_E > z_min) tileh |= SLOPE_E; |
94a4efa5de6e
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents:
8760
diff
changeset
|
290 |
if (z_N > z_min) tileh |= SLOPE_N; |
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7983
diff
changeset
|
291 |
|
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
292 |
/* Check if bridge would take damage */ |
7214
ae8dcfa02ec8
(svn r9950) -Feature(tte): allow terraforming under bridges.
rubidium
parents:
7179
diff
changeset
|
293 |
if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) && |
ae8dcfa02ec8
(svn r9950) -Feature(tte): allow terraforming under bridges.
rubidium
parents:
7179
diff
changeset
|
294 |
GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max * TILE_HEIGHT) { |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
295 |
_terraform_err_tile = tile; // highlight the tile under the bridge |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4815
diff
changeset
|
296 |
return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4815
diff
changeset
|
297 |
} |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
298 |
/* Check if tunnel would take damage */ |
7214
ae8dcfa02ec8
(svn r9950) -Feature(tte): allow terraforming under bridges.
rubidium
parents:
7179
diff
changeset
|
299 |
if (direction == -1 && IsTunnelInWay(tile, z_min * TILE_HEIGHT)) { |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
300 |
_terraform_err_tile = tile; // highlight the tile above the tunnel |
7214
ae8dcfa02ec8
(svn r9950) -Feature(tte): allow terraforming under bridges.
rubidium
parents:
7179
diff
changeset
|
301 |
return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE); |
2639 | 302 |
} |
7983
06d272a9618b
(svn r10998) -Codechange: refactor of the "core" of the terraforming code to make it possible to push the tile type specific terraforming requirements out of the generic part of the terraforming code. Patch by frosch. For more information take a look at FS#1147.
rubidium
parents:
7976
diff
changeset
|
303 |
/* Check tiletype-specific things, and add extra-cost */ |
10633
72128af00ac8
(svn r13177) -Fix[FS#2002]: Using level tool in scenario editor makes tiles brown. That is the only tool that does so in Scenario Editor (apart dynamite, of course).Report and Fix by Roujin
belugas
parents:
9312
diff
changeset
|
304 |
const bool curr_gen = _generating_world; |
72128af00ac8
(svn r13177) -Fix[FS#2002]: Using level tool in scenario editor makes tiles brown. That is the only tool that does so in Scenario Editor (apart dynamite, of course).Report and Fix by Roujin
belugas
parents:
9312
diff
changeset
|
305 |
if (_game_mode == GM_EDITOR) _generating_world = true; // used to create green terraformed land |
9297
94a4efa5de6e
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents:
8760
diff
changeset
|
306 |
CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO, z_min * TILE_HEIGHT, tileh); |
10633
72128af00ac8
(svn r13177) -Fix[FS#2002]: Using level tool in scenario editor makes tiles brown. That is the only tool that does so in Scenario Editor (apart dynamite, of course).Report and Fix by Roujin
belugas
parents:
9312
diff
changeset
|
307 |
_generating_world = curr_gen; |
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7983
diff
changeset
|
308 |
if (CmdFailed(cost)) { |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7983
diff
changeset
|
309 |
_terraform_err_tile = tile; |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7983
diff
changeset
|
310 |
return cost; |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7983
diff
changeset
|
311 |
} |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
312 |
total_cost.AddCost(cost); |
0 | 313 |
} |
314 |
} |
|
315 |
||
316 |
if (flags & DC_EXEC) { |
|
317 |
/* change the height */ |
|
318 |
{ |
|
319 |
int count; |
|
320 |
TerraformerHeightMod *mod; |
|
321 |
||
322 |
mod = ts.modheight; |
|
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:
1571
diff
changeset
|
323 |
for (count = ts.modheight_count; count != 0; count--, mod++) { |
1979
f4462d4e8e62
(svn r2485) Missed two uint -> TileIndex, thanks _Luca_
tron
parents:
1977
diff
changeset
|
324 |
TileIndex til = mod->tile; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
325 |
|
1059
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
326 |
SetTileHeight(til, mod->height); |
0 | 327 |
} |
328 |
} |
|
329 |
||
330 |
/* finally mark the dirty tiles dirty */ |
|
331 |
{ |
|
332 |
int count; |
|
333 |
TileIndex *ti = ts.tile_table; |
|
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:
1571
diff
changeset
|
334 |
for (count = ts.tile_table_count; count != 0; count--, ti++) { |
0 | 335 |
MarkTileDirtyByTile(*ti); |
336 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
337 |
} |
0 | 338 |
} |
8013
67c6bcc81914
(svn r11032) -Codechange: unmagicify some table sizes and removal of some unnecessary variables. Patch by frosch.
rubidium
parents:
8005
diff
changeset
|
339 |
return total_cost; |
0 | 340 |
} |
341 |
||
342 |
||
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
343 |
/** Levels a selected (rectangle) area of land |
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
|
344 |
* @param tile end tile of area-drag |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
345 |
* @param flags for this command type |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
346 |
* @param p1 start tile of area drag |
8692
5408c091b204
(svn r11759) -Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match. Patch by Roujin.
peter1138
parents:
8640
diff
changeset
|
347 |
* @param p2 height difference; eg raise (+1), lower (-1) or level (0) |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
348 |
* @return error or cost of terraforming |
0 | 349 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7214
diff
changeset
|
350 |
CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 351 |
{ |
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:
2705
diff
changeset
|
352 |
if (p1 >= MapSize()) return CMD_ERROR; |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
353 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
354 |
/* remember level height */ |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
355 |
uint oldh = TileHeight(p1); |
8692
5408c091b204
(svn r11759) -Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match. Patch by Roujin.
peter1138
parents:
8640
diff
changeset
|
356 |
|
5408c091b204
(svn r11759) -Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match. Patch by Roujin.
peter1138
parents:
8640
diff
changeset
|
357 |
/* compute new height */ |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
358 |
uint h = oldh + p2; |
8692
5408c091b204
(svn r11759) -Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match. Patch by Roujin.
peter1138
parents:
8640
diff
changeset
|
359 |
|
5408c091b204
(svn r11759) -Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match. Patch by Roujin.
peter1138
parents:
8640
diff
changeset
|
360 |
/* Check range of destination height */ |
5408c091b204
(svn r11759) -Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match. Patch by Roujin.
peter1138
parents:
8640
diff
changeset
|
361 |
if (h > MAX_TILE_HEIGHT) return_cmd_error((oldh == 0) ? STR_1003_ALREADY_AT_SEA_LEVEL : STR_1004_TOO_HIGH); |
0 | 362 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
363 |
/* make sure sx,sy are smaller than ex,ey */ |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
364 |
int ex = TileX(tile); |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
365 |
int ey = TileY(tile); |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
366 |
int sx = TileX(p1); |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
367 |
int sy = TileY(p1); |
6432 | 368 |
if (ex < sx) Swap(ex, sx); |
369 |
if (ey < sy) Swap(ey, sy); |
|
1981 | 370 |
tile = TileXY(sx, sy); |
0 | 371 |
|
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
372 |
int size_x = ex - sx + 1; |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
373 |
int size_y = ey - sy + 1; |
0 | 374 |
|
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
375 |
Money money = GetAvailableMoneyForCommand(); |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
376 |
CommandCost cost(EXPENSES_CONSTRUCTION); |
0 | 377 |
|
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
378 |
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) { |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
379 |
uint curh = TileHeight(tile2); |
0 | 380 |
while (curh != h) { |
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
381 |
CommandCost ret = DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND); |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
382 |
if (CmdFailed(ret)) break; |
0 | 383 |
|
384 |
if (flags & DC_EXEC) { |
|
9312
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
385 |
money -= ret.GetCost(); |
d30aee0a6055
(svn r12562) -Cleanup: variable scope in terraform_cmd.cpp
smatz
parents:
9297
diff
changeset
|
386 |
if (money < 0) { |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
387 |
_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
|
388 |
return cost; |
0 | 389 |
} |
7976
5d93386b748b
(svn r10991) -Codechange: add documentation, enumification and some code simplifications to the terraforming code. Patch by frosch.
rubidium
parents:
7831
diff
changeset
|
390 |
DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND); |
0 | 391 |
} |
392 |
||
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
393 |
cost.AddCost(ret); |
0 | 394 |
curh += (curh > h) ? -1 : 1; |
395 |
} |
|
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
396 |
} END_TILE_LOOP(tile2, size_x, size_y, tile) |
0 | 397 |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
398 |
return (cost.GetCost() == 0) ? CMD_ERROR : cost; |
0 | 399 |
} |