Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport master into release/14 #12466

Merged
merged 11 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/aircraft.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct Aircraft final : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
void OnNewEconomyDay() override;
uint Crash(bool flooded = false) override;
TileIndex GetOrderStationLocation(StationID station) override;
TileIndex GetCargoTile() const override { return this->First()->tile; }
ClosestDepot FindClosestDepot() override;

/**
Expand Down
7 changes: 5 additions & 2 deletions src/aircraft_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,10 +1182,13 @@ static bool HandleCrashedAircraft(Aircraft *v)
if (v->crashed_counter < 500 && st == nullptr && ((v->crashed_counter % 3) == 0) ) {
int z = GetSlopePixelZ(Clamp(v->x_pos, 0, Map::MaxX() * TILE_SIZE), Clamp(v->y_pos, 0, Map::MaxY() * TILE_SIZE));
v->z_pos -= 1;
if (v->z_pos == z) {
if (v->z_pos <= z) {
v->crashed_counter = 500;
v->z_pos++;
v->z_pos = z + 1;
} else {
v->crashed_counter = 0;
}
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
}

if (v->crashed_counter < 650) {
Expand Down
1 change: 1 addition & 0 deletions src/company_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
}
}

InvalidateWindowClassesData(WC_COMPANY, 1);
MarkWholeScreenDirty();
CompanyAdminUpdate(c);
}
Expand Down
16 changes: 16 additions & 0 deletions src/company_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2492,6 +2492,14 @@ struct CompanyWindow : Window
}
}

void OnResize() override
{
NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_C_FACE_TITLE);
SetDParam(0, this->owner);
int y = GetStringHeight(STR_COMPANY_VIEW_PRESIDENT_MANAGER_TITLE, wid->current_x);
if (wid->UpdateVerticalSize(y)) this->ReInit(0, 0);
}

void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
{
switch (widget) {
Expand Down Expand Up @@ -2627,6 +2635,14 @@ struct CompanyWindow : Window
break;
}
}

void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
{
if (gui_scope && data == 1) {
/* Manually call OnResize to adjust minimum height of president name widget. */
OnResize();
}
}
};

static WindowDesc _company_desc(__FILE__, __LINE__,
Expand Down
14 changes: 7 additions & 7 deletions src/economy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ void PrepareUnload(Vehicle *front_v)
front_v->last_station_visited, next_station,
front_v->current_order.GetUnloadType(), ge,
front_v->cargo_payment,
v->tile);
v->GetCargoTile());
if (v->cargo.UnloadCount() > 0) SetBit(v->vehicle_flags, VF_CARGO_UNLOADING);
}
}
Expand Down Expand Up @@ -1441,7 +1441,7 @@ struct ReturnCargoAction
*/
bool operator()(Vehicle *v)
{
v->cargo.Return(UINT_MAX, &this->st->goods[v->cargo_type].cargo, this->next_hop, v->tile);
v->cargo.Return(UINT_MAX, &this->st->goods[v->cargo_type].cargo, this->next_hop, v->GetCargoTile());
return true;
}
};
Expand Down Expand Up @@ -1476,7 +1476,7 @@ struct FinalizeRefitAction
{
if (this->do_reserve) {
this->st->goods[v->cargo_type].cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
&v->cargo, this->next_station, v->tile);
&v->cargo, this->next_station, v->GetCargoTile());
}
this->consist_capleft[v->cargo_type] += v->cargo_cap - v->cargo.RemainingCount();
return true;
Expand Down Expand Up @@ -1567,7 +1567,7 @@ struct ReserveCargoAction {
{
if (v->cargo_cap > v->cargo.RemainingCount() && MayLoadUnderExclusiveRights(st, v)) {
st->goods[v->cargo_type].cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
&v->cargo, *next_station, v->tile);
&v->cargo, *next_station, v->GetCargoTile());
}

return true;
Expand Down Expand Up @@ -1701,7 +1701,7 @@ static void LoadUnloadVehicle(Vehicle *front)
uint new_remaining = v->cargo.RemainingCount() + v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER);
if (v->cargo_cap < new_remaining) {
/* Return some of the reserved cargo to not overload the vehicle. */
v->cargo.Return(new_remaining - v->cargo_cap, &ge->cargo, INVALID_STATION, v->tile);
v->cargo.Return(new_remaining - v->cargo_cap, &ge->cargo, INVALID_STATION, v->GetCargoTile());
}

/* Keep instead of delivering. This may lead to no cargo being unloaded, so ...*/
Expand All @@ -1728,7 +1728,7 @@ static void LoadUnloadVehicle(Vehicle *front)
}
}

amount_unloaded = v->cargo.Unload(amount_unloaded, &ge->cargo, payment, v->tile);
amount_unloaded = v->cargo.Unload(amount_unloaded, &ge->cargo, payment, v->GetCargoTile());
remaining = v->cargo.UnloadCount() > 0;
if (amount_unloaded > 0) {
dirty_vehicle = true;
Expand Down Expand Up @@ -1798,7 +1798,7 @@ static void LoadUnloadVehicle(Vehicle *front)
if (v->cargo.StoredCount() == 0) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
if (_settings_game.order.gradual_loading) cap_left = std::min(cap_left, GetLoadAmount(v));

uint loaded = ge->cargo.Load(cap_left, &v->cargo, next_station, v->tile);
uint loaded = ge->cargo.Load(cap_left, &v->cargo, next_station, v->GetCargoTile());
if (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0) {
/* Remember if there are reservations left so that we don't stop
* loading before they're loaded. */
Expand Down
Loading