Merge branch 'master' into jgrpp

# Conflicts:
#	src/order_cmd.cpp
#	src/table/settings/news_display_settings.ini
This commit is contained in:
Jonathan G Rennison
2021-11-08 00:44:18 +00:00
16 changed files with 66 additions and 16 deletions

View File

@@ -1424,7 +1424,12 @@ static void CrashAirplane(Aircraft *v)
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING)); AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING)); Game::NewEvent(new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
AddTileNewsItem(newsitem, NT_ACCIDENT, vt, nullptr, st != nullptr ? st->index : INVALID_STATION); NewsType newstype = NT_ACCIDENT;
if (v->owner != _local_company) {
newstype = NT_ACCIDENT_OTHER;
}
AddTileNewsItem(newsitem, newstype, vt, nullptr, st != nullptr ? st->index : INVALID_STATION);
ModifyStationRatingAround(vt, v->owner, -160, 30); ModifyStationRatingAround(vt, v->owner, -160, 30);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);

View File

@@ -578,6 +578,16 @@ public:
size_t engine_count = this->engines[click_side].size(); size_t engine_count = this->engines[click_side].size();
EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE; EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE;
/* If Ctrl is pressed on the left side and we don't have any engines of the selected type, stop autoreplacing.
* This is most common when we have finished autoreplacing the engine and want to remove it from the list. */
if (click_side == 0 && _ctrl_pressed && e != INVALID_ENGINE &&
(GetGroupNumEngines(_local_company, sel_group, e) == 0 || GetGroupNumEngines(_local_company, ALL_GROUP, e) == 0)) {
EngineID veh_from = e;
DoCommandP(0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16), CMD_SET_AUTOREPLACE);
break;
}
if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
this->sel_engine[click_side] = e; this->sel_engine[click_side] = e;
if (click_side == 0) { if (click_side == 0) {

View File

@@ -1994,6 +1994,9 @@ STR_CONFIG_SETTING_NEWS_ARRIVAL_FIRST_VEHICLE_OTHER_HELPTEXT :Display a newsp
STR_CONFIG_SETTING_NEWS_ACCIDENTS_DISASTERS :Accidents / disasters: {STRING2} STR_CONFIG_SETTING_NEWS_ACCIDENTS_DISASTERS :Accidents / disasters: {STRING2}
STR_CONFIG_SETTING_NEWS_ACCIDENTS_DISASTERS_HELPTEXT :Display a newspaper when accidents or disasters occur STR_CONFIG_SETTING_NEWS_ACCIDENTS_DISASTERS_HELPTEXT :Display a newspaper when accidents or disasters occur
STR_CONFIG_SETTING_NEWS_ACCIDENT_OTHER :Accidents of competitor's vehicles: {STRING2}
STR_CONFIG_SETTING_NEWS_ACCIDENT_OTHER_HELPTEXT :Display a newspaper about crashed vehicles for competitors
STR_CONFIG_SETTING_NEWS_COMPANY_INFORMATION :Company information: {STRING2} STR_CONFIG_SETTING_NEWS_COMPANY_INFORMATION :Company information: {STRING2}
STR_CONFIG_SETTING_NEWS_COMPANY_INFORMATION_HELPTEXT :Display a newspaper when a new company starts, or when companies are risking to bankrupt STR_CONFIG_SETTING_NEWS_COMPANY_INFORMATION_HELPTEXT :Display a newspaper when a new company starts, or when companies are risking to bankrupt

View File

@@ -1343,7 +1343,7 @@ STR_CONFIG_SETTING_ERRMSG_DURATION_VALUE :{COMMA} second{
STR_CONFIG_SETTING_HOVER_DELAY :Show tooltips: {STRING} STR_CONFIG_SETTING_HOVER_DELAY :Show tooltips: {STRING}
STR_CONFIG_SETTING_HOVER_DELAY_HELPTEXT :Delay before tooltips are displayed when hovering the mouse over some interface element. Alternatively tooltips can be bound to the right mouse button STR_CONFIG_SETTING_HOVER_DELAY_HELPTEXT :Delay before tooltips are displayed when hovering the mouse over some interface element. Alternatively tooltips can be bound to the right mouse button
STR_CONFIG_SETTING_HOVER_DELAY_VALUE :Hover for {COMMA} second{P 0 "" s} STR_CONFIG_SETTING_HOVER_DELAY_VALUE :Hover for {COMMA} millisecond{P 0 "" s}
###setting-zero-is-special ###setting-zero-is-special
STR_CONFIG_SETTING_HOVER_DELAY_DISABLED :Right click STR_CONFIG_SETTING_HOVER_DELAY_DISABLED :Right click
@@ -2284,6 +2284,7 @@ STR_NETWORK_MESSAGE_CLIENT_COMPANY_SPECTATE :*** {STRING} ha
STR_NETWORK_MESSAGE_CLIENT_COMPANY_NEW :*** {STRING} has started a new company (#{2:NUM}) STR_NETWORK_MESSAGE_CLIENT_COMPANY_NEW :*** {STRING} has started a new company (#{2:NUM})
STR_NETWORK_MESSAGE_CLIENT_LEFT :*** {STRING} has left the game ({2:STRING}) STR_NETWORK_MESSAGE_CLIENT_LEFT :*** {STRING} has left the game ({2:STRING})
STR_NETWORK_MESSAGE_NAME_CHANGE :*** {STRING} has changed his/her name to {STRING} STR_NETWORK_MESSAGE_NAME_CHANGE :*** {STRING} has changed his/her name to {STRING}
STR_NETWORK_MESSAGE_GIVE_MONEY :*** {STRING} gave {2:CURRENCY_LONG} to {1:STRING}
STR_NETWORK_MESSAGE_SERVER_SHUTDOWN :{WHITE}The server closed the session STR_NETWORK_MESSAGE_SERVER_SHUTDOWN :{WHITE}The server closed the session
STR_NETWORK_MESSAGE_SERVER_REBOOT :{WHITE}The server is restarting...{}Please wait... STR_NETWORK_MESSAGE_SERVER_REBOOT :{WHITE}The server is restarting...{}Please wait...
@@ -3676,6 +3677,7 @@ STR_REPLACE_MONORAIL_VEHICLES :Monorail Vehicl
STR_REPLACE_MAGLEV_VEHICLES :Maglev Vehicles STR_REPLACE_MAGLEV_VEHICLES :Maglev Vehicles
STR_REPLACE_REMOVE_WAGON :{BLACK}Wagon removal ({STRING}): {ORANGE}{STRING}
STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Make autoreplace keep the length of a train the same by removing wagons (starting at the front), if replacing the engine would make the train longer STR_REPLACE_REMOVE_WAGON_HELP :{BLACK}Make autoreplace keep the length of a train the same by removing wagons (starting at the front), if replacing the engine would make the train longer
# Vehicle view # Vehicle view

View File

@@ -1202,9 +1202,9 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_NEWGAME(Packet
* care about the server shutting down. */ * care about the server shutting down. */
if (this->status >= STATUS_JOIN) { if (this->status >= STATUS_JOIN) {
/* To throttle the reconnects a bit, every clients waits its /* To throttle the reconnects a bit, every clients waits its
* Client ID modulo 16. This way reconnects should be spread * Client ID modulo 16 + 1 (value 0 means no reconnect).
* out a bit. */ * This way reconnects should be spread out a bit. */
_network_reconnect = _network_own_client_id % 16; _network_reconnect = _network_own_client_id % 16 + 1;
ShowErrorMessage(STR_NETWORK_MESSAGE_SERVER_REBOOT, INVALID_STRING_ID, WL_CRITICAL); ShowErrorMessage(STR_NETWORK_MESSAGE_SERVER_REBOOT, INVALID_STRING_ID, WL_CRITICAL);
} }

View File

@@ -2760,8 +2760,8 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, co
uint16 options = buf->ReadWord(); uint16 options = buf->ReadWord();
if (curidx < CURRENCY_END) { if (curidx < CURRENCY_END) {
_currency_specs[curidx].separator[0] = GB(options, 0, 8); _currency_specs[curidx].separator.clear();
_currency_specs[curidx].separator[1] = '\0'; _currency_specs[curidx].separator.push_back(GB(options, 0, 8));
/* By specifying only one bit, we prevent errors, /* By specifying only one bit, we prevent errors,
* since newgrf specs said that only 0 and 1 can be set for symbol_pos */ * since newgrf specs said that only 0 and 1 can be set for symbol_pos */
_currency_specs[curidx].symbol_pos = GB(options, 8, 1); _currency_specs[curidx].symbol_pos = GB(options, 8, 1);

View File

@@ -231,6 +231,7 @@ static NewsTypeData _news_type_data[] = {
NewsTypeData("news_display.arrival_player", 60, SND_1D_APPLAUSE ), ///< NT_ARRIVAL_COMPANY NewsTypeData("news_display.arrival_player", 60, SND_1D_APPLAUSE ), ///< NT_ARRIVAL_COMPANY
NewsTypeData("news_display.arrival_other", 60, SND_1D_APPLAUSE ), ///< NT_ARRIVAL_OTHER NewsTypeData("news_display.arrival_other", 60, SND_1D_APPLAUSE ), ///< NT_ARRIVAL_OTHER
NewsTypeData("news_display.accident", 90, SND_BEGIN ), ///< NT_ACCIDENT NewsTypeData("news_display.accident", 90, SND_BEGIN ), ///< NT_ACCIDENT
NewsTypeData("news_display.accident_other", 90, SND_BEGIN ), ///< NT_ACCIDENT_OTHER
NewsTypeData("news_display.company_info", 60, SND_BEGIN ), ///< NT_COMPANY_INFO NewsTypeData("news_display.company_info", 60, SND_BEGIN ), ///< NT_COMPANY_INFO
NewsTypeData("news_display.open", 90, SND_BEGIN ), ///< NT_INDUSTRY_OPEN NewsTypeData("news_display.open", 90, SND_BEGIN ), ///< NT_INDUSTRY_OPEN
NewsTypeData("news_display.close", 90, SND_BEGIN ), ///< NT_INDUSTRY_CLOSE NewsTypeData("news_display.close", 90, SND_BEGIN ), ///< NT_INDUSTRY_CLOSE

View File

@@ -22,6 +22,7 @@ enum NewsType {
NT_ARRIVAL_COMPANY, ///< First vehicle arrived for company NT_ARRIVAL_COMPANY, ///< First vehicle arrived for company
NT_ARRIVAL_OTHER, ///< First vehicle arrived for competitor NT_ARRIVAL_OTHER, ///< First vehicle arrived for competitor
NT_ACCIDENT, ///< An accident or disaster has occurred NT_ACCIDENT, ///< An accident or disaster has occurred
NT_ACCIDENT_OTHER, ///< An accident or disaster has occurred
NT_COMPANY_INFO, ///< Company info (new companies, bankruptcy messages) NT_COMPANY_INFO, ///< Company info (new companies, bankruptcy messages)
NT_INDUSTRY_OPEN, ///< Opening of industries NT_INDUSTRY_OPEN, ///< Opening of industries
NT_INDUSTRY_CLOSE, ///< Closing of industries NT_INDUSTRY_CLOSE, ///< Closing of industries

View File

@@ -1470,10 +1470,10 @@ CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
v->ClearSeparation(); v->ClearSeparation();
if (HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION)) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED); if (HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION)) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
}
/* We have an aircraft/ship, they have a mini-schedule, so update them all */ /* We have an aircraft/ship, they have a mini-schedule, so update them all */
if (v->type == VEH_AIRCRAFT || v->type == VEH_SHIP) DirtyVehicleListWindowForVehicle(v); if (v->type == VEH_AIRCRAFT || v->type == VEH_SHIP) DirtyVehicleListWindowForVehicle(v);
}
return CommandCost(); return CommandCost();
} }

View File

@@ -1222,9 +1222,12 @@ bool NPFShipCheckReverse(const Ship *v, Trackdir *best_td)
AyStarUserData user = { v->owner, TRANSPORT_WATER, RAILTYPES_NONE, ROADTYPES_NONE, 0 }; AyStarUserData user = { v->owner, TRANSPORT_WATER, RAILTYPES_NONE, ROADTYPES_NONE, 0 };
if (best_td != nullptr) { if (best_td != nullptr) {
TrackdirBits rtds = DiagdirReachesTrackdirs(ReverseDiagDir(VehicleExitDir(v->direction, v->state))); DiagDirection entry = ReverseDiagDir(VehicleExitDir(v->direction, v->state));
TrackdirBits rtds = DiagdirReachesTrackdirs(entry) & TrackStatusToTrackdirBits(GetTileTrackStatus(v->tile, TRANSPORT_WATER, 0, entry));
Trackdir best = (Trackdir)FindFirstBit2x64(rtds); Trackdir best = (Trackdir)FindFirstBit2x64(rtds);
for (rtds = KillFirstBit(rtds); rtds != TRACKDIR_BIT_NONE; rtds = KillFirstBit(rtds)) { rtds = KillFirstBit(rtds);
if (rtds == TRACKDIR_BIT_NONE) return false; /* At most one choice. */
for (; rtds != TRACKDIR_BIT_NONE; rtds = KillFirstBit(rtds)) {
Trackdir td = (Trackdir)FindFirstBit2x64(rtds); Trackdir td = (Trackdir)FindFirstBit2x64(rtds);
ftd = NPFRouteToStationOrTileTwoWay(v->tile, best, false, v->tile, td, false, &fstd, &user); ftd = NPFRouteToStationOrTileTwoWay(v->tile, best, false, v->tile, td, false, &fstd, &user);
if (ftd.best_bird_dist == 0 && NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) best = td; if (ftd.best_bird_dist == 0 && NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) best = td;

View File

@@ -212,7 +212,13 @@ public:
/* create pathfinder instance */ /* create pathfinder instance */
Tpf pf; Tpf pf;
/* set origin and destination nodes */ /* set origin and destination nodes */
pf.SetOrigin(tile, trackdir == nullptr ? TrackdirToTrackdirBits(td1) | TrackdirToTrackdirBits(td2) : DiagdirReachesTrackdirs(ReverseDiagDir(VehicleExitDir(v->direction, v->state)))); if (trackdir == nullptr) {
pf.SetOrigin(tile, TrackdirToTrackdirBits(td1) | TrackdirToTrackdirBits(td2));
} else {
DiagDirection entry = ReverseDiagDir(VehicleExitDir(v->direction, v->state));
TrackdirBits rtds = DiagdirReachesTrackdirs(entry) & TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0, entry));
pf.SetOrigin(tile, rtds);
}
pf.SetDestination(v); pf.SetDestination(v);
/* find best path */ /* find best path */
if (!pf.FindPath(v)) return false; if (!pf.FindPath(v)) return false;

View File

@@ -619,7 +619,13 @@ static void RoadVehCrash(RoadVehicle *v)
SetDParam(0, pass); SetDParam(0, pass);
StringID newsitem = (pass == 1) ? STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER : STR_NEWS_ROAD_VEHICLE_CRASH; StringID newsitem = (pass == 1) ? STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER : STR_NEWS_ROAD_VEHICLE_CRASH;
AddTileNewsItem(newsitem, NT_ACCIDENT, v->tile); NewsType newstype = NT_ACCIDENT;
if (v->owner != _local_company) {
newstype = NT_ACCIDENT_OTHER;
}
AddTileNewsItem(newsitem, newstype, v->tile);
ModifyStationRatingAround(v->tile, v->owner, -160, 22); ModifyStationRatingAround(v->tile, v->owner, -160, 22);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);

View File

@@ -435,8 +435,8 @@ static void CDECL HandleSavegameLoadCrash(int signum)
"or older version.\n" "or older version.\n"
"It will load a NewGRF with the same GRF ID as the missing NewGRF.\n" "It will load a NewGRF with the same GRF ID as the missing NewGRF.\n"
"This means that if the author makes incompatible NewGRFs with the\n" "This means that if the author makes incompatible NewGRFs with the\n"
"same GRF ID OpenTTD cannot magically do the right thing. In most\n" "same GRF ID, OpenTTD cannot magically do the right thing. In most\n"
"cases OpenTTD will load the savegame and not crash, but this is an\n" "cases, OpenTTD will load the savegame and not crash, but this is an\n"
"exception.\n" "exception.\n"
"Please load the savegame with the appropriate NewGRFs installed.\n" "Please load the savegame with the appropriate NewGRFs installed.\n"
"The missing/compatible NewGRFs are:\n"); "The missing/compatible NewGRFs are:\n");

View File

@@ -1866,6 +1866,7 @@ static SettingsContainer &GetSettingsTree()
advisors->Add(new SettingEntry("news_display.general")); advisors->Add(new SettingEntry("news_display.general"));
advisors->Add(new SettingEntry("news_display.new_vehicles")); advisors->Add(new SettingEntry("news_display.new_vehicles"));
advisors->Add(new SettingEntry("news_display.accident")); advisors->Add(new SettingEntry("news_display.accident"));
advisors->Add(new SettingEntry("news_display.accident_other"));
advisors->Add(new SettingEntry("news_display.company_info")); advisors->Add(new SettingEntry("news_display.company_info"));
advisors->Add(new SettingEntry("news_display.acceptance")); advisors->Add(new SettingEntry("news_display.acceptance"));
advisors->Add(new SettingEntry("news_display.arrival_player")); advisors->Add(new SettingEntry("news_display.arrival_player"));

View File

@@ -309,6 +309,7 @@ struct NewsSettings {
uint8 arrival_player; ///< NewsDisplay of vehicles arriving at new stations of current player uint8 arrival_player; ///< NewsDisplay of vehicles arriving at new stations of current player
uint8 arrival_other; ///< NewsDisplay of vehicles arriving at new stations of other players uint8 arrival_other; ///< NewsDisplay of vehicles arriving at new stations of other players
uint8 accident; ///< NewsDisplay of accidents that occur uint8 accident; ///< NewsDisplay of accidents that occur
uint8 accident_other; ///< NewsDisplay if a vehicle from another company is involved in an accident
uint8 company_info; ///< NewsDisplay of general company information uint8 company_info; ///< NewsDisplay of general company information
uint8 open; ///< NewsDisplay on new industry constructions uint8 open; ///< NewsDisplay on new industry constructions
uint8 close; ///< NewsDisplay about closing industries uint8 close; ///< NewsDisplay about closing industries

View File

@@ -5550,6 +5550,17 @@ str = STR_CONFIG_SETTING_NEWS_ACCIDENTS_DISASTERS
strhelp = STR_CONFIG_SETTING_NEWS_ACCIDENTS_DISASTERS_HELPTEXT strhelp = STR_CONFIG_SETTING_NEWS_ACCIDENTS_DISASTERS_HELPTEXT
strval = STR_CONFIG_SETTING_NEWS_MESSAGES_OFF strval = STR_CONFIG_SETTING_NEWS_MESSAGES_OFF
[SDTC_OMANY]
var = news_display.accident_other
type = SLE_UINT8
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN
def = 2
max = 2
full = _news_display
str = STR_CONFIG_SETTING_NEWS_ACCIDENT_OTHER
strhelp = STR_CONFIG_SETTING_NEWS_ACCIDENT_OTHER_HELPTEXT
strval = STR_CONFIG_SETTING_NEWS_MESSAGES_OFF
[SDTC_OMANY] [SDTC_OMANY]
var = news_display.company_info var = news_display.company_info
type = SLE_UINT8 type = SLE_UINT8