disaster_cmd.c
changeset 3314 b8b234d4584f
parent 3269 95e7bffcb3c5
child 3315 1f65f8260092
equal deleted inserted replaced
3313:767d77394c61 3314:b8b234d4584f
     1 /* $Id$ */
     1 /* $Id$ */
     2 
     2 
     3 #include "stdafx.h"
     3 #include "stdafx.h"
     4 #include "openttd.h"
     4 #include "openttd.h"
       
     5 #include "industry_map.h"
     5 #include "table/strings.h"
     6 #include "table/strings.h"
     6 #include "functions.h"
     7 #include "functions.h"
     7 #include "map.h"
     8 #include "map.h"
     8 #include "tile.h"
     9 #include "tile.h"
     9 #include "vehicle.h"
    10 #include "vehicle.h"
   334 static void DestructIndustry(Industry *i)
   335 static void DestructIndustry(Industry *i)
   335 {
   336 {
   336 	TileIndex tile;
   337 	TileIndex tile;
   337 
   338 
   338 	for (tile = 0; tile != MapSize(); tile++) {
   339 	for (tile = 0; tile != MapSize(); tile++) {
   339 		if (IsTileType(tile, MP_INDUSTRY) && _m[tile].m2 == i->index) {
   340 		if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == i->index) {
   340 			_m[tile].m1 = 0;
   341 			_m[tile].m1 = 0;
   341 			MarkTileDirtyByTile(tile);
   342 			MarkTileDirtyByTile(tile);
   342 		}
   343 		}
   343 	}
   344 	}
   344 }
   345 }
   391 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
   392 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
   392 		}
   393 		}
   393 	} else if (v->current_order.station == 0) {
   394 	} else if (v->current_order.station == 0) {
   394 		int x,y;
   395 		int x,y;
   395 		TileIndex tile;
   396 		TileIndex tile;
   396 		int ind;
   397 		uint ind;
   397 
   398 
   398 		x = v->x_pos - 15*16;
   399 		x = v->x_pos - 15*16;
   399 		y = v->y_pos;
   400 		y = v->y_pos;
   400 
   401 
   401 		if ( (uint)x > MapMaxX() * 16-1)
   402 		if ( (uint)x > MapMaxX() * 16-1)
   403 
   404 
   404 		tile = TileVirtXY(x, y);
   405 		tile = TileVirtXY(x, y);
   405 		if (!IsTileType(tile, MP_INDUSTRY))
   406 		if (!IsTileType(tile, MP_INDUSTRY))
   406 			return;
   407 			return;
   407 
   408 
   408 		v->dest_tile = ind = _m[tile].m2;
   409 		ind = GetIndustryIndex(tile);
       
   410 		v->dest_tile = ind;
   409 
   411 
   410 		if (GetIndustry(ind)->type == IT_OIL_REFINERY) {
   412 		if (GetIndustry(ind)->type == IT_OIL_REFINERY) {
   411 			v->current_order.station = 1;
   413 			v->current_order.station = 1;
   412 			v->age = 0;
   414 			v->age = 0;
   413 		}
   415 		}
   462 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
   464 			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
   463 		}
   465 		}
   464 	} else if (v->current_order.station == 0) {
   466 	} else if (v->current_order.station == 0) {
   465 		int x,y;
   467 		int x,y;
   466 		TileIndex tile;
   468 		TileIndex tile;
   467 		int ind;
   469 		uint ind;
   468 
   470 
   469 		x = v->x_pos - 15*16;
   471 		x = v->x_pos - 15*16;
   470 		y = v->y_pos;
   472 		y = v->y_pos;
   471 
   473 
   472 		if ( (uint)x > MapMaxX() * 16-1)
   474 		if ( (uint)x > MapMaxX() * 16-1)
   474 
   476 
   475 		tile = TileVirtXY(x, y);
   477 		tile = TileVirtXY(x, y);
   476 		if (!IsTileType(tile, MP_INDUSTRY))
   478 		if (!IsTileType(tile, MP_INDUSTRY))
   477 			return;
   479 			return;
   478 
   480 
   479 		v->dest_tile = ind = _m[tile].m2;
   481 		ind = GetIndustryIndex(tile);
       
   482 		v->dest_tile = ind;
   480 
   483 
   481 		if (GetIndustry(ind)->type == IT_FACTORY) {
   484 		if (GetIndustry(ind)->type == IT_FACTORY) {
   482 			v->current_order.station = 1;
   485 			v->current_order.station = 1;
   483 			v->age = 0;
   486 			v->age = 0;
   484 		}
   487 		}