288 } else |
288 } else |
289 return CMD_ERROR; |
289 return CMD_ERROR; |
290 } else if ((m5 & 0x10) == 0x10) { |
290 } else if ((m5 & 0x10) == 0x10) { |
291 // shiplift |
291 // shiplift |
292 |
292 |
293 static const TileIndexDiff _shiplift_tomiddle_offs[12] = { |
293 static const TileIndexDiffC _shiplift_tomiddle_offs[] = { |
294 0,0,0,0, // middle |
294 { 0, 0}, {0, 0}, { 0, 0}, {0, 0}, // middle |
295 TILE_XY(-1, 0),TILE_XY(0, 1),TILE_XY(1, 0),TILE_XY(0, -1), // lower |
295 {-1, 0}, {0, 1}, { 1, 0}, {0, -1}, // lower |
296 TILE_XY(1, 0),TILE_XY(0, -1),TILE_XY(-1, 0),TILE_XY(0, 1), // upper |
296 { 1, 0}, {0, -1}, {-1, 0}, {0, 1}, // upper |
297 }; |
297 }; |
298 |
298 |
299 if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
299 if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
300 // don't allow water to delete it. |
300 // don't allow water to delete it. |
301 if (_current_player == OWNER_WATER) return CMD_ERROR; |
301 if (_current_player == OWNER_WATER) return CMD_ERROR; |
302 // move to the middle tile.. |
302 // move to the middle tile.. |
303 return RemoveShiplift(tile + _shiplift_tomiddle_offs[m5 & 0xF], flags); |
303 return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[m5 & 0xF]), flags); |
304 } else { |
304 } else { |
305 // ship depot |
305 // ship depot |
306 if (flags & DC_AUTO) |
306 if (flags & DC_AUTO) |
307 return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
307 return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
308 |
308 |
478 static void AnimateTile_Water(uint tile) |
478 static void AnimateTile_Water(uint tile) |
479 { |
479 { |
480 /* not used */ |
480 /* not used */ |
481 } |
481 } |
482 |
482 |
483 static void TileLoopWaterHelper(uint tile, const int16 *offs) |
483 static void TileLoopWaterHelper(uint tile, const TileIndexDiffC *offs) |
484 { |
484 { |
485 byte *p; |
485 byte *p; |
486 |
486 |
487 p = &_map_type_and_height[tile]; |
487 p = &_map_type_and_height[tile]; |
488 tile += offs[0]; |
488 tile += ToTileIndexDiff(offs[0]); |
489 |
489 |
490 // type of this tile mustn't be water already. |
490 // type of this tile mustn't be water already. |
491 if (p[offs[0]] >> 4 == MP_WATER) |
491 if (p[ToTileIndexDiff(offs[0])] >> 4 == MP_WATER) |
492 return; |
492 return; |
493 |
493 |
494 if ( (p[offs[1]] | p[offs[2]]) & 0xF ) |
494 if ((p[ToTileIndexDiff(offs[1])] | p[ToTileIndexDiff(offs[2])]) & 0xF) |
495 return; |
495 return; |
496 |
496 |
497 if ( (p[offs[3]] | p[offs[4]]) & 0xF ) { |
497 if ((p[ToTileIndexDiff(offs[3])] | p[ToTileIndexDiff(offs[4])]) & 0xF) { |
498 // make coast.. |
498 // make coast.. |
499 if (p[offs[0]] >> 4 == MP_CLEAR || p[offs[0]] >> 4 == MP_TREES) { |
499 if (p[ToTileIndexDiff(offs[0])] >> 4 == MP_CLEAR || |
|
500 p[ToTileIndexDiff(offs[0])] >> 4 == MP_TREES) { |
500 _current_player = OWNER_WATER; |
501 _current_player = OWNER_WATER; |
501 if (DoCommandByTile(tile,0,0,DC_EXEC | DC_AUTO, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) |
502 if (DoCommandByTile(tile,0,0,DC_EXEC | DC_AUTO, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) |
502 ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,1); |
503 ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,1); |
503 } |
504 } |
504 } else { |
505 } else { |
571 |
572 |
572 // called from tunnelbridge_cmd |
573 // called from tunnelbridge_cmd |
573 void TileLoop_Water(uint tile) |
574 void TileLoop_Water(uint tile) |
574 { |
575 { |
575 int i; |
576 int i; |
576 static const TileIndexDiff _tile_loop_offs_array[4][5] = { |
577 static const TileIndexDiffC _tile_loop_offs_array[][5] = { |
577 // tile to mod shore? shore? |
578 // tile to mod shore? shore? |
578 {TILE_XY(-1,0), TILE_XY(0,0), TILE_XY(0,1), TILE_XY(-1,0), TILE_XY(-1,1)}, |
579 {{-1, 0}, {0, 0}, {0, 1}, {-1, 0}, {-1, 1}}, |
579 {TILE_XY(0,1), TILE_XY(0,1), TILE_XY(1,1), TILE_XY(0,2), TILE_XY(1,2)}, |
580 {{ 0, 1}, {0, 1}, {1, 1}, { 0, 2}, { 1, 2}}, |
580 {TILE_XY(1,0), TILE_XY(1,0), TILE_XY(1,1), TILE_XY(2,0), TILE_XY(2,1)}, |
581 {{ 1, 0}, {1, 0}, {1, 1}, { 2, 0}, { 2, 1}}, |
581 {TILE_XY(0,-1), TILE_XY(0,0), TILE_XY(1,0), TILE_XY(0,-1), TILE_XY(1,-1)}, |
582 {{ 0, -1}, {0, 0}, {1, 0}, { 0, -1}, { 1, -1}} |
582 }; |
583 }; |
583 |
584 |
584 if (IS_INT_INSIDE(GET_TILE_X(tile), 1, MapSizeX() - 3 + 1) && |
585 if (IS_INT_INSIDE(GET_TILE_X(tile), 1, MapSizeX() - 3 + 1) && |
585 IS_INT_INSIDE(GET_TILE_Y(tile), 1, MapSizeY() - 3 + 1)) { |
586 IS_INT_INSIDE(GET_TILE_Y(tile), 1, MapSizeY() - 3 + 1)) { |
586 for(i=0; i!=4; i++) |
587 for(i=0; i!=4; i++) |