Merge branch 'master' into jgrpp
# Conflicts: # regression/regression/result.txt # src/aircraft_cmd.cpp # src/airport_gui.cpp # src/articulated_vehicles.cpp # src/console_cmds.cpp # src/date_gui.cpp # src/engine.cpp # src/genworld_gui.cpp # src/gfx_layout_fallback.cpp # src/group_gui.cpp # src/hotkeys.cpp # src/network/core/tcp_connect.cpp # src/network/core/tcp_listen.h # src/newgrf.cpp # src/newgrf.h # src/newgrf_engine.cpp # src/newgrf_gui.cpp # src/newgrf_station.cpp # src/openttd.cpp # src/order_gui.cpp # src/os/macosx/osx_main.cpp # src/pathfinder/yapf/yapf_node_rail.hpp # src/rail_gui.cpp # src/saveload/afterload.cpp # src/saveload/cargopacket_sl.cpp # src/saveload/linkgraph_sl.cpp # src/saveload/station_sl.cpp # src/script/api/script_industrytype.cpp # src/settings.cpp # src/settings_gui.cpp # src/settings_table.cpp # src/settingsgen/settingsgen.cpp # src/station.cpp # src/station_cmd.cpp # src/strings.cpp # src/timer/timer_game_calendar.cpp # src/timer/timer_game_calendar.h # src/timer/timer_manager.h # src/timer/timer_window.cpp # src/timetable_cmd.cpp # src/toolbar_gui.cpp # src/town_cmd.cpp # src/town_gui.cpp # src/train_gui.cpp # src/vehicle_cmd.h # src/vehicle_gui.cpp # src/viewport.cpp # src/widgets/dropdown.cpp # src/window_func.h # src/window_gui.h
This commit is contained in:
@@ -595,16 +595,16 @@ CargoTypes GetEmptyMask(const Station *st)
|
||||
}
|
||||
|
||||
/**
|
||||
* Items contains the two cargo names that are to be accepted or rejected.
|
||||
* msg is the string id of the message to display.
|
||||
* Add news item for when a station changes which cargoes it accepts.
|
||||
* @param st Station of cargo change.
|
||||
* @param cargoes Bit mask of cargo types to list.
|
||||
* @param reject True iff the station rejects the cargo types.
|
||||
*/
|
||||
static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *cargo, StringID msg)
|
||||
static void ShowRejectOrAcceptNews(const Station *st, CargoTypes cargoes, bool reject)
|
||||
{
|
||||
for (uint i = 0; i < num_items; i++) {
|
||||
SetDParam(i + 1, CargoSpec::Get(cargo[i])->name);
|
||||
}
|
||||
|
||||
SetDParam(0, st->index);
|
||||
SetDParam(1, cargoes);
|
||||
StringID msg = reject ? STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST : STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST;
|
||||
AddNewsItem(msg, NT_ACCEPTANCE, NF_INCOLOUR | NF_SMALL, NR_STATION, st->index);
|
||||
}
|
||||
|
||||
@@ -730,41 +730,13 @@ void UpdateStationAcceptance(Station *st, bool show_msg)
|
||||
|
||||
/* show a message to report that the acceptance was changed? */
|
||||
if (show_msg && st->owner == _local_company && st->IsInUse()) {
|
||||
/* List of accept and reject strings for different number of
|
||||
* cargo types */
|
||||
static const StringID accept_msg[] = {
|
||||
STR_NEWS_STATION_NOW_ACCEPTS_CARGO,
|
||||
STR_NEWS_STATION_NOW_ACCEPTS_CARGO_AND_CARGO,
|
||||
};
|
||||
static const StringID reject_msg[] = {
|
||||
STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO,
|
||||
STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_OR_CARGO,
|
||||
};
|
||||
|
||||
/* Array of accepted and rejected cargo types */
|
||||
CargoID accepts[2] = { CT_INVALID, CT_INVALID };
|
||||
CargoID rejects[2] = { CT_INVALID, CT_INVALID };
|
||||
uint num_acc = 0;
|
||||
uint num_rej = 0;
|
||||
|
||||
/* Test each cargo type to see if its acceptance has changed */
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
if (HasBit(new_acc, i)) {
|
||||
if (!HasBit(old_acc, i) && num_acc < lengthof(accepts)) {
|
||||
/* New cargo is accepted */
|
||||
accepts[num_acc++] = i;
|
||||
}
|
||||
} else {
|
||||
if (HasBit(old_acc, i) && num_rej < lengthof(rejects)) {
|
||||
/* Old cargo is no longer accepted */
|
||||
rejects[num_rej++] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Combine old and new masks to get changes */
|
||||
CargoTypes accepts = new_acc & ~old_acc;
|
||||
CargoTypes rejects = ~new_acc & old_acc;
|
||||
|
||||
/* Show news message if there are any changes */
|
||||
if (num_acc > 0) ShowRejectOrAcceptNews(st, num_acc, accepts, accept_msg[num_acc - 1]);
|
||||
if (num_rej > 0) ShowRejectOrAcceptNews(st, num_rej, rejects, reject_msg[num_rej - 1]);
|
||||
if (accepts != 0) ShowRejectOrAcceptNews(st, accepts, false);
|
||||
if (rejects != 0) ShowRejectOrAcceptNews(st, rejects, true);
|
||||
}
|
||||
|
||||
/* redraw the station view since acceptance changed */
|
||||
@@ -783,10 +755,10 @@ static void UpdateStationSignCoord(BaseStation *st)
|
||||
|
||||
if (!Station::IsExpected(st)) return;
|
||||
Station *full_station = Station::From(st);
|
||||
for (CargoID c = 0; c < NUM_CARGO; ++c) {
|
||||
LinkGraphID lg = full_station->goods[c].link_graph;
|
||||
for (const GoodsEntry &ge : full_station->goods) {
|
||||
LinkGraphID lg = ge.link_graph;
|
||||
if (!LinkGraph::IsValidID(lg)) continue;
|
||||
(*LinkGraph::Get(lg))[full_station->goods[c].node].UpdateLocation(st->xy);
|
||||
(*LinkGraph::Get(lg))[ge.node].UpdateLocation(st->xy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4110,8 +4082,8 @@ static bool StationHandleBigTick(BaseStation *st)
|
||||
if (Station::IsExpected(st)) {
|
||||
TriggerWatchedCargoCallbacks(Station::From(st));
|
||||
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
ClrBit(Station::From(st)->goods[i].status, GoodsEntry::GES_ACCEPTED_BIGTICK);
|
||||
for (GoodsEntry &ge : Station::From(st)->goods) {
|
||||
ClrBit(ge.status, GoodsEntry::GES_ACCEPTED_BIGTICK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4683,10 +4655,9 @@ void StationDailyLoop()
|
||||
void StationMonthlyLoop()
|
||||
{
|
||||
for (Station *st : Station::Iterate()) {
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
GoodsEntry *ge = &st->goods[i];
|
||||
SB(ge->status, GoodsEntry::GES_LAST_MONTH, 1, GB(ge->status, GoodsEntry::GES_CURRENT_MONTH, 1));
|
||||
ClrBit(ge->status, GoodsEntry::GES_CURRENT_MONTH);
|
||||
for (GoodsEntry &ge : st->goods) {
|
||||
SB(ge.status, GoodsEntry::GES_LAST_MONTH, 1, GB(ge.status, GoodsEntry::GES_CURRENT_MONTH, 1));
|
||||
ClrBit(ge.status, GoodsEntry::GES_CURRENT_MONTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4696,11 +4667,9 @@ void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint rad
|
||||
{
|
||||
ForAllStationsRadius(tile, radius, [&](Station *st) {
|
||||
if (st->owner == owner && DistanceManhattan(tile, st->xy) <= radius) {
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
GoodsEntry *ge = &st->goods[i];
|
||||
|
||||
if (ge->status != 0) {
|
||||
ge->rating = ClampTo<uint8_t>(ge->rating + amount);
|
||||
for (GoodsEntry &ge : st->goods) {
|
||||
if (ge.status != 0) {
|
||||
ge.rating = ClampTo<uint8_t>(ge.rating + amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user