OpenTTD
disaster_vehicle.cpp
Go to the documentation of this file.
1 /* $Id: disaster_vehicle.cpp 27668 2016-10-16 14:59:44Z frosch $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8  */
9 
28 #include "stdafx.h"
29 
30 #include "aircraft.h"
31 #include "disaster_vehicle.h"
32 #include "industry.h"
33 #include "station_base.h"
34 #include "command_func.h"
35 #include "news_func.h"
36 #include "town.h"
37 #include "company_func.h"
38 #include "strings_func.h"
39 #include "date_func.h"
40 #include "viewport_func.h"
41 #include "vehicle_func.h"
42 #include "sound_func.h"
43 #include "effectvehicle_func.h"
44 #include "roadveh.h"
45 #include "ai/ai.hpp"
46 #include "game/game.hpp"
47 #include "company_base.h"
48 #include "core/random_func.hpp"
49 #include "core/backup_type.hpp"
50 
51 #include "table/strings.h"
52 
53 #include "safeguards.h"
54 
57 
58 static void DisasterClearSquare(TileIndex tile)
59 {
60  if (EnsureNoVehicleOnGround(tile).Failed()) return;
61 
62  switch (GetTileType(tile)) {
63  case MP_RAILWAY:
64  if (Company::IsHumanID(GetTileOwner(tile)) && !IsRailDepot(tile)) {
65  Backup<CompanyByte> cur_company(_current_company, OWNER_WATER, FILE_LINE);
67  cur_company.Restore();
68 
69  /* update signals in buffer */
71  }
72  break;
73 
74  case MP_HOUSE: {
75  Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
77  cur_company.Restore();
78  break;
79  }
80 
81  case MP_TREES:
82  case MP_CLEAR:
83  DoClearSquare(tile);
84  break;
85 
86  default:
87  break;
88  }
89 }
90 
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};
100 
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,
109 };
110 
111 void DisasterVehicle::UpdateImage()
112 {
113  SpriteID img = this->image_override;
114  if (img == 0) img = _disaster_images[this->subtype][this->direction];
115  this->sprite_seq.Set(img);
116 }
117 
127  SpecializedVehicleBase(), big_ufo_destroyer_target(big_ufo_destroyer_target)
128 {
129  this->vehstatus = VS_UNCLICKABLE;
130 
131  this->x_pos = x;
132  this->y_pos = y;
133  switch (subtype) {
134  case ST_ZEPPELINER:
135  case ST_SMALL_UFO:
136  case ST_AIRPLANE:
137  case ST_HELICOPTER:
138  case ST_BIG_UFO:
140  GetAircraftFlightLevelBounds(this, &this->z_pos, NULL);
141  break;
142 
144  GetAircraftFlightLevelBounds(this, &this->z_pos, NULL);
145  this->z_pos += ROTOR_Z_OFFSET;
146  break;
147 
148  case ST_SMALL_SUBMARINE:
149  case ST_BIG_SUBMARINE:
150  this->z_pos = 0;
151  break;
152 
154  case ST_SMALL_UFO_SHADOW:
155  case ST_AIRPLANE_SHADOW:
157  case ST_BIG_UFO_SHADOW:
159  this->z_pos = 0;
160  this->vehstatus |= VS_SHADOW;
161  break;
162  }
163 
164  this->direction = direction;
165  this->tile = TileVirtXY(x, y);
166  this->subtype = subtype;
167  this->UpdateDeltaXY(INVALID_DIR);
168  this->owner = OWNER_NONE;
169  this->image_override = 0;
170  this->current_order.Free();
171 
172  this->UpdateImage();
174 }
175 
182 void DisasterVehicle::UpdatePosition(int x, int y, int z)
183 {
184  this->x_pos = x;
185  this->y_pos = y;
186  this->z_pos = z;
187  this->tile = TileVirtXY(x, y);
188 
189  this->UpdateImage();
191 
192  DisasterVehicle *u = this->Next();
193  if (u != NULL) {
194  int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
195  int safe_y = Clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
196 
197  u->x_pos = x;
198  u->y_pos = y - 1 - (max(z - GetSlopePixelZ(safe_x, safe_y), 0) >> 3);
199  safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
200  u->z_pos = GetSlopePixelZ(safe_x, safe_y);
201  u->direction = this->direction;
202 
203  u->UpdateImage();
205 
206  if ((u = u->Next()) != NULL) {
207  u->x_pos = x;
208  u->y_pos = y;
209  u->z_pos = z + ROTOR_Z_OFFSET;
211  }
212  }
213 }
214 
224 {
225  v->tick_counter++;
226 
227  if (v->current_order.GetDestination() < 2) {
228  if (HasBit(v->tick_counter, 0)) return true;
229 
231 
232  v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
233 
234  if (v->current_order.GetDestination() == 1) {
235  if (++v->age == 38) {
237  v->age = 0;
238  }
239 
240  if (GB(v->tick_counter, 0, 3) == 0) CreateEffectVehicleRel(v, 0, -17, 2, EV_CRASH_SMOKE);
241 
242  } else if (v->current_order.GetDestination() == 0) {
243  if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
245  v->age = 0;
246 
248  AddVehicleNewsItem(STR_NEWS_DISASTER_ZEPPELIN, NT_ACCIDENT, v->index); // Delete the news, when the zeppelin is gone
249  AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCrashed(GetStationIndex(v->tile)));
250  }
251  }
252 
253  if (v->y_pos >= (int)((MapSizeY() + 9) * TILE_SIZE - 1)) {
254  delete v;
255  return false;
256  }
257 
258  return true;
259  }
260 
261  if (v->current_order.GetDestination() > 2) {
262  if (++v->age <= 13320) return true;
263 
264  if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
265  Station *st = Station::GetByTile(v->tile);
266  CLRBITS(st->airport.flags, RUNWAY_IN_block);
267  AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCleared(st->index));
268  }
269 
270  v->UpdatePosition(v->x_pos, v->y_pos, GetAircraftFlightLevel(v));
271  delete v;
272  return false;
273  }
274 
275  int x = v->x_pos;
276  int y = v->y_pos;
277  int z = GetSlopePixelZ(x, y);
278  if (z < v->z_pos) z = v->z_pos - 1;
279  v->UpdatePosition(x, y, z);
280 
281  if (++v->age == 1) {
283  if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
284  v->image_override = SPR_BLIMP_CRASHING;
285  } else if (v->age == 70) {
286  v->image_override = SPR_BLIMP_CRASHED;
287  } else if (v->age <= 300) {
288  if (GB(v->tick_counter, 0, 3) == 0) {
289  uint32 r = Random();
290 
292  GB(r, 0, 4) - 7,
293  GB(r, 4, 4) - 7,
294  GB(r, 8, 3) + 5,
296  }
297  } else if (v->age == 350) {
299  v->age = 0;
300  }
301 
302  if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
303  SETBITS(Station::GetByTile(v->tile)->airport.flags, RUNWAY_IN_block);
304  }
305 
306  return true;
307 }
308 
316 {
317  v->image_override = (HasBit(++v->tick_counter, 3)) ? SPR_UFO_SMALL_SCOUT_DARKER : SPR_UFO_SMALL_SCOUT;
318 
319  if (v->current_order.GetDestination() == 0) {
320  /* Fly around randomly */
321  int x = TileX(v->dest_tile) * TILE_SIZE;
322  int y = TileY(v->dest_tile) * TILE_SIZE;
323  if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) {
324  v->direction = GetDirectionTowards(v, x, y);
326  v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
327  return true;
328  }
329  if (++v->age < 6) {
330  v->dest_tile = RandomTile();
331  return true;
332  }
334 
335  uint n = 0; // Total number of targetable road vehicles.
336  RoadVehicle *u;
337  FOR_ALL_ROADVEHICLES(u) {
338  if (u->IsFrontEngine()) n++;
339  }
340 
341  if (n == 0) {
342  /* If there are no targetable road vehicles, destroy the UFO. */
343  delete v;
344  return false;
345  }
346 
347  n = RandomRange(n); // Choose one of them.
348  FOR_ALL_ROADVEHICLES(u) {
349  /* Find (n+1)-th road vehicle. */
350  if (u->IsFrontEngine() && (n-- == 0)) break;
351  }
352 
353  /* Target it. */
354  v->dest_tile = u->index;
355  v->age = 0;
356  return true;
357  } else {
358  /* Target a vehicle */
360  assert(u != NULL && u->type == VEH_ROAD && u->IsFrontEngine());
361 
362  uint dist = Delta(v->x_pos, u->x_pos) + Delta(v->y_pos, u->y_pos);
363 
364  if (dist < TILE_SIZE && !(u->vehstatus & VS_HIDDEN) && u->breakdown_ctr == 0) {
365  u->breakdown_ctr = 3;
366  u->breakdown_delay = 140;
367  }
368 
369  v->direction = GetDirectionTowards(v, u->x_pos, u->y_pos);
371 
372  int z = v->z_pos;
373  if (dist <= TILE_SIZE && z > u->z_pos) z--;
374  v->UpdatePosition(gp.x, gp.y, z);
375 
376  if (z <= u->z_pos && (u->vehstatus & VS_HIDDEN) == 0) {
377  v->age++;
378  if (u->crashed_ctr == 0) {
379  u->Crash();
380 
381  AddVehicleNewsItem(STR_NEWS_DISASTER_SMALL_UFO, NT_ACCIDENT, u->index); // delete the news, when the roadvehicle is gone
382 
383  AI::NewEvent(u->owner, new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO));
384  Game::NewEvent(new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO));
385  }
386  }
387 
388  /* Destroy? */
389  if (v->age > 50) {
391  if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
392  delete v;
393  return false;
394  }
395  }
396 
397  return true;
398 }
399 
400 static void DestructIndustry(Industry *i)
401 {
402  for (TileIndex tile = 0; tile != MapSize(); tile++) {
403  if (i->TileBelongsToIndustry(tile)) {
406  }
407  }
408 }
409 
423 static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, bool leave_at_top, StringID news_message, IndustryBehaviour industry_flag)
424 {
425  v->tick_counter++;
426  v->image_override = (v->current_order.GetDestination() == 1 && HasBit(v->tick_counter, 2)) ? image_override : 0;
427 
429  v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
430 
431  if ((leave_at_top && gp.x < (-10 * (int)TILE_SIZE)) || (!leave_at_top && gp.x > (int)(MapSizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1)) {
432  delete v;
433  return false;
434  }
435 
436  if (v->current_order.GetDestination() == 2) {
437  if (GB(v->tick_counter, 0, 2) == 0) {
438  Industry *i = Industry::Get(v->dest_tile); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid
439  int x = TileX(i->location.tile) * TILE_SIZE;
440  int y = TileY(i->location.tile) * TILE_SIZE;
441  uint32 r = Random();
442 
444  GB(r, 0, 6) + x,
445  GB(r, 6, 6) + y,
446  GB(r, 12, 4),
448 
449  if (++v->age >= 55) v->current_order.SetDestination(3);
450  }
451  } else if (v->current_order.GetDestination() == 1) {
452  if (++v->age == 112) {
454  v->age = 0;
455 
456  Industry *i = Industry::Get(v->dest_tile); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid
457  DestructIndustry(i);
458 
459  SetDParam(0, i->town->index);
460  AddIndustryNewsItem(news_message, NT_ACCIDENT, i->index); // delete the news, when the industry closes
461  if (_settings_client.sound.disaster) SndPlayTileFx(SND_12_EXPLOSION, i->location.tile);
462  }
463  } else if (v->current_order.GetDestination() == 0) {
464  int x = v->x_pos + ((leave_at_top ? -15 : 15) * TILE_SIZE);
465  int y = v->y_pos;
466 
467  if ((uint)x > MapMaxX() * TILE_SIZE - 1) return true;
468 
469  TileIndex tile = TileVirtXY(x, y);
470  if (!IsTileType(tile, MP_INDUSTRY)) return true;
471 
472  IndustryID ind = GetIndustryIndex(tile);
473  v->dest_tile = ind;
474 
475  if (GetIndustrySpec(Industry::Get(ind)->type)->behaviour & industry_flag) {
477  v->age = 0;
478  }
479  }
480 
481  return true;
482 }
483 
486 {
487  return DisasterTick_Aircraft(v, SPR_F_15_FIRING, true, STR_NEWS_DISASTER_AIRPLANE_OIL_REFINERY, INDUSTRYBEH_AIRPLANE_ATTACKS);
488 }
489 
492 {
493  return DisasterTick_Aircraft(v, SPR_AH_64A_FIRING, false, STR_NEWS_DISASTER_HELICOPTER_FACTORY, INDUSTRYBEH_CHOPPER_ATTACKS);
494 }
495 
498 {
499  v->tick_counter++;
500  if (HasBit(v->tick_counter, 0)) return true;
501 
502  SpriteID &cur_image = v->sprite_seq.seq[0].sprite;
503  if (++cur_image > SPR_ROTOR_MOVING_3) cur_image = SPR_ROTOR_MOVING_1;
504 
506 
507  return true;
508 }
509 
517 {
518  v->tick_counter++;
519 
520  if (v->current_order.GetDestination() == 1) {
521  int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
522  int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
523  if (Delta(v->x_pos, x) + Delta(v->y_pos, y) >= 8) {
524  v->direction = GetDirectionTowards(v, x, y);
525 
527  v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
528  return true;
529  }
530 
531  if (!IsValidTile(v->dest_tile)) {
532  /* Make sure we don't land outside the map. */
533  delete v;
534  return false;
535  }
536 
537  int z = GetSlopePixelZ(v->x_pos, v->y_pos);
538  if (z < v->z_pos) {
539  v->UpdatePosition(v->x_pos, v->y_pos, v->z_pos - 1);
540  return true;
541  }
542 
544 
545  Vehicle *target;
546  FOR_ALL_VEHICLES(target) {
547  if (target->IsGroundVehicle()) {
548  if (Delta(target->x_pos, v->x_pos) + Delta(target->y_pos, v->y_pos) <= 12 * (int)TILE_SIZE) {
549  target->breakdown_ctr = 5;
550  target->breakdown_delay = 0xF0;
551  }
552  }
553  }
554 
555  Town *t = ClosestTownFromTile(v->dest_tile, UINT_MAX);
556  SetDParam(0, t->index);
557  AddTileNewsItem(STR_NEWS_DISASTER_BIG_UFO, NT_ACCIDENT, v->tile);
558 
559  if (!Vehicle::CanAllocateItem(2)) {
560  delete v;
561  return false;
562  }
564  DisasterVehicle *w = new DisasterVehicle(-6 * (int)TILE_SIZE, v->y_pos, DIR_SW, ST_BIG_UFO_DESTROYER_SHADOW);
565  u->SetNext(w);
566  } else if (v->current_order.GetDestination() == 0) {
567  int x = TileX(v->dest_tile) * TILE_SIZE;
568  int y = TileY(v->dest_tile) * TILE_SIZE;
569  if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) {
570  v->direction = GetDirectionTowards(v, x, y);
572  v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
573  return true;
574  }
575 
576  if (++v->age < 6) {
577  v->dest_tile = RandomTile();
578  return true;
579  }
581 
582  TileIndex tile_org = RandomTile();
583  TileIndex tile = tile_org;
584  do {
585  if (IsPlainRailTile(tile) &&
587  break;
588  }
589  tile = TILE_MASK(tile + 1);
590  } while (tile != tile_org);
591  v->dest_tile = tile;
592  v->age = 0;
593  }
594 
595  return true;
596 }
597 
603 {
604  v->tick_counter++;
605 
607  v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
608 
609  if (gp.x > (int)(MapSizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1) {
610  delete v;
611  return false;
612  }
613 
614  if (v->current_order.GetDestination() == 0) {
616  if (Delta(v->x_pos, u->x_pos) > (int)TILE_SIZE) return true;
618 
620  if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, u);
621 
622  delete u;
623 
624  for (int i = 0; i != 80; i++) {
625  uint32 r = Random();
627  GB(r, 0, 6) + v->x_pos - 32,
628  GB(r, 5, 6) + v->y_pos - 32,
629  0,
631  }
632 
633  for (int dy = -3; dy < 3; dy++) {
634  for (int dx = -3; dx < 3; dx++) {
635  TileIndex tile = TileAddWrap(v->tile, dx, dy);
636  if (tile != INVALID_TILE) DisasterClearSquare(tile);
637  }
638  }
639  }
640 
641  return true;
642 }
643 
649 {
650  v->tick_counter++;
651 
652  if (++v->age > 8880) {
653  delete v;
654  return false;
655  }
656 
657  if (!HasBit(v->tick_counter, 0)) return true;
658 
660  if (IsValidTile(tile)) {
662  if (trackbits == TRACK_BIT_ALL && !Chance16(1, 90)) {
664  v->UpdatePosition(gp.x, gp.y, v->z_pos);
665  return true;
666  }
667  }
668 
669  v->direction = ChangeDir(v->direction, GB(Random(), 0, 1) ? DIRDIFF_90RIGHT : DIRDIFF_90LEFT);
670 
671  return true;
672 }
673 
674 
675 static bool DisasterTick_NULL(DisasterVehicle *v)
676 {
677  return true;
678 }
679 
680 typedef bool DisasterVehicleTickProc(DisasterVehicle *v);
681 
682 static DisasterVehicleTickProc * const _disastervehicle_tick_procs[] = {
683  DisasterTick_Zeppeliner, DisasterTick_NULL,
684  DisasterTick_Ufo, DisasterTick_NULL,
685  DisasterTick_Airplane, DisasterTick_NULL,
688  DisasterTick_NULL,
691 };
692 
693 
695 {
696  return _disastervehicle_tick_procs[this->subtype](this);
697 }
698 
699 typedef void DisasterInitProc();
700 
701 
707 {
708  if (!Vehicle::CanAllocateItem(2)) return;
709 
710  /* Pick a random place, unless we find a small airport */
711  int x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
712 
713  Station *st;
714  FOR_ALL_STATIONS(st) {
715  if (st->airport.tile != INVALID_TILE && (st->airport.type == AT_SMALL || st->airport.type == AT_LARGE)) {
716  x = (TileX(st->airport.tile) + 2) * TILE_SIZE;
717  break;
718  }
719  }
720 
722  /* Allocate shadow */
724  v->SetNext(u);
725 }
726 
727 
733 {
734  if (!Vehicle::CanAllocateItem(2)) return;
735 
736  int x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
738  v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
739 
740  /* Allocate shadow */
742  v->SetNext(u);
743 }
744 
745 
746 /* Combat airplane which destroys an oil refinery */
747 static void Disaster_Airplane_Init()
748 {
749  if (!Vehicle::CanAllocateItem(2)) return;
750 
751  Industry *i, *found = NULL;
752 
753  FOR_ALL_INDUSTRIES(i) {
755  (found == NULL || Chance16(1, 2))) {
756  found = i;
757  }
758  }
759 
760  if (found == NULL) return;
761 
762  /* Start from the bottom (south side) of the map */
763  int x = (MapSizeX() + 9) * TILE_SIZE - 1;
764  int y = TileY(found->location.tile) * TILE_SIZE + 37;
765 
768  v->SetNext(u);
769 }
770 
771 
774 {
775  if (!Vehicle::CanAllocateItem(3)) return;
776 
777  Industry *i, *found = NULL;
778 
779  FOR_ALL_INDUSTRIES(i) {
781  (found == NULL || Chance16(1, 2))) {
782  found = i;
783  }
784  }
785 
786  if (found == NULL) return;
787 
788  int x = -16 * (int)TILE_SIZE;
789  int y = TileY(found->location.tile) * TILE_SIZE + 37;
790 
793  v->SetNext(u);
794 
796  u->SetNext(w);
797 }
798 
799 
800 /* Big Ufo which lands on a piece of rail and will consequently be shot
801  * down by a combat airplane, destroying the surroundings */
802 static void Disaster_Big_Ufo_Init()
803 {
804  if (!Vehicle::CanAllocateItem(2)) return;
805 
806  int x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
807  int y = MapMaxX() * TILE_SIZE - 1;
808 
810  v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
811 
812  /* Allocate shadow */
814  v->SetNext(u);
815 }
816 
817 
818 static void Disaster_Submarine_Init(DisasterSubType subtype)
819 {
820  if (!Vehicle::CanAllocateItem()) return;
821 
822  int y;
823  Direction dir;
824  uint32 r = Random();
825  int x = TileX(r) * TILE_SIZE + TILE_SIZE / 2;
826 
827  if (HasBit(r, 31)) {
828  y = MapMaxY() * TILE_SIZE - TILE_SIZE / 2 - 1;
829  dir = DIR_NW;
830  } else {
831  y = TILE_SIZE / 2;
833  dir = DIR_SE;
834  }
835  if (!IsWaterTile(TileVirtXY(x, y))) return;
836 
837  new DisasterVehicle(x, y, dir, subtype);
838 }
839 
840 /* Curious submarine #1, just floats around */
841 static void Disaster_Small_Submarine_Init()
842 {
843  Disaster_Submarine_Init(ST_SMALL_SUBMARINE);
844 }
845 
846 
847 /* Curious submarine #2, just floats around */
848 static void Disaster_Big_Submarine_Init()
849 {
850  Disaster_Submarine_Init(ST_BIG_SUBMARINE);
851 }
852 
853 
859 {
860  int index = GB(Random(), 0, 4);
861  uint m;
862 
863  for (m = 0; m < 15; m++) {
864  const Industry *i;
865 
866  FOR_ALL_INDUSTRIES(i) {
867  if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
868  SetDParam(0, i->town->index);
869  AddTileNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE, NT_ACCIDENT, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes
870 
871  {
873  TileIndexDiff step = TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
874 
875  for (uint n = 0; n < 30; n++) {
876  DisasterClearSquare(tile);
877  tile += step;
878  if (!IsValidTile(tile)) break;
879  }
880  }
881  return;
882  }
883  }
884  }
885 }
886 
887 struct Disaster {
888  DisasterInitProc *init_proc;
891 };
892 
893 static const Disaster _disasters[] = {
894  {Disaster_Zeppeliner_Init, 1930, 1955}, // zeppeliner
895  {Disaster_Small_Ufo_Init, 1940, 1970}, // ufo (small)
896  {Disaster_Airplane_Init, 1960, 1990}, // airplane
897  {Disaster_Helicopter_Init, 1970, 2000}, // helicopter
898  {Disaster_Big_Ufo_Init, 2000, 2100}, // ufo (big)
899  {Disaster_Small_Submarine_Init, 1940, 1965}, // submarine (small)
900  {Disaster_Big_Submarine_Init, 1975, 2010}, // submarine (big)
901  {Disaster_CoalMine_Init, 1950, 1985}, // coalmine
902 };
903 
904 static void DoDisaster()
905 {
906  byte buf[lengthof(_disasters)];
907 
908  byte j = 0;
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;
911  }
912 
913  if (j == 0) return;
914 
915  _disasters[buf[RandomRange(j)]].init_proc();
916 }
917 
918 
919 static void ResetDisasterDelay()
920 {
921  _disaster_delay = GB(Random(), 0, 9) + 730;
922 }
923 
924 void DisasterDailyLoop()
925 {
926  if (--_disaster_delay != 0) return;
927 
928  ResetDisasterDelay();
929 
930  if (_settings_game.difficulty.disasters != 0) DoDisaster();
931 }
932 
933 void StartupDisasters()
934 {
935  ResetDisasterDelay();
936 }
937 
944 {
945  DisasterVehicle *v;
947  /* primary disaster vehicles that have chosen target */
948  if (v->subtype == ST_AIRPLANE || v->subtype == ST_HELICOPTER) {
949  /* if it has chosen target, and it is this industry (yes, dest_tile is IndustryID here), set order to "leaving map peacefully" */
950  if (v->current_order.GetDestination() > 0 && v->dest_tile == i) v->current_order.SetDestination(3);
951  }
952  }
953 }
954 
960 {
961  DisasterVehicle *v;
963  /* primary disaster vehicles that have chosen target */
964  if (v->subtype == ST_SMALL_UFO) {
965  if (v->current_order.GetDestination() != 0 && v->dest_tile == vehicle) {
966  /* Revert to target-searching */
968  v->dest_tile = RandomTile();
969  GetAircraftFlightLevelBounds(v, &v->z_pos, NULL);
970  v->age = 0;
971  }
972  }
973  }
974 }
975 
977 {
978  this->x_offs = -1;
979  this->y_offs = -1;
980  this->x_extent = 2;
981  this->y_extent = 2;
982  this->z_extent = 5;
983 }
Flag for an invalid direction.
Shadow of the aircraft.
static RoadVehicle * Get(size_t index)
Gets vehicle with given index.
Functions related to OTTD&#39;s strings.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:89
Road vehicle states.
byte type
Type of this airport,.
Definition: station_base.h:309
#define RandomTile()
Get a valid random tile.
Definition: map_func.h:425
can be exploded by a military airplane (oil refinery)
Definition: industrytype.h:75
static uint MapSizeX()
Get the size of the map along the X.
Definition: map_func.h:74
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition: game_core.cpp:134
Airplane destroying an oil refinery.
Definition of stuff that is very close to a company, like the company struct itself.
Year max_year
The last year this disaster will occur.
Year min_year
The first year this disaster will occur.
static uint MapSizeY()
Get the size of the map along the Y.
Definition: map_func.h:84
All disaster vehicles.
Shadow of the big UFO.
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
DirectionByte direction
facing
Definition: vehicle_base.h:271
static bool IsAirportTile(TileIndex t)
Is this tile a station tile and an airport tile?
Definition: station_map.h:168
void UpdateDeltaXY(Direction direction)
Updates the x and y offsets and the size of the sprite used for this vehicle.
Part of an industry.
Definition: tile_type.h:51
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
Definition: vehicle.cpp:538
static bool DisasterTick_Submarine(DisasterVehicle *v)
Submarine, v->current_order.dest states: Unused, just float around aimlessly and pop up at different ...
int32 TileIndexDiff
An offset value between to tiles.
Definition: map_func.h:156
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:246
Functions related to dates.
byte breakdown_delay
Counter for managing breakdown length.
Definition: vehicle_base.h:264
Various explosions.
Angle of 90 degrees right.
Vehicle is a shadow vehicle.
Definition: vehicle_base.h:37
Town * town
Nearest town.
Definition: industry.h:41
Large airport.
Definition: airport.h:32
static const int ROTOR_Z_OFFSET
Z Offset between helicopter- and rotorsprite.
Definition: aircraft.h:50
#define SETBITS(x, y)
Sets several bits in a variable.
TileIndex dest_tile
Heading for this tile.
Definition: vehicle_base.h:237
Transport over water.
Functions related to vehicles.
static bool IsHumanID(size_t index)
Is this company a company not controlled by a NoAI program?
Definition: company_base.h:157
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:207
Vehicle data structure.
Definition: vehicle_base.h:212
bool disasters
are disasters enabled
Definition: settings_type.h:70
Defines the internal data of a functional industry.
Definition: industry.h:39
can cause a subsidence (coal mine, shaft that collapses)
Definition: industrytype.h:77
demolish a tile
Definition: command_type.h:182
void Set(SpriteID sprite)
Assign a single sprite to the sequence.
Definition: vehicle_base.h:163
DifficultySettings difficulty
settings related to the difficulty
Tindex index
Index of this pool item.
Definition: pool_type.hpp:147
void SetNext(Vehicle *next)
Set the next vehicle of this vehicle.
Definition: vehicle.cpp:2631
static SigSegState UpdateSignalsInBuffer(Owner owner)
Updates blocks in _globset buffer.
Definition: signal.cpp:472
Base for aircraft.
A railway.
Definition: tile_type.h:44
Small submarine, pops up in the oceans but doesn&#39;t do anything.
#define CLRBITS(x, y)
Clears several bits in a variable.
static void ResetIndustryConstructionStage(TileIndex tile)
Reset the construction stage counter of the industry, as well as the completion bit.
Definition: industry_map.h:189
void GetAircraftFlightLevelBounds(const Vehicle *v, int *min, int *max)
Get the &#39;flight level&#39; bounds, in pixels from &#39;z_pos&#39; 0 for a particular vehicle for normal flight si...
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:20
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:26
byte vehstatus
Status.
Definition: vehicle_base.h:317
EffectVehicle * CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type)
Create an effect vehicle above a particular location.
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:26
static void Disaster_CoalMine_Init()
Coal mine catastrophe, destroys a stretch of 30 tiles of land in a certain direction.
static const uint TILE_SIZE
Tile size in world coordinates.
Definition: tile_type.h:15
static uint32 RandomRange(uint32 limit)
Pick a random number between 0 and limit - 1, inclusive.
Definition: random_func.hpp:83
VehicleSpriteSeq sprite_seq
Vehicle appearance.
Definition: vehicle_base.h:280
Direction
Defines the 8 directions on the map.
Various explosions.
Southeast.
Class to backup a specific variable and restore it later.
Definition: backup_type.hpp:23
can be exploded by a military helicopter (factory)
Definition: industrytype.h:76
Functions related to (drawing on) viewports.
Pseudo random number generator.
Northeast.
Small UFO, tries to find a road vehicle to destroy.
bool freeform_edges
allow terraforming the tiles at the map edges
byte breakdown_ctr
Counter for managing breakdown events.
Definition: vehicle_base.h:263
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
Definition: tile_map.h:154
byte subtype
subtype (Filled with values from #EffectVehicles/#TrainSubTypes/#AircraftSubTypes) ...
Definition: vehicle_base.h:327
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:41
Buses, trucks and trams belong to this class.
Definition: roadveh.h:88
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold...
Definition: town_cmd.cpp:3239
Big UFO, finds a piece of railroad to "park" on.
Class defining several overloaded accessors so we don&#39;t have to cast vehicle types that often...
Definition: vehicle_base.h:993
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:343
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a give tiletype.
Definition: tile_map.h:143
All possible tracks.
Definition: track_type.h:56
int y
x and y position of the vehicle after moving
Definition: vehicle_func.h:78
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
Definition: command.cpp:436
static bool DisasterTick_Big_Ufo_Destroyer(DisasterVehicle *v)
Skyranger destroying (Big) Ufo handling, v->current_order.dest states: 0: Home in on landed Ufo and s...
Shadow of small UFO.
SoundSettings sound
sound effect settings
static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, bool leave_at_top, StringID news_message, IndustryBehaviour industry_flag)
Aircraft handling, v->current_order.dest states: 0: Fly towards the targeted industry 1: If within 15...
int8 y_offs
y offset for vehicle sprite
Definition: vehicle_base.h:287
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:18
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
Definition: tile_map.h:171
static void Disaster_Zeppeliner_Init()
Zeppeliner which crashes on a small airport if one found, otherwise crashes on a random tile...
Rotors of helicopter.
DisasterVehicle * Next() const
Get next vehicle in the chain.
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:76
DisasterVehicle()
For use by saveload.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
byte x_extent
x-extent of vehicle bounding box
Definition: vehicle_base.h:281
IndustryType type
type of industry.
Definition: industry.h:55
byte z_extent
z-extent of vehicle bounding box
Definition: vehicle_base.h:283
static void Disaster_Helicopter_Init()
Combat helicopter that destroys a factory.
TileArea location
Location of the industry.
Definition: industry.h:40
Smoke of disasters.
static void Disaster_Small_Ufo_Init()
Ufo which flies around aimlessly from the middle of the map a bit until it locates a road vehicle whi...
bool IsFrontEngine() const
Check if the vehicle is a front engine.
Definition: vehicle_base.h:882
TileIndex tile
Current tile index.
Definition: vehicle_base.h:230
The tile has no ownership.
Definition: company_type.h:27
static Direction ChangeDir(Direction d, DirDiff delta)
Change a direction by a given difference.
int8 x_offs
x offset for vehicle sprite
Definition: vehicle_base.h:286
uint64 flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
Definition: station_base.h:308
DiagDirection
Enumeration for diagonal directions.
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:42
Road vehicle type.
Definition: vehicle_type.h:25
IndustryBehaviour behaviour
How this industry will behave, and how others entities can use it.
Definition: industrytype.h:120
SpriteID image_override
Override for the default disaster vehicle sprite.
uint Crash(bool flooded=false)
Crash the (whole) vehicle chain.
static bool IsWaterTile(TileIndex t)
Is it a water tile with plain water?
Definition: water_map.h:184
static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
(Big) Ufo handling, v->current_order.dest states: 0: Fly around to the middle of the map...
Functions related to sound.
static bool IsPlainRailTile(TileIndex t)
Checks whether the tile is a rail tile or rail tile with signals.
Definition: rail_map.h:61
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
byte tick_counter
Increased by one for each tick.
Definition: vehicle_base.h:314
EffectVehicle * CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type)
Create an effect vehicle above a particular vehicle.
uint16 crashed_ctr
Animation counter when the vehicle has crashed.
Definition: roadveh.h:94
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
Definition: landscape.cpp:509
Aircraft the will bomb the big UFO.
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Definition: ai_core.cpp:233
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:139
TileIndex TileAddWrap(TileIndex tile, int addx, int addy)
This function checks if we add addx/addy to tile, if we do wrap around the edges. ...
Definition: map.cpp:116
static bool Chance16(const uint a, const uint b)
Flips a coin with given probability.
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
Small airport.
Definition: airport.h:31
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:1904
Helicopter destroying a factory.
Angle of 90 degrees left.
execute the given command
Definition: command_type.h:342
Functions related to companies.
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v)
Get position information of a vehicle when moving one pixel in the direction it is facing...
Definition: vehicle.cpp:1608
void UpdatePosition()
Update the position of the vehicle.
Definition: vehicle.cpp:1547
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Definition: station_map.h:29
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:196
Tile got trees.
Definition: tile_type.h:47
static uint MapSize()
Get the size of the map.
Definition: map_func.h:94
void UpdatePosition(int x, int y, int z)
Update the position of the vehicle.
VehicleID big_ufo_destroyer_target
The big UFO that this destroyer is supposed to bomb.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
Definition: vehicle_base.h:472
static bool IsRailDepot(TileIndex t)
Is this rail tile a rail depot?
Definition: rail_map.h:96
DestinationID GetDestination() const
Gets the destination of this order.
Definition: order_base.h:96
static bool DisasterTick_Helicopter_Rotors(DisasterVehicle *v)
Helicopter rotor blades; keep these spinning.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:19
CompanyByte _current_company
Company currently doing an action.
Definition: company_cmd.cpp:47
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
void ReleaseDisastersTargetingIndustry(IndustryID i)
Marks all disasters targeting this industry in such a way they won&#39;t call Industry::Get(v->dest_tile)...
Position information of a vehicle after it moved.
Definition: vehicle_func.h:77
static IndustryID GetIndustryIndex(TileIndex t)
Get the industry ID of the given tile.
Definition: industry_map.h:65
Shadow of the zeppelin.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:217
void Free()
&#39;Free&#39; the order
Definition: order_cmd.cpp:64
Disasters, like submarines, skyrangers and their shadows, belong to this class.
OwnerByte owner
Which company owns the vehicle?
Definition: vehicle_base.h:273
DisasterInitProc * init_proc
The init function for this disaster.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void ReleaseDisastersTargetingVehicle(VehicleID vehicle)
Notify disasters that we are about to delete a vehicle.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Definition: map_func.h:113
Town data structure.
Definition: town.h:55
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
Definition: track_func.h:351
bool disaster
Play disaster and accident sounds.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
Definition: pool_type.hpp:216
int32 z_pos
z coordinate.
Definition: vehicle_base.h:270
Vehicle is not visible.
Definition: vehicle_base.h:32
Base functions for all Games.
Functions related to commands.
IndustryBehaviour
Various industry behaviours mostly to represent original TTD specialities.
Definition: industrytype.h:62
An accident or disaster has occurred.
Definition: news_type.h:39
static bool DisasterTick_Ufo(DisasterVehicle *v)
(Small) Ufo handling, v->current_order.dest states: 0: Fly around to the middle of the map...
Zeppelin, crashes at airports.
void SetDestination(DestinationID destination)
Sets the destination of this order.
Definition: order_base.h:103
ConstructionSettings construction
construction of things in-game
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:181
#define FOR_ALL_DISASTERVEHICLES(var)
Iterate over disaster vehicles.
Base of all industries.
Airport airport
Tile area the airport covers.
Definition: station_base.h:460
Northwest.
byte y_extent
y-extent of vehicle bounding box
Definition: vehicle_base.h:282
int32 x_pos
x coordinate.
Definition: vehicle_base.h:268
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
void Restore()
Restore the variable.
Base functions for all AIs.
#define FOR_ALL_VEHICLES(var)
Iterate over all vehicles.
Definition: vehicle_base.h:986
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:85
Base of the town class.
bool TileBelongsToIndustry(TileIndex tile) const
Check if a given tile belongs to this industry.
Definition: industry.h:83
static bool DisasterTick_Airplane(DisasterVehicle *v)
Airplane handling.
A tile without any structures, i.e. grass, rocks, farm fields etc.
Definition: tile_type.h:43
A house by a town.
Definition: tile_type.h:46
int32 y_pos
y coordinate.
Definition: vehicle_base.h:269
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Definition: map_func.h:104
Big submarine, pops up in the oceans but doesn&#39;t do anything.
SpriteID sprite
The &#39;real&#39; sprite.
Definition: gfx_type.h:25
Functions related to news.
Base classes/functions for stations.
static T Delta(const T a, const T b)
Returns the (absolute) difference between two (scalar) variables.
Definition: math_func.hpp:232
Date age
Age in days.
Definition: vehicle_base.h:258
Shadow of helicopter.
Southwest.
The tile/execution is done by "water".
Definition: company_type.h:28
VehicleTypeByte type
Type of vehicle.
Definition: vehicle_type.h:54
Class for backupping variables and making sure they are restored later.
Station data structure.
Definition: station_base.h:446
Functions related to effect vehicles.
#define TILE_MASK(x)
&#39;Wraps&#39; the given tile to it is within the map.
Definition: map_func.h:28
Shadow of airplane.
DisasterSubType
Different sub types of disaster vehicles.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
Definition: map_func.h:165
static bool DisasterTick_Helicopter(DisasterVehicle *v)
Helicopter handling.
Order current_order
The current order (+ status, like: loading)
Definition: vehicle_base.h:318
void UpdatePositionAndViewport()
Update the position of the vehicle, and update the viewport.
Definition: vehicle.cpp:1589
static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
Zeppeliner handling, v->current_order.dest states: 0: Zeppeliner initialization has found a small air...
Vehicle is not clickable by the user (shadow vehicles).
Definition: vehicle_base.h:34
uint16 _disaster_delay
Delay counter for considering the next disaster.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:201
static void AddVehicleNewsItem(StringID string, NewsType type, VehicleID vehicle, StationID station=INVALID_STATION)
Adds a newsitem referencing a vehicle.
Definition: news_func.h:32
bool Tick()
Calls the tick handler of the vehicle.