Merge branch 'master' into jgrpp

# Conflicts:
#	src/saveload/cargopacket_sl.cpp
#	src/saveload/saveload.h
#	src/strings.cpp
#	src/vehicle.cpp
This commit is contained in:
Jonathan G Rennison
2023-04-12 20:02:57 +01:00
26 changed files with 659 additions and 117 deletions

View File

@@ -37,6 +37,7 @@
#include "game/game_text.hpp"
#include "network/network_content_gui.h"
#include "newgrf_engine.h"
#include "core/backup_type.hpp"
#include "core/y_combinator.hpp"
#include <stack>
@@ -1812,7 +1813,11 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Industry *i = Industry::GetIfValid(args->GetInt32(SCC_INDUSTRY_NAME));
if (i == nullptr) break;
if (_scan_for_gender_data) {
static bool use_cache = true;
if (use_cache) { // Use cached version if first call
AutoRestoreBackup cache_backup(use_cache, false);
buff = strecpy(buff, i->GetCachedName(), last);
} else if (_scan_for_gender_data) {
/* Gender is defined by the industry type.
* STR_FORMAT_INDUSTRY_NAME may have the town first, so it would result in the gender of the town name */
StringParameters tmp_params(nullptr, 0, nullptr);
@@ -1857,7 +1862,11 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
break;
}
if (!st->name.empty()) {
static bool use_cache = true;
if (use_cache) { // Use cached version if first call
AutoRestoreBackup cache_backup(use_cache, false);
buff = strecpy(buff, st->GetCachedName(), last);
} else if (!st->name.empty()) {
int64 args_array[] = {(int64)(size_t)st->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
@@ -1890,7 +1899,11 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Town *t = Town::GetIfValid(args->GetInt32(SCC_TOWN_NAME));
if (t == nullptr) break;
if (!t->name.empty()) {
static bool use_cache = true;
if (use_cache) { // Use cached version if first call
AutoRestoreBackup cache_backup(use_cache, false);
buff = strecpy(buff, t->GetCachedName(), last);
} else if (!t->name.empty()) {
int64 args_array[] = {(int64)(size_t)t->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);