Merge branch 'master' into jgrpp

# Conflicts:
#	src/build_vehicle_gui.cpp
#	src/cheat_gui.cpp
#	src/console_cmds.cpp
#	src/crashlog.cpp
#	src/date_gui.cpp
#	src/engine.cpp
#	src/group_cmd.cpp
#	src/landscape.cpp
#	src/network/network_gui.cpp
#	src/newgrf.cpp
#	src/saveload/afterload.cpp
#	src/script/api/script_date.cpp
#	src/sl/oldloader_sl.cpp
#	src/station_cmd.cpp
#	src/station_cmd.h
#	src/strings.cpp
#	src/subsidy_gui.cpp
#	src/survey.cpp
#	src/timer/timer_game_calendar.cpp
#	src/timer/timer_game_calendar.h
This commit is contained in:
Jonathan G Rennison
2023-12-29 14:46:53 +00:00
27 changed files with 159 additions and 120 deletions

View File

@@ -1060,6 +1060,20 @@ CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32
return CommandCost();
}
/**
* Update liveries for a company. This is called when the LS_DEFAULT scheme is changed, to update schemes with colours
* set to default.
* @param c Company to update.
*/
void UpdateCompanyLiveries(Company *c)
{
for (int i = 1; i < LS_END; i++) {
if (!HasBit(c->livery[i].in_use, 0)) c->livery[i].colour1 = c->livery[LS_DEFAULT].colour1;
if (!HasBit(c->livery[i].in_use, 1)) c->livery[i].colour2 = c->livery[LS_DEFAULT].colour2;
}
UpdateCompanyGroupLiveries(c);
}
/**
* Change the company's company-colour
* @param tile unused
@@ -1100,9 +1114,7 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1,
/* If setting the first colour of the default scheme, adjust the
* original and cached company colours too. */
if (scheme == LS_DEFAULT) {
for (int i = 1; i < LS_END; i++) {
if (!HasBit(c->livery[i].in_use, 0)) c->livery[i].colour1 = colour;
}
UpdateCompanyLiveries(c);
_company_colours[_current_company] = colour;
c->colour = colour;
CompanyAdminUpdate(c);
@@ -1113,9 +1125,7 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1,
c->livery[scheme].colour2 = colour;
if (scheme == LS_DEFAULT) {
for (int i = 1; i < LS_END; i++) {
if (!HasBit(c->livery[i].in_use, 1)) c->livery[i].colour2 = colour;
}
UpdateCompanyGroupLiveries(c);
}
}