51 #include "table/strings.h" 
   58 static void DisasterClearSquare(
TileIndex tile)
 
   91 static const SpriteID _disaster_images_1[] = {SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP};
 
   92 static const SpriteID _disaster_images_2[] = {SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT};
 
   93 static const SpriteID _disaster_images_3[] = {SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15};
 
   94 static const SpriteID _disaster_images_4[] = {SPR_SUB_SMALL_NE, SPR_SUB_SMALL_NE, SPR_SUB_SMALL_SE, SPR_SUB_SMALL_SE, SPR_SUB_SMALL_SW, SPR_SUB_SMALL_SW, SPR_SUB_SMALL_NW, SPR_SUB_SMALL_NW};
 
   95 static const SpriteID _disaster_images_5[] = {SPR_SUB_LARGE_NE, SPR_SUB_LARGE_NE, SPR_SUB_LARGE_SE, SPR_SUB_LARGE_SE, SPR_SUB_LARGE_SW, SPR_SUB_LARGE_SW, SPR_SUB_LARGE_NW, SPR_SUB_LARGE_NW};
 
   96 static const SpriteID _disaster_images_6[] = {SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER};
 
   97 static const SpriteID _disaster_images_7[] = {SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER};
 
   98 static const SpriteID _disaster_images_8[] = {SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A};
 
   99 static const SpriteID _disaster_images_9[] = {SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1};
 
  101 static const SpriteID * 
const _disaster_images[] = {
 
  102   _disaster_images_1, _disaster_images_1,                     
 
  103   _disaster_images_2, _disaster_images_2,                     
 
  104   _disaster_images_3, _disaster_images_3,                     
 
  105   _disaster_images_8, _disaster_images_8, _disaster_images_9, 
 
  106   _disaster_images_6, _disaster_images_6,                     
 
  107   _disaster_images_7, _disaster_images_7,                     
 
  108   _disaster_images_4, _disaster_images_5,                     
 
  111 void DisasterVehicle::UpdateImage()
 
  198     u->
y_pos = y - 1 - (
max(z - GetSlopePixelZ(safe_x, safe_y), 0) >> 3);
 
  200     u->
z_pos = GetSlopePixelZ(safe_x, safe_y);
 
  206     if ((u = u->
Next()) != NULL) {
 
  235       if (++v->
age == 38) {
 
  262     if (++v->
age <= 13320) 
return true;
 
  277   int z = GetSlopePixelZ(x, y);
 
  278   if (z < v->z_pos) z = v->
z_pos - 1;
 
  285   } 
else if (v->
age == 70) {
 
  287   } 
else if (v->
age <= 300) {
 
  297   } 
else if (v->
age == 350) {
 
  324       v->
direction = GetDirectionTowards(v, x, y);
 
  337     FOR_ALL_ROADVEHICLES(u) {
 
  348     FOR_ALL_ROADVEHICLES(u) {
 
  373     if (dist <= TILE_SIZE && z > u->
z_pos) z--;
 
  400 static void DestructIndustry(
Industry *i)
 
  431   if ((leave_at_top && gp.x < (-10 * (
int)
TILE_SIZE)) || (!leave_at_top && gp.x > (
int)(
MapSizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1)) {
 
  452     if (++v->
age == 112) {
 
  464     int x = v->
x_pos + ((leave_at_top ? -15 : 15) * TILE_SIZE);
 
  467     if ((uint)x > 
MapMaxX() * TILE_SIZE - 1) 
return true;
 
  503   if (++cur_image > SPR_ROTOR_MOVING_3) cur_image = SPR_ROTOR_MOVING_1;
 
  524       v->
direction = GetDirectionTowards(v, x, y);
 
  570       v->
direction = GetDirectionTowards(v, x, y);
 
  590     } 
while (tile != tile_org);
 
  624     for (
int i = 0; i != 80; i++) {
 
  633     for (
int dy = -3; dy < 3; dy++) {
 
  634       for (
int dx = -3; dx < 3; dx++) {
 
  652   if (++v->
age > 8880) {
 
  682 static DisasterVehicleTickProc * 
const _disastervehicle_tick_procs[] = {
 
  696   return _disastervehicle_tick_procs[this->
subtype](
this);
 
  699 typedef void DisasterInitProc();
 
  714   FOR_ALL_STATIONS(st) {
 
  747 static void Disaster_Airplane_Init()
 
  753   FOR_ALL_INDUSTRIES(i) {
 
  755         (found == NULL || 
Chance16(1, 2))) {
 
  760   if (found == NULL) 
return;
 
  779   FOR_ALL_INDUSTRIES(i) {
 
  781         (found == NULL || 
Chance16(1, 2))) {
 
  786   if (found == NULL) 
return;
 
  802 static void Disaster_Big_Ufo_Init()
 
  841 static void Disaster_Small_Submarine_Init()
 
  848 static void Disaster_Big_Submarine_Init()
 
  860   int index = 
GB(Random(), 0, 4);
 
  863   for (m = 0; m < 15; m++) {
 
  866     FOR_ALL_INDUSTRIES(i) {
 
  875           for (uint n = 0; n < 30; n++) {
 
  876             DisasterClearSquare(tile);
 
  893 static const Disaster _disasters[] = {
 
  896   {Disaster_Airplane_Init,        1960, 1990}, 
 
  898   {Disaster_Big_Ufo_Init,         2000, 2100}, 
 
  899   {Disaster_Small_Submarine_Init, 1940, 1965}, 
 
  900   {Disaster_Big_Submarine_Init,   1975, 2010}, 
 
  904 static void DoDisaster()
 
  909   for (
size_t i = 0; i != 
lengthof(_disasters); i++) {
 
  910     if (
_cur_year >= _disasters[i].min_year && 
_cur_year < _disasters[i].max_year) buf[j++] = (byte)i;
 
  919 static void ResetDisasterDelay()
 
  924 void DisasterDailyLoop()
 
  928   ResetDisasterDelay();
 
  933 void StartupDisasters()
 
  935   ResetDisasterDelay();