Merge branch 'master' into jgrpp
# Conflicts: # CMakeLists.txt # src/3rdparty/md5/md5.h # src/3rdparty/squirrel/squirrel/squtils.h # src/animated_tile.cpp # src/console_func.h # src/core/CMakeLists.txt # src/core/container_func.hpp # src/core/smallstack_type.hpp # src/crashlog.cpp # src/crashlog.h # src/debug.h # src/economy.cpp # src/gamelog.cpp # src/industry_gui.cpp # src/lang/catalan.txt # src/misc_gui.cpp # src/network/network_content.h # src/newgrf.cpp # src/newgrf.h # src/newgrf_config.cpp # src/newgrf_config.h # src/newgrf_gui.cpp # src/os/unix/font_unix.cpp # src/os/windows/crashlog_win.cpp # src/rail_cmd.cpp # src/saveload/animated_tile_sl.cpp # src/script/api/script_tilelist.cpp # src/settings.cpp # src/settingsgen/settingsgen.cpp # src/sl/oldloader_sl.cpp # src/station.cpp # src/station_cmd.cpp # src/stdafx.h # src/strgen/strgen.cpp # src/strgen/strgen_base.cpp # src/table/settings/gui_settings.ini # src/train_gui.cpp # src/vehicle.cpp # src/vehicle_base.h # src/vehicle_cmd.cpp # src/vehicle_gui_base.h # src/viewport_sprite_sorter.h
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "newgrf_internal.h"
|
||||
#include "core/container_func.hpp"
|
||||
#include "debug.h"
|
||||
#include "fileio_func.h"
|
||||
#include "engine_func.h"
|
||||
@@ -8092,7 +8093,7 @@ static void GRFLoadError(ByteReader *buf)
|
||||
}
|
||||
|
||||
/* Only two parameter numbers can be used in the string. */
|
||||
for (uint i = 0; i < lengthof(error->param_value) && buf->HasData(); i++) {
|
||||
for (uint i = 0; i < error->param_value.size() && buf->HasData(); i++) {
|
||||
uint param_number = buf->ReadByte();
|
||||
error->param_value[i] = _cur.grffile->GetParam(param_number);
|
||||
}
|
||||
@@ -8992,7 +8993,7 @@ static bool ChangeGRFNumUsedParams(size_t len, ByteReader *buf)
|
||||
grfmsg(2, "StaticGRFInfo: expected only 1 byte for 'INFO'->'NPAR' but got " PRINTF_SIZE ", ignoring this field", len);
|
||||
buf->Skip(len);
|
||||
} else {
|
||||
_cur.grfconfig->num_valid_params = std::min<byte>(buf->ReadByte(), lengthof(_cur.grfconfig->param));
|
||||
_cur.grfconfig->num_valid_params = std::min(buf->ReadByte(), ClampTo<uint8_t>(_cur.grfconfig->param.size()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -9141,7 +9142,7 @@ static bool ChangeGRFParamMask(size_t len, ByteReader *buf)
|
||||
buf->Skip(len);
|
||||
} else {
|
||||
byte param_nr = buf->ReadByte();
|
||||
if (param_nr >= lengthof(_cur.grfconfig->param)) {
|
||||
if (param_nr >= _cur.grfconfig->param.size()) {
|
||||
grfmsg(2, "StaticGRFInfo: invalid parameter number in 'INFO'->'PARA'->'MASK', param %d, ignoring this field", param_nr);
|
||||
buf->Skip(len - 1);
|
||||
} else {
|
||||
@@ -9338,10 +9339,10 @@ static bool HandleParameterInfo(ByteReader *buf)
|
||||
if (id >= _cur.grfconfig->param_info.size()) {
|
||||
_cur.grfconfig->param_info.resize(id + 1);
|
||||
}
|
||||
if (_cur.grfconfig->param_info[id] == nullptr) {
|
||||
_cur.grfconfig->param_info[id] = new GRFParameterInfo(id);
|
||||
if (!_cur.grfconfig->param_info[id].has_value()) {
|
||||
_cur.grfconfig->param_info[id] = GRFParameterInfo(id);
|
||||
}
|
||||
_cur_parameter = _cur.grfconfig->param_info[id];
|
||||
_cur_parameter = &_cur.grfconfig->param_info[id].value();
|
||||
/* Read all parameter-data and process each node. */
|
||||
if (!HandleNodes(buf, _tags_parameters)) return false;
|
||||
type = buf->ReadByte();
|
||||
@@ -10570,13 +10571,8 @@ GRFFile::GRFFile(const GRFConfig *config)
|
||||
|
||||
/* Copy the initial parameter list
|
||||
* 'Uninitialised' parameters are zeroed as that is their default value when dynamically creating them. */
|
||||
static_assert(lengthof(this->param) == lengthof(config->param) && lengthof(this->param) == 0x80);
|
||||
|
||||
assert(config->num_params <= lengthof(config->param));
|
||||
this->param = config->param;
|
||||
this->param_end = config->num_params;
|
||||
if (this->param_end > 0) {
|
||||
MemCpyT(this->param, config->param, this->param_end);
|
||||
}
|
||||
}
|
||||
|
||||
GRFFile::~GRFFile()
|
||||
|
Reference in New Issue
Block a user