Merge branch 'master' into jgrpp

# Conflicts:
#	src/articulated_vehicles.cpp
#	src/articulated_vehicles.h
#	src/base_media_base.h
#	src/base_media_func.h
#	src/build_vehicle_gui.cpp
#	src/dock_gui.cpp
#	src/main_gui.cpp
#	src/music_gui.cpp
#	src/network/network_chat_gui.cpp
#	src/network/network_content.cpp
#	src/newgrf.cpp
#	src/newgrf_roadstop.cpp
#	src/os/windows/string_uniscribe.h
#	src/os/windows/win32.cpp
#	src/rail_gui.cpp
#	src/road.cpp
#	src/road_gui.cpp
#	src/settings.cpp
#	src/settings_gui.cpp
#	src/smallmap_gui.cpp
#	src/strings.cpp
#	src/terraform_gui.cpp
#	src/tests/test_script_admin.cpp
#	src/tests/test_window_desc.cpp
#	src/timer/timer_game_calendar.h
#	src/vehicle.cpp
#	src/vehicle_base.h
#	src/viewport.cpp
#	src/widget_type.h
#	src/window.cpp
#	src/window_gui.h
This commit is contained in:
Jonathan G Rennison
2023-11-29 20:32:54 +00:00
154 changed files with 1094 additions and 798 deletions

View File

@@ -260,18 +260,8 @@ static void LoadSpriteTables()
ClrBit(master->flags, GCF_INIT_ONLY);
/* Baseset extra graphics */
GRFConfig *extra = new GRFConfig(used_set->files[GFT_EXTRA].filename.c_str());
/* We know the palette of the base set, so if the base NewGRF is not
* setting one, use the palette of the base set and not the global
* one which might be the wrong palette for this base NewGRF.
* The value set here might be overridden via action14 later. */
switch (used_set->palette) {
case PAL_DOS: extra->palette |= GRFP_GRF_DOS; break;
case PAL_WINDOWS: extra->palette |= GRFP_GRF_WINDOWS; break;
default: break;
}
FillGRFDetails(extra, false, BASESET_DIR);
GRFConfig *extra = new GRFConfig(used_set->GetOrCreateExtraConfig());
if (extra->num_params == 0) extra->SetParameterDefaults();
ClrBit(extra->flags, GCF_INIT_ONLY);
extra->next = top;
@@ -546,6 +536,17 @@ void GfxLoadSprites()
DEBUG(sprite, 2, "Completed loading sprite set %d", _settings_game.game_creation.landscape);
}
GraphicsSet::GraphicsSet()
: BaseSet<GraphicsSet, MAX_GFT, true>{}, palette{}, blitter{}
{
// instantiate here, because unique_ptr needs a complete type
}
GraphicsSet::~GraphicsSet()
{
// instantiate here, because unique_ptr needs a complete type
}
bool GraphicsSet::FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename)
{
bool ret = this->BaseSet<GraphicsSet, MAX_GFT, true>::FillSetDetails(ini, path, full_filename, false);
@@ -564,6 +565,46 @@ bool GraphicsSet::FillSetDetails(const IniFile &ini, const std::string &path, co
return ret;
}
/**
* Return configuration for the extra GRF, or lazily create it.
* @return NewGRF configuration
*/
GRFConfig &GraphicsSet::GetOrCreateExtraConfig() const
{
if (!this->extra_cfg) {
this->extra_cfg.reset(new GRFConfig(this->files[GFT_EXTRA].filename));
/* We know the palette of the base set, so if the base NewGRF is not
* setting one, use the palette of the base set and not the global
* one which might be the wrong palette for this base NewGRF.
* The value set here might be overridden via action14 later. */
switch (this->palette) {
case PAL_DOS: this->extra_cfg->palette |= GRFP_GRF_DOS; break;
case PAL_WINDOWS: this->extra_cfg->palette |= GRFP_GRF_WINDOWS; break;
default: break;
}
FillGRFDetails(this->extra_cfg.get(), false, BASESET_DIR);
}
return *this->extra_cfg;
}
bool GraphicsSet::IsConfigurable() const
{
const GRFConfig &cfg = this->GetOrCreateExtraConfig();
/* This check is more strict than the one for NewGRF Settings.
* There are no legacy basesets with parameters, but without Action14 */
return !cfg.param_info.empty();
}
void GraphicsSet::CopyCompatibleConfig(const GraphicsSet &src)
{
const GRFConfig *src_cfg = src.GetExtraConfig();
if (src_cfg == nullptr || src_cfg->num_params == 0) return;
GRFConfig &dest_cfg = this->GetOrCreateExtraConfig();
if (dest_cfg.IsCompatible(src_cfg->version)) return;
dest_cfg.CopyParams(*src_cfg);
}
/**
* Calculate and check the MD5 hash of the supplied GRF.
* @param file The file get the hash of.