Merge branch 'master' into jgrpp
# Conflicts: # config.lib # projects/openttd_vs140.vcxproj # projects/openttd_vs140.vcxproj.filters # projects/openttd_vs141.vcxproj # projects/openttd_vs141.vcxproj.filters # projects/openttd_vs142.vcxproj # projects/openttd_vs142.vcxproj.filters # src/aircraft_cmd.cpp # src/base_station_base.h # src/core/pool_type.hpp # src/disaster_vehicle.cpp # src/economy.cpp # src/engine.cpp # src/group.h # src/group_cmd.cpp # src/group_gui.cpp # src/lang/english.txt # src/lang/german.txt # src/linkgraph/linkgraph_gui.cpp # src/network/network_command.cpp # src/network/network_server.cpp # src/openttd.cpp # src/order_cmd.cpp # src/road_cmd.cpp # src/saveload/afterload.cpp # src/saveload/cargopacket_sl.cpp # src/saveload/linkgraph_sl.cpp # src/saveload/order_sl.cpp # src/saveload/station_sl.cpp # src/saveload/town_sl.cpp # src/saveload/vehicle_sl.cpp # src/screenshot.cpp # src/screenshot.h # src/settings_gui.cpp # src/settings_type.h # src/smallmap_gui.cpp # src/station.cpp # src/station_cmd.cpp # src/table/settings.ini # src/toolbar_gui.cpp # src/town_cmd.cpp # src/train.h # src/train_cmd.cpp # src/train_gui.cpp # src/vehicle.cpp # src/vehicle_base.h # src/vehiclelist.cpp # src/window_type.h
This commit is contained in:
@@ -352,8 +352,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
|
||||
v->current_order.SetDestination(1);
|
||||
|
||||
uint n = 0; // Total number of targetable road vehicles.
|
||||
RoadVehicle *u;
|
||||
FOR_ALL_ROADVEHICLES(u) {
|
||||
for (const RoadVehicle *u : RoadVehicle::Iterate()) {
|
||||
if (u->IsFrontEngine()) n++;
|
||||
}
|
||||
|
||||
@@ -364,14 +363,16 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
|
||||
}
|
||||
|
||||
n = RandomRange(n); // Choose one of them.
|
||||
FOR_ALL_ROADVEHICLES(u) {
|
||||
for (const RoadVehicle *u : RoadVehicle::Iterate()) {
|
||||
/* Find (n+1)-th road vehicle. */
|
||||
if (u->IsFrontEngine() && (n-- == 0)) break;
|
||||
if (u->IsFrontEngine() && (n-- == 0)) {
|
||||
/* Target it. */
|
||||
v->dest_tile = u->index;
|
||||
v->age = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Target it. */
|
||||
v->dest_tile = u->index;
|
||||
v->age = 0;
|
||||
return true;
|
||||
} else {
|
||||
/* Target a vehicle */
|
||||
@@ -562,8 +563,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
|
||||
|
||||
v->current_order.SetDestination(2);
|
||||
|
||||
Vehicle *target;
|
||||
FOR_ALL_VEHICLES(target) {
|
||||
for (Vehicle *target : Vehicle::Iterate()) {
|
||||
if (target->IsGroundVehicle() && !HasBit(target->subtype, GVSF_VIRTUAL)) {
|
||||
if (Delta(target->x_pos, v->x_pos) + Delta(target->y_pos, v->y_pos) <= 12 * (int)TILE_SIZE) {
|
||||
target->breakdown_ctr = 5;
|
||||
@@ -733,8 +733,7 @@ static void Disaster_Zeppeliner_Init()
|
||||
/* Pick a random place, unless we find a small airport */
|
||||
int x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
|
||||
|
||||
Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
for (const Station *st : Station::Iterate()) {
|
||||
if (st->airport.tile != INVALID_TILE && (st->airport.type == AT_SMALL || st->airport.type == AT_LARGE)) {
|
||||
x = (TileX(st->airport.tile) + 2) * TILE_SIZE;
|
||||
break;
|
||||
@@ -775,9 +774,9 @@ static void Disaster_Airplane_Init()
|
||||
{
|
||||
if (!Vehicle::CanAllocateItem(2)) return;
|
||||
|
||||
Industry *i, *found = nullptr;
|
||||
Industry *found = nullptr;
|
||||
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
for (Industry *i : Industry::Iterate()) {
|
||||
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_AIRPLANE_ATTACKS) &&
|
||||
(found == nullptr || Chance16(1, 2))) {
|
||||
found = i;
|
||||
@@ -803,9 +802,9 @@ static void Disaster_Helicopter_Init()
|
||||
{
|
||||
if (!Vehicle::CanAllocateItem(3)) return;
|
||||
|
||||
Industry *i, *found = nullptr;
|
||||
Industry *found = nullptr;
|
||||
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
for (Industry *i : Industry::Iterate()) {
|
||||
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CHOPPER_ATTACKS) &&
|
||||
(found == nullptr || Chance16(1, 2))) {
|
||||
found = i;
|
||||
@@ -896,9 +895,7 @@ static void Disaster_CoalMine_Init()
|
||||
uint m;
|
||||
|
||||
for (m = 0; m < 15; m++) {
|
||||
const Industry *i;
|
||||
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
for (const Industry *i : Industry::Iterate()) {
|
||||
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
|
||||
SetDParam(0, i->town->index);
|
||||
AddTileNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE, NT_ACCIDENT, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes
|
||||
@@ -979,8 +976,7 @@ void ReleaseDisastersTargetingIndustry(IndustryID i)
|
||||
{
|
||||
if (!_disaster_vehicle_count) return;
|
||||
|
||||
DisasterVehicle *v;
|
||||
FOR_ALL_DISASTERVEHICLES(v) {
|
||||
for (DisasterVehicle *v : DisasterVehicle::Iterate()) {
|
||||
/* primary disaster vehicles that have chosen target */
|
||||
if (v->subtype == ST_AIRPLANE || v->subtype == ST_HELICOPTER) {
|
||||
/* if it has chosen target, and it is this industry (yes, dest_tile is IndustryID here), set order to "leaving map peacefully" */
|
||||
@@ -997,8 +993,7 @@ void ReleaseDisastersTargetingVehicle(VehicleID vehicle)
|
||||
{
|
||||
if (!_disaster_vehicle_count) return;
|
||||
|
||||
DisasterVehicle *v;
|
||||
FOR_ALL_DISASTERVEHICLES(v) {
|
||||
for (DisasterVehicle *v : DisasterVehicle::Iterate()) {
|
||||
/* primary disaster vehicles that have chosen target */
|
||||
if (v->subtype == ST_SMALL_UFO) {
|
||||
if (v->current_order.GetDestination() != 0 && v->dest_tile == vehicle) {
|
||||
|
Reference in New Issue
Block a user