Changeset - r9234:c3f7730d9a9b
[Not reviewed]
master
0 19 0
rubidium - 16 years ago 2008-05-15 13:39:36
rubidium@openttd.org
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
19 files changed with 126 insertions and 68 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -1389,25 +1389,25 @@ static void CrashAirplane(Vehicle *v)
 
	v->Next()->cargo.Truncate(0);
 
	const Station *st = GetStation(v->u.air.targetairport);
 
	StringID newsitem;
 
	if (st->airport_tile == 0) {
 
		newsitem = STR_PLANE_CRASH_OUT_OF_FUEL;
 
	} else {
 
		SetDParam(1, st->index);
 
		newsitem = STR_A034_PLANE_CRASH_DIE_IN_FIREBALL;
 
	}
 

	
 
	SetDParam(1, st->index);
 
	AddNewsItem(newsitem,
 
		NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
 
		NS_ACCIDENT_VEHICLE,
 
		v->index,
 
		0);
 

	
 
	SndPlayVehicleFx(SND_12_EXPLOSION, v);
 
}
 

	
 
static void MaybeCrashAirplane(Vehicle *v)
 
{
 
	Station *st = GetStation(v->u.air.targetairport);
 

	
 
	/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
 
	uint16 prob = 0x10000 / 1500;
 
@@ -1434,25 +1434,25 @@ static void AircraftEntersTerminal(Vehic
 
	if (v->current_order.IsType(OT_GOTO_DEPOT)) return;
 

	
 
	Station *st = GetStation(v->u.air.targetairport);
 
	v->last_station_visited = v->u.air.targetairport;
 

	
 
	/* Check if station was ever visited before */
 
	if (!(st->had_vehicle_of_type & HVOT_AIRCRAFT)) {
 
		st->had_vehicle_of_type |= HVOT_AIRCRAFT;
 
		SetDParam(0, st->index);
 
		/* show newsitem of celebrating citizens */
 
		AddNewsItem(
 
			STR_A033_CITIZENS_CELEBRATE_FIRST,
 
			NM_THIN, NF_VIEWPORT | NF_VEHICLE, (v->owner == _local_player) ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
 
			(v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
 
			v->index,
 
			0);
 
	}
 

	
 
	v->BeginLoading();
 
}
 

	
 
static void AircraftLandAirplane(Vehicle *v)
 
{
 
	v->UpdateDeltaXY(INVALID_DIR);
 

	
 
	if (!PlayVehicleSound(v, VSE_TOUCHDOWN)) {
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -314,25 +314,25 @@ static CommandCost WagonRemoval(Vehicle 
 
	CommandCost cost = CommandCost();
 

	
 
	while (front->u.rail.cached_total_length > old_total_length) {
 
		/* the train is too long. We will remove cars one by one from the start of the train until it's short enough */
 
		while (v != NULL && RailVehInfo(v->engine_type)->railveh_type != RAILVEH_WAGON) {
 
			/* We move backwards in the train until we find a wagon */
 
			v = GetNextVehicle(v);
 
		}
 

	
 
		if (v == NULL) {
 
			/* We sold all the wagons and the train is still not short enough */
 
			SetDParam(0, front->unitnumber);
 
			AddNewsItem(STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT, NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE, front->index, 0);
 
			AddNewsItem(STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT, NS_ADVICE, front->index, 0);
 
			return cost;
 
		}
 

	
 
		/* We found a wagon we can sell */
 
		Vehicle *temp = v;
 
		v = GetNextVehicle(v);
 
		DoCommand(0, (INVALID_VEHICLE << 16) | temp->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); // remove the wagon from the train
 
		MoveVehicleCargo(front, temp); // move the cargo back on the train
 
		cost.AddCost(DoCommand(0, temp->index, 0, DC_EXEC, CMD_SELL_RAIL_WAGON)); // sell the wagon
 
	}
 
	return cost;
 
}
 
@@ -471,25 +471,25 @@ CommandCost MaybeReplaceVehicle(Vehicle 
 
			if (GetAvailableMoneyForCommand() < cost.GetCost() && IsLocalPlayer()) {
 
				StringID message;
 
				SetDParam(0, v->unitnumber);
 
				switch (v->type) {
 
					case VEH_TRAIN:    message = STR_TRAIN_AUTORENEW_FAILED;       break;
 
					case VEH_ROAD:     message = STR_ROADVEHICLE_AUTORENEW_FAILED; break;
 
					case VEH_SHIP:     message = STR_SHIP_AUTORENEW_FAILED;        break;
 
					case VEH_AIRCRAFT: message = STR_AIRCRAFT_AUTORENEW_FAILED;    break;
 
						// This should never happen
 
					default: NOT_REACHED(); message = 0; break;
 
				}
 

	
 
				AddNewsItem(message, NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
 
				AddNewsItem(message, NS_ADVICE, v->index, 0);
 
			}
 
		}
 
	}
 

	
 
	if (display_costs && IsLocalPlayer() && (flags & DC_EXEC) && CmdSucceeded(cost)) {
 
		ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost());
 
	}
 

	
 
	if (!(flags & DC_EXEC) || CmdFailed(cost)) {
 
		v = backup.Restore(v, p);
 
	}
 

	
src/currency.cpp
Show inline comments
 
@@ -145,25 +145,25 @@ uint GetMaskOfAllowedCurrencies()
 
	return mask;
 
}
 

	
 
/**
 
 * Verify if the currency chosen by the user is about to be converted to Euro
 
 **/
 
void CheckSwitchToEuro()
 
{
 
	if (_currency_specs[_opt.currency].to_euro != CF_NOEURO &&
 
			_currency_specs[_opt.currency].to_euro != CF_ISEURO &&
 
			_cur_year >= _currency_specs[_opt.currency].to_euro) {
 
		_opt.currency = 2; // this is the index of euro above.
 
		AddNewsItem(STR_EURO_INTRODUCE, NM_NORMAL, NF_NONE, NT_ECONOMY, DNC_NONE, 0, 0);
 
		AddNewsItem(STR_EURO_INTRODUCE, NS_ECONOMY, 0, 0);
 
	}
 
}
 

	
 
/**
 
 * Will fill _currency_specs array with
 
 * default values from origin_currency_specs
 
 * Called only from newgrf.cpp and settings.cpp.
 
 * @param preserve_custom will not reset custom currency (the latest one on the list)
 
 *        if ever it is flagged to true. In which case, the total size of the memory to move
 
 *        will be one currency spec less, thus preserving the custom curreny from been
 
 *        overwritten.
 
 **/
src/disaster_cmd.cpp
Show inline comments
 
@@ -225,25 +225,25 @@ static void DisasterTick_Zeppeliner(Vehi
 
		} else if (v->current_order.GetDestination() == 0) {
 
			tile = v->tile;
 

	
 
			if (IsValidTile(tile) &&
 
					IsTileType(tile, MP_STATION) &&
 
					IsAirport(tile) &&
 
					IsHumanPlayer(GetTileOwner(tile))) {
 
				v->current_order.SetDestination(1);
 
				v->age = 0;
 

	
 
				SetDParam(0, GetStationIndex(tile));
 
				AddNewsItem(STR_B000_ZEPPELIN_DISASTER_AT,
 
					NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
 
					NS_ACCIDENT_VEHICLE,
 
					v->index,
 
					0);
 
			}
 
		}
 

	
 
		if (v->y_pos >= ((int)MapSizeY() + 9) * TILE_SIZE - 1) DeleteDisasterVeh(v);
 
		return;
 
	}
 

	
 
	if (v->current_order.GetDestination() > 2) {
 
		if (++v->age <= 13320) return;
 

	
 
@@ -358,25 +358,25 @@ static void DisasterTick_Ufo(Vehicle *v)
 

	
 
		z = v->z_pos;
 
		if (dist <= TILE_SIZE && z > u->z_pos) z--;
 
		SetDisasterVehiclePos(v, gp.x, gp.y, z);
 

	
 
		if (z <= u->z_pos && (u->vehstatus & VS_HIDDEN) == 0) {
 
			v->age++;
 
			if (u->u.road.crashed_ctr == 0) {
 
				u->u.road.crashed_ctr++;
 
				u->vehstatus |= VS_CRASHED;
 

	
 
				AddNewsItem(STR_B001_ROAD_VEHICLE_DESTROYED,
 
					NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
 
					NS_ACCIDENT_VEHICLE,
 
					u->index,
 
					0);
 
			}
 
		}
 

	
 
		/* Destroy? */
 
		if (v->age > 50) {
 
			CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE);
 
			SndPlayVehicleFx(SND_12_EXPLOSION, v);
 
			DeleteDisasterVeh(v);
 
		}
 
	}
 
@@ -433,25 +433,25 @@ static void DisasterTick_Airplane(Vehicl
 
		}
 
	} else if (v->current_order.GetDestination() == 1) {
 
		if (++v->age == 112) {
 
			Industry *i;
 

	
 
			v->current_order.SetDestination(2);
 
			v->age = 0;
 

	
 
			i = GetIndustry(v->dest_tile);
 
			DestructIndustry(i);
 

	
 
			SetDParam(0, i->town->index);
 
			AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy, 0);
 
			AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NS_ACCIDENT_TILE, i->xy, 0);
 
			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
 
		}
 
	} else if (v->current_order.GetDestination() == 0) {
 
		int x, y;
 
		TileIndex tile;
 
		uint ind;
 

	
 
		x = v->x_pos - (15 * TILE_SIZE);
 
		y = v->y_pos;
 

	
 
		if ( (uint)x > MapMaxX() * TILE_SIZE - 1) return;
 

	
 
@@ -506,25 +506,25 @@ static void DisasterTick_Helicopter(Vehi
 
		}
 
	} else if (v->current_order.GetDestination() == 1) {
 
		if (++v->age == 112) {
 
			Industry *i;
 

	
 
			v->current_order.SetDestination(2);
 
			v->age = 0;
 

	
 
			i = GetIndustry(v->dest_tile);
 
			DestructIndustry(i);
 

	
 
			SetDParam(0, i->town->index);
 
			AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy, 0);
 
			AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NS_ACCIDENT_TILE, i->xy, 0);
 
			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
 
		}
 
	} else if (v->current_order.GetDestination() == 0) {
 
		int x, y;
 
		TileIndex tile;
 
		uint ind;
 

	
 
		x = v->x_pos + (15 * TILE_SIZE);
 
		y = v->y_pos;
 

	
 
		if ( (uint)x > MapMaxX() * TILE_SIZE - 1) return;
 

	
 
@@ -591,25 +591,25 @@ static void DisasterTick_Big_Ufo(Vehicle
 
		FOR_ALL_VEHICLES(u) {
 
			if (u->type == VEH_TRAIN || u->type == VEH_ROAD) {
 
				if (Delta(u->x_pos, v->x_pos) + Delta(u->y_pos, v->y_pos) <= 12 * TILE_SIZE) {
 
					u->breakdown_ctr = 5;
 
					u->breakdown_delay = 0xF0;
 
				}
 
			}
 
		}
 

	
 
		t = ClosestTownFromTile(v->dest_tile, (uint)-1);
 
		SetDParam(0, t->index);
 
		AddNewsItem(STR_B004_UFO_LANDS_NEAR,
 
			NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE,
 
			NS_ACCIDENT_TILE,
 
			v->tile,
 
			0);
 

	
 
		u = new DisasterVehicle();
 
		if (u == NULL) {
 
			DeleteDisasterVeh(v);
 
			return;
 
		}
 

	
 
		InitializeDisasterVehicle(u, -6 * TILE_SIZE, v->y_pos, 135, DIR_SW, ST_Big_Ufo_Destroyer);
 
		u->u.disaster.big_ufo_destroyer_target = v->index;
 

	
 
@@ -969,25 +969,25 @@ static void Disaster_Big_Submarine_Init(
 
static void Disaster_CoalMine_Init()
 
{
 
	int index = GB(Random(), 0, 4);
 
	uint m;
 

	
 
	for (m = 0; m < 15; m++) {
 
		const Industry *i;
 

	
 
		FOR_ALL_INDUSTRIES(i) {
 
			if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
 
				SetDParam(0, i->town->index);
 
				AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES,
 
					NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy + TileDiffXY(1, 1), 0);
 
					NS_ACCIDENT_TILE, i->xy + TileDiffXY(1, 1), 0);
 

	
 
				{
 
					TileIndex tile = i->xy;
 
					TileIndexDiff step = TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
 
					uint n;
 

	
 
					for (n = 0; n < 30; n++) {
 
						DisasterClearSquare(tile);
 
						tile = TILE_MASK(tile + step);
 
					}
 
				}
 
				return;
src/economy.cpp
Show inline comments
 
@@ -522,58 +522,58 @@ static void PlayersCheckBankrupt(Player 
 
	}
 

	
 
	p->quarters_of_bankrupcy++;
 

	
 
	owner = p->index;
 

	
 
	switch (p->quarters_of_bankrupcy) {
 
		case 2:
 
			SetDParam(0, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE);
 
			SetDParam(1, STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED);
 
			SetDParam(2, owner);
 
			AddNewsItem(STR_02B6,
 
				NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, owner | NB_BTROUBLE);
 
				NS_COMPANY_TROUBLE, 0, owner | NB_BTROUBLE);
 
			break;
 
		case 3: {
 
			/* XXX - In multiplayer, should we ask other players if it wants to take
 
		          over when it is a human company? -- TrueLight */
 
			if (IsHumanPlayer(owner)) {
 
				SetDParam(0, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE);
 
				SetDParam(1, STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED);
 
				SetDParam(2, owner);
 
				AddNewsItem(STR_02B6,
 
					NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, owner | NB_BTROUBLE);
 
					NS_COMPANY_TROUBLE, 0, owner | NB_BTROUBLE);
 
				break;
 
			}
 

	
 
			/* Check if the company has any value.. if not, declare it bankrupt
 
			 *  right now */
 
			Money val = CalculateCompanyValue(p);
 
			if (val > 0) {
 
				p->bankrupt_value = val;
 
				p->bankrupt_asked = 1 << owner; // Don't ask the owner
 
				p->bankrupt_timeout = 0;
 
				break;
 
			}
 
			/* Else, falltrue to case 4... */
 
		}
 
		case 4: {
 
			/* Close everything the owner has open */
 
			DeletePlayerWindows(owner);
 

	
 
			/* Show bankrupt news */
 
			SetDParam(0, STR_705C_BANKRUPT);
 
			SetDParam(1, STR_705D_HAS_BEEN_CLOSED_DOWN_BY);
 
			SetDParam(2, p->index);
 
			AddNewsItem(STR_02B6, NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, owner | NB_BBANKRUPT);
 
			AddNewsItem(STR_02B6, NS_COMPANY_BANKRUPT, 0, owner | NB_BBANKRUPT);
 

	
 
			if (IsHumanPlayer(owner)) {
 
				/* XXX - If we are in offline mode, leave the player playing. Eg. there
 
				 * is no THE-END, otherwise mark the player as spectator to make sure
 
				 * he/she is no long in control of this company */
 
				if (!_networking) {
 
					p->bankrupt_asked = 0xFF;
 
					p->bankrupt_timeout = 0x456;
 
					break;
 
				}
 

	
 
				ChangeNetworkOwner(owner, PLAYER_SPECTATOR);
 
@@ -765,28 +765,28 @@ static void PlayersPayInterest()
 
		SubtractMoneyFromPlayer(CommandCost(EXPENSES_LOAN_INT, (Money)BigMulSU(p->current_loan, interest, 16)));
 

	
 
		SubtractMoneyFromPlayer(CommandCost(EXPENSES_OTHER, _price.station_value >> 2));
 
	}
 
}
 

	
 
static void HandleEconomyFluctuations()
 
{
 
	if (_opt.diff.economy == 0) return;
 

	
 
	if (--_economy.fluct == 0) {
 
		_economy.fluct = -(int)GB(Random(), 0, 2);
 
		AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NM_NORMAL, NF_NONE, NT_ECONOMY, DNC_NONE, 0, 0);
 
		AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NS_ECONOMY, 0, 0);
 
	} else if (_economy.fluct == -12) {
 
		_economy.fluct = GB(Random(), 0, 8) + 312;
 
		AddNewsItem(STR_7074_RECESSION_OVER_UPTURN_IN, NM_NORMAL, NF_NONE, NT_ECONOMY, DNC_NONE, 0, 0);
 
		AddNewsItem(STR_7074_RECESSION_OVER_UPTURN_IN, NS_ECONOMY, 0, 0);
 
	}
 
}
 

	
 
static byte _price_category[NUM_PRICES] = {
 
	0, 2, 2, 2, 2, 2, 2, 2,
 
	2, 2, 2, 2, 2, 2, 2, 2,
 
	2, 2, 2, 2, 2, 2, 2, 2,
 
	2, 2, 2, 2, 2, 2, 2, 2,
 
	2, 2, 2, 2, 2, 2, 2, 2,
 
	2, 2, 1, 1, 1, 1, 1, 1,
 
	2,
 
};
 
@@ -1108,32 +1108,32 @@ static void SubsidyMonthlyHandler()
 
	Subsidy *s;
 
	Pair pair;
 
	Station *st;
 
	uint n;
 
	FoundRoute fr;
 
	bool modified = false;
 

	
 
	for (s = _subsidies; s != endof(_subsidies); s++) {
 
		if (s->cargo_type == CT_INVALID) continue;
 

	
 
		if (s->age == 12-1) {
 
			pair = SetupSubsidyDecodeParam(s, 1);
 
			AddNewsItem(STR_202E_OFFER_OF_SUBSIDY_EXPIRED, NM_NORMAL, NF_TILE | NF_TILE2, NT_SUBSIDIES, DNC_NONE, pair.a, pair.b);
 
			AddNewsItem(STR_202E_OFFER_OF_SUBSIDY_EXPIRED, NS_SUBSIDIES, pair.a, pair.b);
 
			s->cargo_type = CT_INVALID;
 
			modified = true;
 
		} else if (s->age == 2*12-1) {
 
			st = GetStation(s->to);
 
			if (st->owner == _local_player) {
 
				pair = SetupSubsidyDecodeParam(s, 1);
 
				AddNewsItem(STR_202F_SUBSIDY_WITHDRAWN_SERVICE, NM_NORMAL, NF_TILE | NF_TILE2, NT_SUBSIDIES, DNC_NONE, pair.a, pair.b);
 
				AddNewsItem(STR_202F_SUBSIDY_WITHDRAWN_SERVICE, NS_SUBSIDIES, pair.a, pair.b);
 
			}
 
			s->cargo_type = CT_INVALID;
 
			modified = true;
 
		} else {
 
			s->age++;
 
		}
 
	}
 

	
 
	/* 25% chance to go on */
 
	if (Chance16(1,4)) {
 
		/*  Find a free slot*/
 
		s = _subsidies;
 
@@ -1154,25 +1154,25 @@ static void SubsidyMonthlyHandler()
 
			FindSubsidyCargoRoute(&fr);
 
			if (fr.distance <= 70) {
 
				s->cargo_type = fr.cargo;
 
				s->from = ((Industry*)fr.from)->index;
 
				{
 
					const CargoSpec *cs = GetCargo(fr.cargo);
 
					s->to = (cs->town_effect == TE_GOODS || cs->town_effect == TE_FOOD) ? ((Town*)fr.to)->index : ((Industry*)fr.to)->index;
 
				}
 
	add_subsidy:
 
				if (!CheckSubsidyDuplicate(s)) {
 
					s->age = 0;
 
					pair = SetupSubsidyDecodeParam(s, 0);
 
					AddNewsItem(STR_2030_SERVICE_SUBSIDY_OFFERED, NM_NORMAL, NF_TILE | NF_TILE2, NT_SUBSIDIES, DNC_NONE, pair.a, pair.b);
 
					AddNewsItem(STR_2030_SERVICE_SUBSIDY_OFFERED, NS_SUBSIDIES, pair.a, pair.b);
 
					modified = true;
 
					break;
 
				}
 
			}
 
		} while (n--);
 
	}
 
no_add:;
 
	if (modified)
 
		InvalidateWindow(WC_SUBSIDIES_LIST, 0);
 
}
 

	
 
static const SaveLoad _subsidies_desc[] = {
 
@@ -1371,25 +1371,25 @@ static bool CheckSubsidised(Station *fro
 
			/* Found a subsidy, change the values to indicate that it's in use */
 
			s->age = 12;
 
			s->from = from->index;
 
			s->to = to->index;
 

	
 
			/* Add a news item */
 
			pair = SetupSubsidyDecodeParam(s, 0);
 
			InjectDParam(1);
 

	
 
			SetDParam(0, _current_player);
 
			AddNewsItem(
 
				STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier,
 
				NM_NORMAL, NF_TILE | NF_TILE2, NT_SUBSIDIES, DNC_NONE,
 
				NS_SUBSIDIES,
 
				pair.a, pair.b
 
			);
 

	
 
			InvalidateWindow(WC_SUBSIDIES_LIST, 0);
 
			return true;
 
		}
 
	}
 
	return false;
 
}
 

	
 
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source, StationID dest, TileIndex source_tile, byte days_in_transit)
 
{
 
@@ -1813,25 +1813,25 @@ void PlayersMonthlyLoop()
 

	
 
static void DoAcquireCompany(Player *p)
 
{
 
	Player *owner;
 
	int i;
 
	Money value;
 

	
 
	SetDParam(0, STR_7059_TRANSPORT_COMPANY_MERGER);
 
	SetDParam(1, p->bankrupt_value == 0 ? STR_707F_HAS_BEEN_TAKEN_OVER_BY : STR_705A_HAS_BEEN_SOLD_TO_FOR);
 
	SetDParam(2, p->index);
 
	SetDParam(3, _current_player);
 
	SetDParam(4, p->bankrupt_value);
 
	AddNewsItem(STR_02B6, NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, _current_player | NB_BMERGER);
 
	AddNewsItem(STR_02B6, NS_COMPANY_MERGER, 0, _current_player | NB_BMERGER);
 

	
 
	/* original code does this a little bit differently */
 
	PlayerID pi = p->index;
 
	ChangeNetworkOwner(pi, _current_player);
 
	ChangeOwnershipOfPlayerItems(pi, _current_player);
 

	
 
	if (p->bankrupt_value == 0) {
 
		owner = GetPlayer(_current_player);
 
		owner->current_loan += p->current_loan;
 
	}
 

	
 
	value = CalculateCompanyValue(p) >> 2;
src/engine.cpp
Show inline comments
 
@@ -459,25 +459,25 @@ static void NewVehicleAvailable(Engine *
 
		FOR_ALL_PLAYERS(p) {
 
			if (p->is_active) SetBit(p->avail_railtypes, railtype);
 
		}
 
	} else if (e->type == VEH_ROAD) {
 
		/* maybe make another road type available */
 
		FOR_ALL_PLAYERS(p) {
 
			if (p->is_active) SetBit(p->avail_roadtypes, HasBit(e->info.misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
 
		}
 
	}
 

	
 
	SetDParam(0, GetEngineCategoryName(index));
 
	SetDParam(1, index);
 
	AddNewsItem(STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE, NM_CALLBACK, NF_NONE, NT_NEW_VEHICLES, DNC_VEHICLEAVAIL, index, 0);
 
	AddNewsItem(STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE, NS_NEW_VEHICLES, index, 0);
 
}
 

	
 
void EnginesMonthlyLoop()
 
{
 
	if (_cur_year < YEAR_ENGINE_AGING_STOPS) {
 
		Engine *e;
 
		FOR_ALL_ENGINES(e) {
 
			/* Age the vehicle */
 
			if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) {
 
				e->age++;
 
				CalcEngineReliability(e);
 
			}
src/industry_cmd.cpp
Show inline comments
 
@@ -1642,25 +1642,25 @@ CommandCost CmdBuildIndustry(TileIndex t
 
					 */
 
					tile = RandomTile();
 
					const Industry *ind = CreateNewIndustryHelper(tile, p1, flags, indspec, RandomRange(indspec->num_table), p2);
 
					if (ind != NULL) {
 
						SetDParam(0, indspec->name);
 
						if (indspec->new_industry_text > STR_LAST_STRINGID) {
 
							SetDParam(1, STR_TOWN);
 
							SetDParam(2, ind->town->index);
 
						} else {
 
							SetDParam(1, ind->town->index);
 
						}
 
						AddNewsItem(indspec->new_industry_text,
 
								NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, DNC_NONE, ind->xy, 0);
 
								NS_OPENCLOSE, ind->xy, 0);
 
						break;
 
					}
 
				}
 
			}
 
		}
 
	} else {
 
		int count = indspec->num_table;
 
		const IndustryTileTable * const *itt = indspec->table;
 
		int num = Clamp(GB(p1, 16, 16), 0, count - 1);
 

	
 
		_error_message = STR_0239_SITE_UNSUITABLE;
 
		do {
 
@@ -1861,25 +1861,25 @@ static void MaybeNewIndustry(void)
 
		if (ind != NULL) break;
 
		if (--num == 0) return;
 
	}
 

	
 
	SetDParam(0, ind_spc->name);
 
	if (ind_spc->new_industry_text > STR_LAST_STRINGID) {
 
		SetDParam(1, STR_TOWN);
 
		SetDParam(2, ind->town->index);
 
	} else {
 
		SetDParam(1, ind->town->index);
 
	}
 
	AddNewsItem(ind_spc->new_industry_text,
 
		NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, DNC_NONE, ind->xy, 0);
 
		NS_OPENCLOSE, ind->xy, 0);
 
}
 

	
 
/**
 
 * Protects an industry from closure if the appropriate flags and conditions are met
 
 * INDUSTRYBEH_CANCLOSE_LASTINSTANCE must be set (which, by default, it is not) and the
 
 * count of industries of this type must one (or lower) in order to be protected
 
 * against closure.
 
 * @param type IndustryType been queried
 
 * @result true if protection is on, false otherwise (except for oil wells)
 
 */
 
static bool CheckIndustryCloseDownProtection(IndustryType type)
 
{
 
@@ -1993,38 +1993,38 @@ int WhoCanServiceIndustry(Industry* ind)
 
	return result;
 
}
 

	
 
/**
 
* Report news that industry production has changed significantly
 
*
 
* @param ind: Industry with changed production
 
* @param type: Cargo type that has changed
 
* @param percent: Percentage of change (>0 means increase, <0 means decrease)
 
*/
 
static void ReportNewsProductionChangeIndustry(Industry *ind, CargoID type, int percent)
 
{
 
	NewsType nt;
 
	NewsSubtype ns;
 

	
 
	switch (WhoCanServiceIndustry(ind)) {
 
		case 0: nt = NT_INDUSTRY_NOBODY; break;
 
		case 1: nt = NT_INDUSTRY_OTHER;  break;
 
		case 2: nt = NT_INDUSTRY_PLAYER; break;
 
		case 0: ns = NS_INDUSTRY_NOBODY; break;
 
		case 1: ns = NS_INDUSTRY_OTHER;  break;
 
		case 2: ns = NS_INDUSTRY_PLAYER; break;
 
		default: NOT_REACHED(); break;
 
	}
 
	SetDParam(2, abs(percent));
 
	SetDParam(0, GetCargo(type)->name);
 
	SetDParam(1, ind->index);
 
	AddNewsItem(
 
		percent >= 0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN,
 
		NM_THIN, NF_VIEWPORT | NF_TILE, nt, DNC_NONE,
 
		ns,
 
		ind->xy + TileDiffXY(1, 1), 0
 
	);
 
}
 

	
 
enum {
 
	PERCENT_TRANSPORTED_60 = 153,
 
	PERCENT_TRANSPORTED_80 = 204,
 
};
 

	
 
/** Change industry production or do closure
 
 * @param i Industry for which changes are performed
 
 * @param monthly true if it's the monthly call, false if it's the random call
 
@@ -2174,51 +2174,51 @@ static void ChangeIndustryProduction(Ind
 
		} else {
 
			i->prod_level = ClampU(i->prod_level + increment, PRODLEVEL_MINIMUM, PRODLEVEL_MAXIMUM);
 
		}
 
	}
 

	
 
	/* Close if needed and allowed */
 
	if (closeit && !CheckIndustryCloseDownProtection(i->type)) {
 
		i->prod_level = PRODLEVEL_CLOSURE;
 
		str = indspec->closure_text;
 
	}
 

	
 
	if (!suppress_message && str != STR_NULL) {
 
		NewsType nt;
 
		NewsSubtype ns;
 
		/* Compute news category */
 
		if (closeit) {
 
			nt = NT_OPENCLOSE;
 
			ns = NS_OPENCLOSE;
 
		} else {
 
			switch (WhoCanServiceIndustry(i)) {
 
				case 0: nt = NT_INDUSTRY_NOBODY; break;
 
				case 1: nt = NT_INDUSTRY_OTHER;  break;
 
				case 2: nt = NT_INDUSTRY_PLAYER; break;
 
				case 0: ns = NS_INDUSTRY_NOBODY; break;
 
				case 1: ns = NS_INDUSTRY_OTHER;  break;
 
				case 2: ns = NS_INDUSTRY_PLAYER; break;
 
				default: NOT_REACHED(); break;
 
			}
 
		}
 
		/* Set parameters of news string */
 
		if (str > STR_LAST_STRINGID) {
 
			SetDParam(0, STR_TOWN);
 
			SetDParam(1, i->town->index);
 
			SetDParam(2, indspec->name);
 
		} else if (closeit) {
 
			SetDParam(0, STR_INDUSTRY_FORMAT);
 
			SetDParam(1, i->town->index);
 
			SetDParam(2, indspec->name);
 
		} else {
 
			SetDParam(0, i->index);
 
		}
 
		/* and report the news to the user */
 
		AddNewsItem(str,
 
			NM_THIN, NF_VIEWPORT | NF_TILE, nt, DNC_NONE,
 
			ns,
 
			i->xy + TileDiffXY(1, 1), 0);
 
	}
 
}
 

	
 
void IndustryMonthlyLoop()
 
{
 
	Industry *i;
 
	PlayerID old_player = _current_player;
 
	_current_player = OWNER_NONE;
 

	
 
	FOR_ALL_INDUSTRIES(i) {
 
		UpdateIndustryStatistics(i);
src/news_func.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file news_func.h Functions related to news. */
 

	
 
#ifndef NEWS_FUNC_H
 
#define NEWS_FUNC_H
 

	
 
#include "news_type.h"
 
#include "vehicle_type.h"
 

	
 
void AddNewsItem(StringID string, NewsMode mode, NewsFlag flag, NewsType type, NewsCallback callback, uint data_a, uint data_b);
 
void AddNewsItem(StringID string, NewsSubtype subtype, uint data_a, uint data_b);
 
void NewsLoop();
 
void DrawNewsBorder(const Window *w);
 
void InitNewsItemStructs();
 

	
 
extern NewsItem _statusbar_news_item;
 
extern bool _news_ticker_sound;
 

	
 
extern NewsTypeData _news_type_data[NT_END];
 

	
 
/**
 
 * Delete a news item type about a vehicle
 
 * if the news item type is INVALID_STRING_ID all news about the vehicle get
src/news_gui.cpp
Show inline comments
 
@@ -74,24 +74,59 @@ static NewsID _forced_news = INVALID_NEW
 

	
 
static uint _total_news = 0; ///< Number of news items in FIFO queue @see _news_items
 

	
 
void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni);
 
void DrawNewsBankrupcy(Window *w, const NewsItem *ni);
 
static void MoveToNextItem();
 

	
 
static DrawNewsCallbackProc * const _draw_news_callback[] = {
 
	DrawNewsNewVehicleAvail,  ///< DNC_VEHICLEAVAIL
 
	DrawNewsBankrupcy,        ///< DNC_BANKRUPCY
 
};
 

	
 
/**
 
 * Data common to all news items of a given subtype (structure)
 
 */
 
struct NewsSubtypeData {
 
	NewsType type;         ///< News category @see NewsType
 
	NewsMode display_mode; ///< Display mode value @see NewsMode
 
	NewsFlag flags;        ///< Initial NewsFlags bits @see NewsFlag
 
	NewsCallback callback; ///< Call-back function
 
};
 

	
 
/**
 
 * Data common to all news items of a given subtype (actual data)
 
 */
 
static const struct NewsSubtypeData _news_subtype_data[NS_END] = {
 
	/* type,             display_mode, flags,                  callback */
 
	{ NT_ARRIVAL_PLAYER,  NM_THIN,     NF_VIEWPORT|NF_VEHICLE, DNC_NONE         }, ///< NS_ARRIVAL_PLAYER
 
	{ NT_ARRIVAL_OTHER,   NM_THIN,     NF_VIEWPORT|NF_VEHICLE, DNC_NONE         }, ///< NS_ARRIVAL_OTHER
 
	{ NT_ACCIDENT,        NM_THIN,     NF_VIEWPORT|NF_TILE,    DNC_NONE         }, ///< NS_ACCIDENT_TILE
 
	{ NT_ACCIDENT,        NM_THIN,     NF_VIEWPORT|NF_VEHICLE, DNC_NONE         }, ///< NS_ACCIDENT_VEHICLE
 
	{ NT_COMPANY_INFO,    NM_CALLBACK, NF_NONE,                DNC_BANKRUPCY    }, ///< NS_COMPANY_TROUBLE
 
	{ NT_COMPANY_INFO,    NM_CALLBACK, NF_NONE,                DNC_BANKRUPCY    }, ///< NS_COMPANY_MERGER
 
	{ NT_COMPANY_INFO,    NM_CALLBACK, NF_NONE,                DNC_BANKRUPCY    }, ///< NS_COMPANY_BANKRUPT
 
	{ NT_COMPANY_INFO,    NM_CALLBACK, NF_TILE,                DNC_BANKRUPCY    }, ///< NS_COMPANY_NEW
 
	{ NT_OPENCLOSE,       NM_THIN,     NF_VIEWPORT|NF_TILE,    DNC_NONE         }, ///< NS_OPENCLOSE
 
	{ NT_ECONOMY,         NM_NORMAL,   NF_NONE,                DNC_NONE         }, ///< NS_ECONOMY
 
	{ NT_INDUSTRY_PLAYER, NM_THIN,     NF_VIEWPORT|NF_TILE,    DNC_NONE         }, ///< NS_INDUSTRY_PLAYER
 
	{ NT_INDUSTRY_OTHER,  NM_THIN,     NF_VIEWPORT|NF_TILE,    DNC_NONE         }, ///< NS_INDUSTRY_OTHER
 
	{ NT_INDUSTRY_NOBODY, NM_THIN,     NF_VIEWPORT|NF_TILE,    DNC_NONE         }, ///< NS_INDUSTRY_NOBODY
 
	{ NT_ADVICE,          NM_SMALL,    NF_VIEWPORT|NF_VEHICLE, DNC_NONE         }, ///< NS_ADVICE
 
	{ NT_NEW_VEHICLES,    NM_CALLBACK, NF_NONE,                DNC_VEHICLEAVAIL }, ///< NS_NEW_VEHICLES
 
	{ NT_ACCEPTANCE,      NM_SMALL,    NF_VIEWPORT|NF_TILE,    DNC_NONE         }, ///< NS_ACCEPTANCE
 
	{ NT_SUBSIDIES,       NM_NORMAL,   NF_TILE|NF_TILE2,       DNC_NONE         }, ///< NS_SUBSIDIES
 
	{ NT_GENERAL,         NM_NORMAL,   NF_TILE,                DNC_NONE         }, ///< NS_GENERAL
 
};
 

	
 
/** Initialize the news-items data structures */
 
void InitNewsItemStructs()
 
{
 
	free(_news_items);
 
	_max_news_items = max(ScaleByMapSize(30), 30U);
 
	_news_items = CallocT<NewsItem>(_max_news_items);
 
	_current_news = INVALID_NEWS;
 
	_oldest_news = 0;
 
	_latest_news = INVALID_NEWS;
 
	_forced_news = INVALID_NEWS;
 
	_total_news = 0;
 
}
 
@@ -115,61 +150,62 @@ void DrawNewsBorder(const Window *w)
 

	
 
static void NewsWindowProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
		case WE_CREATE: { // If chatbar is open at creation time, we need to go above it
 
			const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0);
 
			WP(w, news_d).chat_height = (w1 != NULL) ? w1->height : 0;
 
			break;
 
		}
 

	
 
		case WE_PAINT: {
 
			const NewsItem *ni = WP(w, news_d).ni;
 
			const NewsMode display_mode = _news_subtype_data[ni->subtype].display_mode;
 

	
 
			switch (ni->display_mode) {
 
			switch (display_mode) {
 
				case NM_NORMAL:
 
				case NM_THIN: {
 
					DrawNewsBorder(w);
 

	
 
					DrawString(2, 1, STR_00C6, TC_FROMSTRING);
 

	
 
					SetDParam(0, ni->date);
 
					DrawStringRightAligned(428, 1, STR_01FF, TC_FROMSTRING);
 

	
 
					if (!(ni->flags & NF_VIEWPORT)) {
 
						CopyInDParam(0, ni->params, lengthof(ni->params));
 
						DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56,
 
						DrawStringMultiCenter(215, display_mode == NM_NORMAL ? 76 : 56,
 
							ni->string_id, w->width - 4);
 
					} else {
 
						/* Back up transparency options to draw news view */
 
						TransparencyOptionBits to_backup = _transparency_opt;
 
						_transparency_opt = 0;
 
						DrawWindowViewport(w);
 
						_transparency_opt = to_backup;
 

	
 
						/* Shade the viewport into gray, or color*/
 
						ViewPort *vp = w->viewport;
 
						GfxFillRect(vp->left - w->left, vp->top - w->top,
 
							vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1,
 
							(ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY) | (1 << USE_COLORTABLE)
 
						);
 

	
 
						CopyInDParam(0, ni->params, lengthof(ni->params));
 
						DrawStringMultiCenter(w->width / 2, 20, ni->string_id, w->width - 4);
 
					}
 
					break;
 
				}
 

	
 
				case NM_CALLBACK:
 
					_draw_news_callback[ni->callback](w, ni);
 
					_draw_news_callback[_news_subtype_data[ni->subtype].callback](w, ni);
 
					break;
 

	
 
				default:
 
					DrawWindowWidgets(w);
 
					if (!(ni->flags & NF_VIEWPORT)) {
 
						CopyInDParam(0, ni->params, lengthof(ni->params));
 
						DrawStringMultiCenter(140, 38, ni->string_id, 276);
 
					} else {
 
						DrawWindowViewport(w);
 
						CopyInDParam(0, ni->params, lengthof(ni->params));
 
						DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, w->width - 4);
 
					}
 
@@ -274,25 +310,25 @@ static inline NewsID DecreaseIndex(NewsI
 
 *  - For DNC_TRAINAVAIL, DNC_ROADAVAIL, DNC_SHIPAVAIL, DNC_AIRCRAFTAVAIL messages: StringID is
 
 *    the index of the engine that is shown
 
 *
 
 *  - For DNC_BANKRUPCY: bytes 0-3 of StringID contains the player that is in trouble,
 
 *    and 4-7 contains what kind of bankrupcy message is shown.
 
 *    @see NewsBankrupcy
 
 *
 
 * @see NewsMode
 
 * @see NewsFlag
 
 * @see NewsType
 
 * @see NewsCallback
 
 */
 
void AddNewsItem(StringID string, NewsMode display_mode, NewsFlag flags, NewsType type, NewsCallback callback, uint data_a, uint data_b)
 
void AddNewsItem(StringID string, NewsSubtype subtype, uint data_a, uint data_b)
 
{
 
	if (_game_mode == GM_MENU) return;
 

	
 
	/* check the rare case that the oldest (to be overwritten) news item is open */
 
	if (_total_news == _max_news_items && (_oldest_news == _current_news || _oldest_news == _forced_news)) {
 
		MoveToNextItem();
 
	}
 

	
 
	if (_total_news < _max_news_items) _total_news++;
 

	
 
	/* Increase _latest_news. If we have no news yet, use _oldest news as an
 
	 * index. We cannot use 0 as _oldest_news can jump around due to
 
@@ -305,32 +341,30 @@ void AddNewsItem(StringID string, NewsMo
 
		assert(_total_news == _max_news_items);
 
		_oldest_news = IncreaseIndex(_oldest_news);
 
	}
 

	
 
	/*DEBUG(misc, 0, "+cur %3d, old %2d, lat %3d, for %3d, tot %2d",
 
	  _current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/
 

	
 
	/* Add news to _latest_news */
 
	NewsItem *ni = &_news_items[_latest_news];
 
	memset(ni, 0, sizeof(*ni));
 

	
 
	ni->string_id = string;
 
	ni->display_mode = display_mode;
 
	ni->flags = flags;
 
	ni->subtype = subtype;
 
	ni->flags = _news_subtype_data[subtype].flags;
 

	
 
	/* show this news message in color? */
 
	if (_cur_year >= _patches.colored_news_year) ni->flags |= NF_INCOLOR;
 

	
 
	ni->type = type;
 
	ni->callback = callback;
 
	ni->data_a = data_a;
 
	ni->data_b = data_b;
 
	ni->date = _date;
 
	CopyOutDParam(ni->params, 0, lengthof(ni->params));
 

	
 
	Window *w = FindWindowById(WC_MESSAGE_HISTORY, 0);
 
	if (w == NULL) return;
 
	w->SetDirty();
 
	w->vscroll.count = _total_news;
 
}
 

	
 

	
 
@@ -398,30 +432,30 @@ static WindowDesc _news_type0_desc = {
 
	WDF_DEF_WIDGET,
 
	_news_type0_widgets,
 
	NewsWindowProc
 
};
 

	
 

	
 
/** Open up an own newspaper window for the news item */
 
static void ShowNewspaper(NewsItem *ni)
 
{
 
	ni->flags &= ~NF_FORCE_BIG;
 
	ni->duration = 555;
 

	
 
	SoundFx sound = _news_type_data[ni->type].sound;
 
	SoundFx sound = _news_type_data[_news_subtype_data[ni->subtype].type].sound;
 
	if (sound != 0) SndPlayFx(sound);
 

	
 
	int top = _screen.height;
 
	Window *w;
 
	switch (ni->display_mode) {
 
	switch (_news_subtype_data[ni->subtype].display_mode) {
 
		case NM_NORMAL:
 
		case NM_CALLBACK:
 
			_news_type13_desc.top = top;
 
			w = new Window(&_news_type13_desc);
 
			if (ni->flags & NF_VIEWPORT) {
 
				InitializeWindowViewport(w, 2, 58, 426, 110,
 
					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
 
			}
 
			break;
 

	
 
		case NM_THIN:
 
			_news_type2_desc.top = top;
 
@@ -484,29 +518,30 @@ static bool ReadyForNextItem()
 
}
 

	
 
/** Move to the next news item */
 
static void MoveToNextItem()
 
{
 
	DeleteWindowById(WC_NEWS_WINDOW, 0);
 
	_forced_news = INVALID_NEWS;
 

	
 
	/* if we're not at the last item, then move on */
 
	if (_current_news != _latest_news) {
 
		_current_news = (_current_news == INVALID_NEWS) ? _oldest_news : IncreaseIndex(_current_news);
 
		NewsItem *ni = &_news_items[_current_news];
 
		const NewsType type = _news_subtype_data[ni->subtype].type;
 

	
 
		/* check the date, don't show too old items */
 
		if (_date - _news_type_data[ni->type].age > ni->date) return;
 
		if (_date - _news_type_data[type].age > ni->date) return;
 

	
 
		switch (_news_type_data[ni->type].display) {
 
		switch (_news_type_data[type].display) {
 
			default: NOT_REACHED();
 
			case ND_OFF: { // Off - show nothing only a small reminder in the status bar
 
				Window *w = FindWindowById(WC_STATUS_BAR, 0);
 

	
 
				if (w != NULL) {
 
					WP(w, def_d).data_2 = 91;
 
					w->SetDirty();
 
				}
 
				break;
 
			}
 

	
 
			case ND_SUMMARY: // Summary - show ticker, but if forced big, cascade to full
src/news_type.h
Show inline comments
 
@@ -23,24 +23,49 @@ enum NewsType {
 
	NT_INDUSTRY_PLAYER, ///< Production changes of industry serviced by local player
 
	NT_INDUSTRY_OTHER,  ///< Production changes of industry serviced by competitor(s)
 
	NT_INDUSTRY_NOBODY, ///< Other industry production changes
 
	NT_ADVICE,          ///< Bits of news about vehicles of the player
 
	NT_NEW_VEHICLES,    ///< New vehicle has become available
 
	NT_ACCEPTANCE,      ///< A type of cargo is (no longer) accepted
 
	NT_SUBSIDIES,       ///< News about subsidies (announcements, expirations, acceptance)
 
	NT_GENERAL,         ///< General news (from towns)
 
	NT_END,             ///< end-of-array marker
 
};
 

	
 
/**
 
 * News subtypes.
 
 */
 
enum NewsSubtype {
 
	NS_ARRIVAL_PLAYER,   ///< NT_ARRIVAL_PLAYER
 
	NS_ARRIVAL_OTHER,    ///< NT_ARRIVAL_OTHER
 
	NS_ACCIDENT_TILE,    ///< NT_ACCIDENT (tile)
 
	NS_ACCIDENT_VEHICLE, ///< NT_ACCIDENT (vehicle)
 
	NS_COMPANY_TROUBLE,  ///< NT_COMPANY_INFO (trouble)
 
	NS_COMPANY_MERGER,   ///< NT_COMPANY_INFO (merger)
 
	NS_COMPANY_BANKRUPT, ///< NT_COMPANY_INFO (bankrupt)
 
	NS_COMPANY_NEW,      ///< NT_COMPANY_INFO (new company)
 
	NS_OPENCLOSE,        ///< NT_OPENCLOSE
 
	NS_ECONOMY,          ///< NT_ECONOMY
 
	NS_INDUSTRY_PLAYER,  ///< NT_INDUSTRY_PLAYER
 
	NS_INDUSTRY_OTHER,   ///< NT_INDUSTRY_OTHER
 
	NS_INDUSTRY_NOBODY,  ///< NT_INDUSTRY_NOBODY
 
	NS_ADVICE,           ///< NT_ADVICE
 
	NS_NEW_VEHICLES,     ///< NT_NEW_VEHICLES
 
	NS_ACCEPTANCE,       ///< NT_ACCEPTANCE
 
	NS_SUBSIDIES,        ///< NT_SUBSIDIES
 
	NS_GENERAL,          ///< NT_GENERAL
 
	NS_END,              ///< end-of-array marker
 
};
 

	
 
/**
 
 * News mode.
 
 */
 
enum NewsMode {
 
	NM_SMALL    = 0, ///< Show only a small popup informing us about vehicle age for example
 
	NM_NORMAL   = 1, ///< Show a simple news message (height 170 pixels)
 
	NM_THIN     = 2, ///< Show a simple news message (height 130 pixels)
 
	NM_CALLBACK = 3, ///< Do some special processing before displaying news message. Which callback to call is in NewsCallback
 
};
 

	
 
/**
 
 * Various OR-able news-item flags.
 
 * note: NF_INCOLOR is set automatically if needed
 
@@ -91,27 +116,25 @@ enum NewsDisplay {
 
 */
 
struct NewsTypeData {
 
	const char *const name; ///< Name
 
	const byte age;         ///< Maximum age of news items (in days)
 
	const SoundFx sound;    ///< Sound
 
	NewsDisplay display;    ///< Display mode (off, summary, full)
 
};
 

	
 
struct NewsItem {
 
	StringID string_id;    ///< Message text
 
	uint16 duration;       ///< Remaining time for showing this news message
 
	Date date;             ///< Date of the news
 
	NewsSubtype subtype;   ///< News subtype @see NewsSubtype
 
	NewsFlag flags;        ///< NewsFlags bits @see NewsFlag
 
	NewsMode display_mode; ///< Display mode value @see NewsMode
 
	NewsType type;         ///< News category @see NewsType
 
	NewsCallback callback; ///< Call-back function
 

	
 
	uint data_a;           ///< Custom data 1 (usually tile or vehicle)
 
	uint data_b;           ///< Custom data 2
 

	
 
	uint64 params[10];
 
};
 

	
 
typedef bool ValidationProc(uint data_a, uint data_b);
 
typedef void DrawNewsCallbackProc(Window *w, const NewsItem *ni);
 

	
 
#endif /* NEWS_TYPE_H */
src/order_cmd.cpp
Show inline comments
 
@@ -1435,25 +1435,25 @@ void CheckOrders(const Vehicle* v)
 
		/* Do we only have 1 station in our order list? */
 
		if (n_st < 2 && problem_type == -1) problem_type = 0;
 

	
 
		/* We don't have a problem */
 
		if (problem_type < 0) return;
 

	
 
		message = STR_TRAIN_HAS_TOO_FEW_ORDERS + (v->type << 2) + problem_type;
 
		//DEBUG(misc, 3, "Triggered News Item for vehicle %d", v->index);
 

	
 
		SetDParam(0, v->unitnumber);
 
		AddNewsItem(
 
			message,
 
			NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE,
 
			NS_ADVICE,
 
			v->index,
 
			0
 
		);
 
	}
 
}
 

	
 
/**
 
 * Removes an order from all vehicles. Triggers when, say, a station is removed.
 
 * @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]).
 
 * @param destination The destination. Can be a StationID, DepotID or WaypointID.
 
 */
 
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
src/players.cpp
Show inline comments
 
@@ -351,25 +351,25 @@ verify_name:;
 

	
 
set_name:;
 
		p->name_1 = str;
 
		p->name_2 = strp;
 

	
 
		MarkWholeScreenDirty();
 

	
 
		if (!IsHumanPlayer(p->index)) {
 
			SetDParam(0, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED);
 
			SetDParam(1, STR_705F_STARTS_CONSTRUCTION_NEAR);
 
			SetDParam(2, p->index);
 
			SetDParam(3, t->index);
 
			AddNewsItem(STR_02B6, NM_CALLBACK, NF_TILE, NT_COMPANY_INFO, DNC_BANKRUPCY, p->last_build_coordinate, p->index | NB_BNEWCOMPANY);
 
			AddNewsItem(STR_02B6, NS_COMPANY_NEW, p->last_build_coordinate, p->index | NB_BNEWCOMPANY);
 
		}
 
		return;
 
	}
 
bad_town_name:;
 

	
 
	if (p->president_name_1 == SPECSTR_PRESIDENT_NAME) {
 
		str = SPECSTR_ANDCO_NAME;
 
		strp = p->president_name_2;
 
		goto set_name;
 
	} else {
 
		str = SPECSTR_ANDCO_NAME;
 
		strp = Random();
 
@@ -930,25 +930,25 @@ CommandCost CmdPlayerCtrl(TileIndex tile
 

	
 
		p = GetPlayer((PlayerID)p2);
 

	
 
		/* Only allow removal of HUMAN companies */
 
		if (IsHumanPlayer(p->index)) {
 
			/* Delete any open window of the company */
 
			DeletePlayerWindows(p->index);
 

	
 
			/* Show the bankrupt news */
 
			SetDParam(0, STR_705C_BANKRUPT);
 
			SetDParam(1, STR_705D_HAS_BEEN_CLOSED_DOWN_BY);
 
			SetDParam(2, p->index);
 
			AddNewsItem(STR_02B6, NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, p->index | NB_BBANKRUPT);
 
			AddNewsItem(STR_02B6, NS_COMPANY_BANKRUPT, 0, p->index | NB_BBANKRUPT);
 

	
 
			/* Remove the company */
 
			ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
 
			p->is_active = false;
 
		}
 
	} break;
 

	
 
	case 3: { /* Merge a company (#1) into another company (#2), elimination company #1 */
 
		PlayerID pid_old = (PlayerID)GB(p2,  0, 16);
 
		PlayerID pid_new = (PlayerID)GB(p2, 16, 16);
 

	
 
		if (!IsValidPlayer(pid_old) || !IsValidPlayer(pid_new)) return CMD_ERROR;
src/roadveh_cmd.cpp
Show inline comments
 
@@ -655,25 +655,25 @@ static void RoadVehCrash(Vehicle *v)
 

	
 
		MarkSingleVehicleDirty(u);
 
	}
 

	
 
	ClearSlot(v);
 

	
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 

	
 
	SetDParam(0, pass);
 
	AddNewsItem(
 
		(pass == 1) ?
 
			STR_9031_ROAD_VEHICLE_CRASH_DRIVER : STR_9032_ROAD_VEHICLE_CRASH_DIE,
 
		NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
 
		NS_ACCIDENT_VEHICLE,
 
		v->index,
 
		0
 
	);
 

	
 
	ModifyStationRatingAround(v->tile, v->owner, -160, 22);
 
	SndPlayVehicleFx(SND_12_EXPLOSION, v);
 
}
 

	
 
static void RoadVehCheckTrainCrash(Vehicle *v)
 
{
 
	for (Vehicle *u = v; u != NULL; u = u->Next()) {
 
		if (u->u.road.state == RVSB_WORMHOLE) continue;
 
@@ -821,36 +821,36 @@ static Vehicle* RoadVehFindCloseTo(Vehic
 
	return u;
 
}
 

	
 
static void RoadVehArrivesAt(const Vehicle* v, Station* st)
 
{
 
	if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
 
		/* Check if station was ever visited before */
 
		if (!(st->had_vehicle_of_type & HVOT_BUS)) {
 
			st->had_vehicle_of_type |= HVOT_BUS;
 
			SetDParam(0, st->index);
 
			AddNewsItem(
 
				v->u.road.roadtype == ROADTYPE_ROAD ? STR_902F_CITIZENS_CELEBRATE_FIRST : STR_CITIZENS_CELEBRATE_FIRST_PASSENGER_TRAM,
 
				NM_THIN, NF_VIEWPORT | NF_VEHICLE, (v->owner == _local_player) ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
 
				(v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
 
				v->index,
 
				0);
 
		}
 
	} else {
 
		/* Check if station was ever visited before */
 
		if (!(st->had_vehicle_of_type & HVOT_TRUCK)) {
 
			st->had_vehicle_of_type |= HVOT_TRUCK;
 
			SetDParam(0, st->index);
 
			AddNewsItem(
 
				v->u.road.roadtype == ROADTYPE_ROAD ? STR_9030_CITIZENS_CELEBRATE_FIRST : STR_CITIZENS_CELEBRATE_FIRST_CARGO_TRAM,
 
				NM_THIN, NF_VIEWPORT | NF_VEHICLE, (v->owner == _local_player) ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
 
				(v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
 
				v->index,
 
				0
 
			);
 
		}
 
	}
 
}
 

	
 
static bool RoadVehAccelerate(Vehicle *v)
 
{
 
	uint spd = v->cur_speed + 1 + (v->u.road.overtaking != 0 ? 1 : 0);
 
	byte t;
 

	
src/ship_cmd.cpp
Show inline comments
 
@@ -340,25 +340,25 @@ static CommandCost EstimateShipCost(Engi
 
	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base >> 3) >> 5);
 
}
 

	
 
static void ShipArrivesAt(const Vehicle* v, Station* st)
 
{
 
	/* Check if station was ever visited before */
 
	if (!(st->had_vehicle_of_type & HVOT_SHIP)) {
 
		st->had_vehicle_of_type |= HVOT_SHIP;
 

	
 
		SetDParam(0, st->index);
 
		AddNewsItem(
 
			STR_9833_CITIZENS_CELEBRATE_FIRST,
 
			NM_THIN, NF_VIEWPORT | NF_VEHICLE, (v->owner == _local_player) ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
 
			(v->owner == _local_player) ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
 
			v->index,
 
			0);
 
	}
 
}
 

	
 
struct PathFindShip {
 
	TileIndex skiptile;
 
	TileIndex dest_coords;
 
	uint best_bird_dist;
 
	uint best_length;
 
};
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -400,25 +400,25 @@ static uint GetAcceptanceMask(const Stat
 
}
 

	
 
/** Items contains the two cargo names that are to be accepted or rejected.
 
 * msg is the string id of the message to display.
 
 */
 
static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *cargo, StringID msg)
 
{
 
	for (uint i = 0; i < num_items; i++) {
 
		SetDParam(i + 1, GetCargo(cargo[i])->name);
 
	}
 

	
 
	SetDParam(0, st->index);
 
	AddNewsItem(msg, NM_SMALL, NF_VIEWPORT | NF_TILE, NT_ACCEPTANCE, DNC_NONE, st->xy, 0);
 
	AddNewsItem(msg, NS_ACCEPTANCE, st->xy, 0);
 
}
 

	
 
/**
 
 * Get a list of the cargo types being produced around the tile (in a rectangle).
 
 * @param produced: Destination array of produced cargo
 
 * @param tile: Center of the search area
 
 * @param w: Width of the center
 
 * @param h: Height of the center
 
 * @param rad: Radius of the search area
 
 */
 
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile,
 
	int w, int h, int rad)
src/town_cmd.cpp
Show inline comments
 
@@ -2143,25 +2143,25 @@ static void TownActionAdvertiseLarge(Tow
 
{
 
	ModifyStationRatingAround(t->xy, _current_player, 0xA0, 20);
 
}
 

	
 
static void TownActionRoadRebuild(Town *t)
 
{
 
	t->road_build_months = 6;
 

	
 
	SetDParam(0, t->index);
 
	SetDParam(1, _current_player);
 

	
 
	AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING,
 
		NM_NORMAL, NF_TILE, NT_GENERAL, DNC_NONE, t->xy, 0);
 
		NS_GENERAL, t->xy, 0);
 
}
 

	
 
static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)
 
{
 
	/* Statues can be build on slopes, just like houses. Only the steep slopes is a no go. */
 
	if (IsSteepSlope(GetTileSlope(tile, NULL))) return false;
 

	
 
	if (!IsTileType(tile, MP_HOUSE) &&
 
			!IsTileType(tile, MP_CLEAR) &&
 
			!IsTileType(tile, MP_TREES)) {
 
		return false;
 
	}
src/train_cmd.cpp
Show inline comments
 
@@ -2441,25 +2441,25 @@ static Track ChooseTrainTrack(Vehicle *v
 

	
 
	/* handle "path not found" state */
 
	if (path_not_found) {
 
		/* PF didn't find the route */
 
		if (!HasBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION)) {
 
			/* it is first time the problem occurred, set the "path not found" flag */
 
			SetBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
 
			/* and notify user about the event */
 
			if (_patches.lost_train_warn && v->owner == _local_player) {
 
				SetDParam(0, v->unitnumber);
 
				AddNewsItem(
 
					STR_TRAIN_IS_LOST,
 
					NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE,
 
					NS_ADVICE,
 
					v->index,
 
					0);
 
			}
 
		}
 
	} else {
 
		/* route found, is the train marked with "path not found" flag? */
 
		if (HasBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION)) {
 
			/* clear the flag as the PF's problem was solved */
 
			ClrBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
 
			/* can we also delete the "News" item somehow? */
 
		}
 
	}
 
@@ -2638,25 +2638,25 @@ static int UpdateTrainSpeed(Vehicle *v)
 

	
 
static void TrainEnterStation(Vehicle *v, StationID station)
 
{
 
	v->last_station_visited = station;
 

	
 
	/* check if a train ever visited this station before */
 
	Station *st = GetStation(station);
 
	if (!(st->had_vehicle_of_type & HVOT_TRAIN)) {
 
		st->had_vehicle_of_type |= HVOT_TRAIN;
 
		SetDParam(0, st->index);
 
		AddNewsItem(
 
			STR_8801_CITIZENS_CELEBRATE_FIRST,
 
			NM_THIN, NF_VIEWPORT | NF_VEHICLE, v->owner == _local_player ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
 
			v->owner == _local_player ? NS_ARRIVAL_PLAYER : NS_ARRIVAL_OTHER,
 
			v->index,
 
			0
 
		);
 
	}
 

	
 
	v->BeginLoading();
 

	
 
	StationAnimationTrigger(st, v->tile, STAT_ANIM_TRAIN_ARRIVES);
 
}
 

	
 
static byte AfterSetTrainPos(Vehicle *v, bool new_tile)
 
{
 
@@ -2884,25 +2884,25 @@ static void CheckTrainCollision(Vehicle 
 
	if (v->u.rail.track == TRACK_BIT_WORMHOLE) {
 
		VehicleFromPos(v->tile, &tcc, FindTrainCollideEnum);
 
		VehicleFromPos(GetOtherTunnelBridgeEnd(v->tile), &tcc, FindTrainCollideEnum);
 
	} else {
 
		VehicleFromPosXY(v->x_pos, v->y_pos, &tcc, FindTrainCollideEnum);
 
	}
 

	
 
	/* any dead -> no crash */
 
	if (tcc.num == 0) return;
 

	
 
	SetDParam(0, tcc.num);
 
	AddNewsItem(STR_8868_TRAIN_CRASH_DIE_IN_FIREBALL,
 
		NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
 
		NS_ACCIDENT_VEHICLE,
 
		v->index,
 
		0
 
	);
 

	
 
	ModifyStationRatingAround(v->tile, v->owner, -160, 30);
 
	SndPlayVehicleFx(SND_13_BIG_CRASH, v);
 
}
 

	
 
static void *CheckVehicleAtSignal(Vehicle *v, void *data)
 
{
 
	Direction dir = *(Direction*)data;
 

	
 
@@ -3608,25 +3608,25 @@ void Train::OnNewDay()
 
void TrainsYearlyLoop()
 
{
 
	Vehicle *v;
 

	
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
 
			/* show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
 
			if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
 
				SetDParam(1, v->GetDisplayProfitThisYear());
 
				SetDParam(0, v->unitnumber);
 
				AddNewsItem(
 
					STR_TRAIN_IS_UNPROFITABLE,
 
					NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE,
 
					NS_ADVICE,
 
					v->index,
 
					0);
 
			}
 

	
 
			v->profit_last_year = v->profit_this_year;
 
			v->profit_this_year = 0;
 
			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		}
 
	}
 
}
 

	
 

	
src/vehicle.cpp
Show inline comments
 
@@ -943,25 +943,25 @@ static const StringID _vehicle_type_name
 
	STR_019D_AIRCRAFT,
 
};
 

	
 
static void ShowVehicleGettingOld(Vehicle *v, StringID msg)
 
{
 
	if (v->owner != _local_player) return;
 

	
 
	/* Do not show getting-old message if autorenew is active (and it can replace the vehicle) */
 
	if (GetPlayer(v->owner)->engine_renew && GetEngine(v->engine_type)->player_avail != 0) return;
 

	
 
	SetDParam(0, _vehicle_type_names[v->type]);
 
	SetDParam(1, v->unitnumber);
 
	AddNewsItem(msg, NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
 
	AddNewsItem(msg, NS_ADVICE, v->index, 0);
 
}
 

	
 
void AgeVehicle(Vehicle *v)
 
{
 
	if (v->age < 65535) v->age++;
 

	
 
	int age = v->age - v->max_age;
 
	if (age == 366*0 || age == 366*1 || age == 366*2 || age == 366*3 || age == 366*4) v->reliability_spd_dec <<= 1;
 

	
 
	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 

	
 
	if (age == -366) {
 
@@ -1642,25 +1642,25 @@ void VehicleEnterDepot(Vehicle *v)
 
		v->current_order.MakeDummy();
 

	
 
		if (t.IsRefit()) {
 
			_current_player = v->owner;
 
			CommandCost cost = DoCommand(v->tile, v->index, t.GetRefitCargo() | t.GetRefitSubtype() << 8, DC_EXEC, GetCmdRefitVeh(v));
 

	
 
			if (CmdFailed(cost)) {
 
				v->leave_depot_instantly = false; // We ensure that the vehicle stays in the depot
 
				if (v->owner == _local_player) {
 
					/* Notify the user that we stopped the vehicle */
 
					SetDParam(0, _vehicle_type_names[v->type]);
 
					SetDParam(1, v->unitnumber);
 
					AddNewsItem(STR_ORDER_REFIT_FAILED, NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
 
					AddNewsItem(STR_ORDER_REFIT_FAILED, NS_ADVICE, v->index, 0);
 
				}
 
			} else if (v->owner == _local_player && cost.GetCost() != 0) {
 
				ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost());
 
			}
 
		}
 

	
 
		if (t.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) {
 
			/* Part of orders */
 
			UpdateVehicleTimetable(v, true);
 
			v->cur_order_index++;
 
		} else if (t.GetDepotActionType() & ODATFB_HALT) {
 
			/* Force depot visit */
 
@@ -1668,25 +1668,25 @@ void VehicleEnterDepot(Vehicle *v)
 
			if (v->owner == _local_player) {
 
				StringID string;
 

	
 
				switch (v->type) {
 
					case VEH_TRAIN:    string = STR_8814_TRAIN_IS_WAITING_IN_DEPOT; break;
 
					case VEH_ROAD:     string = STR_9016_ROAD_VEHICLE_IS_WAITING;   break;
 
					case VEH_SHIP:     string = STR_981C_SHIP_IS_WAITING_IN_DEPOT;  break;
 
					case VEH_AIRCRAFT: string = STR_A014_AIRCRAFT_IS_WAITING_IN;    break;
 
					default: NOT_REACHED(); string = STR_EMPTY; // Set the string to something to avoid a compiler warning
 
				}
 

	
 
				SetDParam(0, v->unitnumber);
 
				AddNewsItem(string, NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
 
				AddNewsItem(string, NS_ADVICE, v->index, 0);
 
			}
 
		}
 
	}
 
}
 

	
 
static bool IsUniqueVehicleName(const char *name)
 
{
 
	const Vehicle *v;
 
	char buf[512];
 

	
 
	FOR_ALL_VEHICLES(v) {
 
		switch (v->type) {
src/water_cmd.cpp
Show inline comments
 
@@ -852,25 +852,25 @@ static void FloodVehicle(Vehicle *v)
 
			}
 

	
 
			RebuildVehicleLists();
 
		} else {
 
			return;
 
		}
 

	
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 

	
 
		SetDParam(0, pass);
 
		AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED,
 
			NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
 
			NS_ACCIDENT_VEHICLE,
 
			v->index,
 
			0);
 
		CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
 
		SndPlayVehicleFx(SND_12_EXPLOSION, v);
 
	}
 
}
 

	
 
/**
 
 * Returns the behaviour of a tile during flooding.
 
 *
 
 * @return Behaviour of the tile
 
 */
0 comments (0 inline, 0 general)