summaryrefslogtreecommitdiff
path: root/landscape.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-05-12 00:11:37 +0000
committerDarkvater <darkvater@openttd.org>2005-05-12 00:11:37 +0000
commit921cc4e94a7703816ff63e4f673eaa9d8a7da4ca (patch)
tree2a2c6834d0b034f560428a4c3abe47e5e2df1f44 /landscape.c
parentf3b217db9dd377d2e8e5d28434cc01ffe5c23b3b (diff)
downloadopenttd-921cc4e94a7703816ff63e4f673eaa9d8a7da4ca.tar.xz
(svn r2297) - CodeChange: server-check the next batch of commands.
- CodeChange: since only the server will be able to modify difficulty settings, leave the checking of correct values besides, and trust users will join legit servers. - CodeChange: for renaming signs, only check if GetDParam(); eg _decode_parameters is empty ('\0') or not, instead of the extra check of players, etc. That basically does the same thing. Also dirty sign two times when renaming, once before, once after the action. Because if the name becomes shorter and you update only after, garbage remains on the screen. - CodeChange: made GetMaskOfTownActions() available to the town-cmd to double-check if the action was available to the player. For this purpose the hardcoded _local_player has been removed from the function and is now passed as a parameter.
Diffstat (limited to 'landscape.c')
-rw-r--r--landscape.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/landscape.c b/landscape.c
index 46c1e13c1..755e3a48f 100644
--- a/landscape.c
+++ b/landscape.c
@@ -287,14 +287,20 @@ int32 CmdLandscapeClear(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags);
}
-// p1 = end tile
+/** Clear a big piece of landscape
+ * @param x,y end coordinates of area dragging
+ * @param p1 start tile of area dragging
+ * @param p2 unused
+ */
int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
{
- int32 cost,ret, money;
+ int32 cost, ret, money;
int sx,sy;
int x,y;
bool success = false;
+ if (p1 > MapSize()) return CMD_ERROR;
+
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
// make sure sx,sy are smaller than ex,ey
@@ -306,22 +312,22 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
money = GetAvailableMoneyForCommand();
cost = 0;
- for(x=sx; x<=ex; x+=16) {
- for(y=sy; y<=ey; y+=16) {
+ for (x = sx; x <= ex; x += 16) {
+ for (y = sy; y <= ey; y += 16) {
ret = DoCommandByTile(TILE_FROM_XY(x,y), 0, 0, flags &~DC_EXEC, CMD_LANDSCAPE_CLEAR);
- if (ret == CMD_ERROR) continue;
+ if (CmdFailed(ret)) continue;
cost += ret;
success = true;
if (flags & DC_EXEC) {
- if ( ret>0 && (money -= ret) < 0) {
+ if (ret > 0 && (money -= ret) < 0) {
_additional_cash_required = ret;
return cost - ret;
}
DoCommandByTile(TILE_FROM_XY(x,y), 0, 0, flags, CMD_LANDSCAPE_CLEAR);
// draw explosion animation...
- if ((x==sx || x==ex) && (y==sy || y==ey)) {
+ if ((x == sx || x == ex) && (y == sy || y == ey)) {
// big explosion in each corner, or small explosion for single tiles
CreateEffectVehicleAbove(x + 8, y + 8, 2,
sy == ey && sx == ex ? EV_EXPLOSION_SMALL : EV_EXPLOSION_LARGE
@@ -331,9 +337,7 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
}
}
- if (!success)
- cost = CMD_ERROR;
- return cost;
+ return (success) ? cost : CMD_ERROR;
}