Merge branch 'master' into jgrpp

# Conflicts:
#	src/company_cmd.cpp
#	src/core/overflowsafe_type.hpp
#	src/economy.cpp
#	src/engine_base.h
#	src/ground_vehicle.cpp
#	src/group_gui.cpp
#	src/industry_cmd.cpp
#	src/industry_gui.cpp
#	src/newgrf_commons.cpp
#	src/newgrf_engine.cpp
#	src/newgrf_industries.cpp
#	src/newgrf_object.cpp
#	src/newgrf_roadstop.cpp
#	src/newgrf_station.cpp
#	src/rail_gui.cpp
#	src/road_cmd.h
#	src/road_gui.cpp
#	src/saveload/afterload.cpp
#	src/script/api/script_log.cpp
#	src/script/api/script_log.hpp
#	src/settings_gui.cpp
#	src/settingsgen/settingsgen.cpp
#	src/station_cmd.cpp
#	src/station_cmd.h
#	src/station_gui.cpp
#	src/strgen/strgen.cpp
#	src/string_func.h
#	src/string_type.h
#	src/table/settings/network_private_settings.ini
#	src/tests/math_func.cpp
#	src/textfile_gui.cpp
#	src/timetable_gui.cpp
#	src/town_cmd.cpp
#	src/vehicle.cpp
#	src/waypoint_cmd.cpp
#	src/waypoint_cmd.h
#	src/widgets/dropdown.cpp
This commit is contained in:
Jonathan G Rennison
2023-06-03 19:16:42 +01:00
101 changed files with 987 additions and 964 deletions

View File

@@ -35,7 +35,7 @@ void NORETURN CDECL error(const char *s, ...)
va_start(va, s);
vseprintf(buf, lastof(buf), s, va);
va_end(va);
fprintf(stderr, "FATAL: %s\n", buf);
fprintf(stderr, "settingsgen: FATAL: %s\n", buf);
exit(1);
}
@@ -72,7 +72,7 @@ public:
void Write(FILE *out_fp) const
{
if (fwrite(this->data, 1, this->size, out_fp) != this->size) {
fprintf(stderr, "Error: Cannot write output\n");
error("Cannot write output");
}
}
@@ -329,8 +329,7 @@ static void DumpSections(IniLoadFile *ifile)
IniItem *template_item = templates_grp->GetItem(grp->name, false); // Find template value.
if (template_item == nullptr || !template_item->value.has_value()) {
fprintf(stderr, "settingsgen: Warning: Cannot find template %s\n", grp->name.c_str());
continue;
error("Cannot find template %s", grp->name.c_str());
}
DumpLine(template_item, grp, default_grp, _stored_output);
@@ -354,8 +353,7 @@ static void CopyFile(const char *fname, FILE *out_fp)
FILE *in_fp = fopen(fname, "r");
if (in_fp == nullptr) {
fprintf(stderr, "settingsgen: Warning: Cannot open file %s for copying\n", fname);
return;
error("Cannot open file %s for copying", fname);
}
char buffer[4096];
@@ -363,8 +361,7 @@ static void CopyFile(const char *fname, FILE *out_fp)
do {
length = fread(buffer, 1, lengthof(buffer), in_fp);
if (fwrite(buffer, 1, length, out_fp) != length) {
fprintf(stderr, "Error: Cannot copy file\n");
break;
error("Cannot copy file");
}
} while (length == lengthof(buffer));
@@ -513,8 +510,7 @@ int CDECL main(int argc, char *argv[])
FILE *fp = fopen(tmp_output, "w");
if (fp == nullptr) {
fprintf(stderr, "settingsgen: Warning: Cannot open file %s\n", tmp_output);
return 1;
error("Cannot open file %s", tmp_output);
}
CopyFile(before_file, fp);
_stored_output.Write(fp);