clear_cmd.c
changeset 1293 a09e03073113
parent 1209 a1ac96655b79
child 1298 d4aee03d99ae
equal deleted inserted replaced
1292:60391134c30a 1293:a09e03073113
   543 static void AnimateTile_Clear(uint tile)
   543 static void AnimateTile_Clear(uint tile)
   544 {
   544 {
   545 	/* unused */
   545 	/* unused */
   546 }
   546 }
   547 
   547 
   548 void TileLoopClearHelper(uint tile)
   548 void TileLoopClearHelper(TileIndex tile)
   549 {
   549 {
   550 	byte img_1, img_2;
   550 	byte img_1;
   551 	static byte img_by_map5[8] = { 0,0,0,2, 1,1,0,0, };
   551 	byte img_2;
   552 	uint dirty = -1;
   552 	static byte img_by_map5[] = { 0, 0, 0, 2, 1, 1, 0, 0 };
   553 
   553 	TileIndex dirty = INVALID_TILE;
   554 	img_1 = 0;
   554 
   555 	if (IsTileType(tile, MP_CLEAR)) {
   555 	switch (GetTileType(tile)) {
   556 		img_1 = img_by_map5[(_map5[tile] & 0x1C) >> 2];
   556 		case MP_CLEAR:
   557 	} else if (IsTileType(tile, MP_TREES) && (_map2[tile] & 0x30) == 0x20) {
   557 			img_1 = img_by_map5[(_map5[tile] & 0x1C) >> 2];
   558 		img_1 = 1;
   558 			break;
   559 	}
   559 
   560 
   560 		case MP_TREES:
   561 	img_2 = 0;
   561 			if ((_map2[tile] & 0x30) == 0x20)
   562 	if (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR)) {
   562 				img_1 = 1;
   563 		img_2 = img_by_map5[(_map5[TILE_ADDXY(tile, 1, 0)] & 0x1C) >> 2];
   563 			else
   564 	} else if (IsTileType(TILE_ADDXY(tile, 1, 0), MP_TREES) && (_map2[TILE_ADDXY(tile, 1, 0)] & 0x30) == 0x20) {
   564 				img_1 = 0;
   565 		img_2 = 1;
   565 
   566 	}
   566 		default:
   567 
   567 			img_1 = 0;
   568 	if (!(_map3_hi[tile] & 0xE0)) {
   568 			break;
   569 		if ( (img_1&2) != (img_2&2) ) {
   569 	}
       
   570 
       
   571 	switch (GetTileType(TILE_ADDXY(tile, 1, 0))) {
       
   572 		case MP_CLEAR:
       
   573 			img_2 = img_by_map5[(_map5[TILE_ADDXY(tile, 1, 0)] & 0x1C) >> 2];
       
   574 			break;
       
   575 
       
   576 		case MP_TREES:
       
   577 			if ((_map2[TILE_ADDXY(tile, 1, 0)] & 0x30) == 0x20)
       
   578 				img_2 = 1;
       
   579 			else
       
   580 				img_2 = 0;
       
   581 			break;
       
   582 
       
   583 		default:
       
   584 			img_2 = 0;
       
   585 			break;
       
   586 	}
       
   587 
       
   588 	if ((_map3_hi[tile] & 0xE0) == 0) {
       
   589 		if ((img_1 & 2) != (img_2 & 2)) {
   570 			_map3_hi[tile] |= 3 << 5;
   590 			_map3_hi[tile] |= 3 << 5;
   571 			dirty = tile;
   591 			dirty = tile;
   572 		}
   592 		}
   573 	} else {
   593 	} else {
   574 		if (img_1 == 1 && img_2 == 1) {
   594 		if (img_1 == 1 && img_2 == 1) {
   575 			_map3_hi[tile] &= ~(3 << 5);
   595 			_map3_hi[tile] &= ~(3 << 5);
   576 			dirty = tile;
   596 			dirty = tile;
   577 		}
   597 		}
   578 	}
   598 	}
   579 
   599 
   580 	img_2 = 0;
   600 	switch (GetTileType(TILE_ADDXY(tile, 0, 1))) {
   581 	if (IsTileType(TILE_ADDXY(tile, 0, 1), MP_CLEAR)) {
   601 		case MP_CLEAR:
   582 		img_2 = img_by_map5[(_map5[TILE_ADDXY(tile, 0, 1)] & 0x1C) >> 2];
   602 			img_2 = img_by_map5[(_map5[TILE_ADDXY(tile, 1, 0)] & 0x1C) >> 2];
   583 	} else if (IsTileType(TILE_ADDXY(tile, 0, 1), MP_TREES) && (_map2[TILE_ADDXY(tile, 0, 1)] & 0x30) == 0x20) {
   603 			break;
   584 		img_2 = 1;
   604 
   585 	}
   605 		case MP_TREES:
   586 
   606 			if ((_map2[TILE_ADDXY(tile, 0, 1)] & 0x30) == 0x20)
   587 	if (!(_map3_hi[tile] & 0x1C)) {
   607 				img_2 = 1;
   588 		if ( (img_1&2) != (img_2&2) ) {
   608 			else
       
   609 				img_2 = 0;
       
   610 			break;
       
   611 
       
   612 		default:
       
   613 			img_2 = 0;
       
   614 			break;
       
   615 	}
       
   616 
       
   617 	if ((_map3_hi[tile] & 0x1C) == 0) {
       
   618 		if ((img_1 & 2) != (img_2 & 2)) {
   589 			_map3_hi[tile] |= 3 << 2;
   619 			_map3_hi[tile] |= 3 << 2;
   590 			dirty = tile;
   620 			dirty = tile;
   591 		}
   621 		}
   592 	} else {
   622 	} else {
   593 		if (img_1 == 1 && img_2 == 1) {
   623 		if (img_1 == 1 && img_2 == 1) {
   594 			_map3_hi[tile] &= ~(3 << 2);
   624 			_map3_hi[tile] &= ~(3 << 2);
   595 			dirty = tile;
   625 			dirty = tile;
   596 		}
   626 		}
   597 	}
   627 	}
   598 
   628 
   599 	if (dirty != (uint) -1)
   629 	if (dirty != INVALID_TILE)
   600 		MarkTileDirtyByTile(dirty);
   630 		MarkTileDirtyByTile(dirty);
   601 }
   631 }
   602 
   632 
   603 
   633 
   604 /* convert into snowy tiles */
   634 /* convert into snowy tiles */