(svn r1576) Clean TileLoopWaterHelper() a bit up

This commit is contained in:
tron 2005-01-20 18:18:32 +00:00
parent 1af764c4d0
commit 44dae05c3d
1 changed files with 40 additions and 22 deletions

View File

@ -486,47 +486,65 @@ static void AnimateTile_Water(uint tile)
/* not used */ /* not used */
} }
static void TileLoopWaterHelper(uint tile, const TileIndexDiffC *offs) static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
{ {
byte *p; TileIndex target = TILE_ADD(tile, ToTileIndexDiff(offs[0]));
p = &_map_type_and_height[tile];
tile += ToTileIndexDiff(offs[0]);
// type of this tile mustn't be water already. // type of this tile mustn't be water already.
if (p[ToTileIndexDiff(offs[0])] >> 4 == MP_WATER) if (IsTileType(target, MP_WATER))
return; return;
if ((p[ToTileIndexDiff(offs[1])] | p[ToTileIndexDiff(offs[2])]) & 0xF) if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[1]))) != 0 ||
TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[2]))) != 0)
return; return;
if ((p[ToTileIndexDiff(offs[3])] | p[ToTileIndexDiff(offs[4])]) & 0xF) { if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[3]))) != 0 ||
TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[4]))) != 0) {
// make coast.. // make coast..
if (p[ToTileIndexDiff(offs[0])] >> 4 == MP_CLEAR || switch (TileType(target)) {
p[ToTileIndexDiff(offs[0])] >> 4 == MP_TREES) { case MP_CLEAR:
_current_player = OWNER_WATER; case MP_TREES:
if (DoCommandByTile(tile,0,0,DC_EXEC | DC_AUTO, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) _current_player = OWNER_WATER;
ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,1); if (DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) {
ModifyTile(
target,
MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR |
MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,
OWNER_WATER, 1
);
}
break;
default:
break;
} }
} else { } else {
if (IsTileType(tile, MP_TUNNELBRIDGE)) { if (IsTileType(target, MP_TUNNELBRIDGE)) {
byte m5 = _map5[tile]; byte m5 = _map5[target];
if ( (m5&0xF8) == 0xC8 || (m5&0xF8) == 0xF0) if ((m5 & 0xF8) == 0xC8 || (m5 & 0xF8) == 0xF0)
return; return;
if ( (m5&0xC0) == 0xC0) { if ((m5 & 0xC0) == 0xC0) {
ModifyTile(tile, MP_MAPOWNER | MP_MAP5,OWNER_WATER,(m5 & ~0x38)|0x8); ModifyTile(target, MP_MAPOWNER | MP_MAP5, OWNER_WATER, (m5 & ~0x38) | 0x8);
return; return;
} }
} }
_current_player = OWNER_WATER; _current_player = OWNER_WATER;
{ {
Vehicle *v = FindVehicleBetween(tile, tile, 0); Vehicle *v = FindVehicleBetween(target, target, 0);
if (v != NULL) {FloodVehicle(v);} if (v != NULL) FloodVehicle(v);
}
if (DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) {
ModifyTile(
target,
MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR |
MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,
OWNER_WATER,
0
);
} }
if (DoCommandByTile(tile,0,0,DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR)
ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,0);
} }
} }