484 static void AnimateTile_Water(uint tile) |
484 static void AnimateTile_Water(uint tile) |
485 { |
485 { |
486 /* not used */ |
486 /* not used */ |
487 } |
487 } |
488 |
488 |
489 static void TileLoopWaterHelper(uint tile, const TileIndexDiffC *offs) |
489 static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs) |
490 { |
490 { |
491 byte *p; |
491 TileIndex target = TILE_ADD(tile, ToTileIndexDiff(offs[0])); |
492 |
|
493 p = &_map_type_and_height[tile]; |
|
494 tile += ToTileIndexDiff(offs[0]); |
|
495 |
492 |
496 // type of this tile mustn't be water already. |
493 // type of this tile mustn't be water already. |
497 if (p[ToTileIndexDiff(offs[0])] >> 4 == MP_WATER) |
494 if (IsTileType(target, MP_WATER)) |
498 return; |
495 return; |
499 |
496 |
500 if ((p[ToTileIndexDiff(offs[1])] | p[ToTileIndexDiff(offs[2])]) & 0xF) |
497 if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[1]))) != 0 || |
|
498 TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[2]))) != 0) |
501 return; |
499 return; |
502 |
500 |
503 if ((p[ToTileIndexDiff(offs[3])] | p[ToTileIndexDiff(offs[4])]) & 0xF) { |
501 if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[3]))) != 0 || |
|
502 TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[4]))) != 0) { |
504 // make coast.. |
503 // make coast.. |
505 if (p[ToTileIndexDiff(offs[0])] >> 4 == MP_CLEAR || |
504 switch (TileType(target)) { |
506 p[ToTileIndexDiff(offs[0])] >> 4 == MP_TREES) { |
505 case MP_CLEAR: |
507 _current_player = OWNER_WATER; |
506 case MP_TREES: |
508 if (DoCommandByTile(tile,0,0,DC_EXEC | DC_AUTO, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) |
507 _current_player = OWNER_WATER; |
509 ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,1); |
508 if (DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) { |
|
509 ModifyTile( |
|
510 target, |
|
511 MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | |
|
512 MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, |
|
513 OWNER_WATER, 1 |
|
514 ); |
|
515 } |
|
516 break; |
|
517 |
|
518 default: |
|
519 break; |
510 } |
520 } |
511 } else { |
521 } else { |
512 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
522 if (IsTileType(target, MP_TUNNELBRIDGE)) { |
513 byte m5 = _map5[tile]; |
523 byte m5 = _map5[target]; |
514 if ( (m5&0xF8) == 0xC8 || (m5&0xF8) == 0xF0) |
524 if ((m5 & 0xF8) == 0xC8 || (m5 & 0xF8) == 0xF0) |
515 return; |
525 return; |
516 |
526 |
517 if ( (m5&0xC0) == 0xC0) { |
527 if ((m5 & 0xC0) == 0xC0) { |
518 ModifyTile(tile, MP_MAPOWNER | MP_MAP5,OWNER_WATER,(m5 & ~0x38)|0x8); |
528 ModifyTile(target, MP_MAPOWNER | MP_MAP5, OWNER_WATER, (m5 & ~0x38) | 0x8); |
519 return; |
529 return; |
520 } |
530 } |
521 } |
531 } |
522 |
532 |
523 _current_player = OWNER_WATER; |
533 _current_player = OWNER_WATER; |
524 { |
534 { |
525 Vehicle *v = FindVehicleBetween(tile, tile, 0); |
535 Vehicle *v = FindVehicleBetween(target, target, 0); |
526 if (v != NULL) {FloodVehicle(v);} |
536 if (v != NULL) FloodVehicle(v); |
527 } |
537 } |
528 if (DoCommandByTile(tile,0,0,DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) |
538 |
529 ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,0); |
539 if (DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) { |
|
540 ModifyTile( |
|
541 target, |
|
542 MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | |
|
543 MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, |
|
544 OWNER_WATER, |
|
545 0 |
|
546 ); |
|
547 } |
530 } |
548 } |
531 } |
549 } |
532 |
550 |
533 static void FloodVehicle(Vehicle *v) |
551 static void FloodVehicle(Vehicle *v) |
534 { |
552 { |