Merge branch 'master' into jgrpp-beta

# Conflicts:
#	.github/workflows/commit-checker.yml
#	src/company_cmd.cpp
#	src/console_cmds.cpp
#	src/crashlog.cpp
#	src/lang/english.txt
#	src/lang/german.txt
#	src/lang/indonesian.txt
#	src/lang/japanese.txt
#	src/lang/korean.txt
#	src/lang/swedish.txt
#	src/linkgraph/linkgraphjob.cpp
#	src/linkgraph/mcf.cpp
#	src/network/core/tcp.cpp
#	src/network/core/tcp.h
#	src/network/core/tcp_game.h
#	src/network/core/udp.h
#	src/network/network.cpp
#	src/network/network_admin.cpp
#	src/network/network_admin.h
#	src/network/network_chat_gui.cpp
#	src/network/network_client.cpp
#	src/network/network_client.h
#	src/network/network_func.h
#	src/network/network_internal.h
#	src/network/network_server.cpp
#	src/network/network_server.h
#	src/newgrf.cpp
#	src/newgrf_station.cpp
#	src/order_gui.cpp
#	src/rail_cmd.cpp
#	src/saveload/saveload.cpp
#	src/settings.cpp
#	src/settings_gui.cpp
#	src/settings_internal.h
#	src/settings_type.h
#	src/station_cmd.cpp
#	src/stdafx.h
#	src/table/currency_settings.ini
#	src/table/misc_settings.ini
#	src/table/settings.h.preamble
#	src/table/settings.ini
#	src/terraform_cmd.cpp
#	src/timetable_gui.cpp
#	src/train_cmd.cpp
#	src/tree_cmd.cpp
#	src/water_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2021-09-27 22:47:13 +01:00
204 changed files with 1829 additions and 1549 deletions

View File

@@ -36,7 +36,7 @@ static NetworkClientInfo *FindClientInfo(ScriptClient::ClientID client)
{
NetworkClientInfo *ci = FindClientInfo(client);
if (ci == nullptr) return nullptr;
return stredup(ci->client_name);
return stredup(ci->client_name.c_str());
}
/* static */ ScriptCompany::CompanyID ScriptClient::GetCompany(ScriptClient::ClientID client)

View File

@@ -54,7 +54,7 @@
seprintf(log_message, lastof(log_message), "Break: %s", message);
ScriptLog::Log(ScriptLog::LOG_SQ_ERROR, log_message);
/* Inform script developer that his script has been paused and
/* Inform script developer that their script has been paused and
* needs manual action to continue. */
ShowAIDebugWindow(ScriptObject::GetRootCompany());

View File

@@ -17,17 +17,15 @@
/* static */ bool ScriptGameSettings::IsValid(const char *setting)
{
uint i;
const SettingDesc *sd = GetSettingFromName(setting, &i);
return sd != nullptr && sd->desc.cmd != SDT_STRING;
const SettingDesc *sd = GetSettingFromName(setting);
return sd != nullptr && sd->desc.cmd != SDT_STDSTRING;
}
/* static */ int32 ScriptGameSettings::GetValue(const char *setting)
{
if (!IsValid(setting)) return -1;
uint index;
const SettingDesc *sd = GetSettingFromName(setting, &index);
const SettingDesc *sd = GetSettingFromName(setting);
void *ptr = GetVariableAddress(&_settings_game, &sd->save);
if (sd->desc.cmd == SDT_BOOLX) return *(bool*)ptr;
@@ -39,13 +37,12 @@
{
if (!IsValid(setting)) return false;
uint index;
const SettingDesc *sd = GetSettingFromName(setting, &index);
const SettingDesc *sd = GetSettingFromName(setting);
if ((sd->save.conv & SLF_NO_NETWORK_SYNC) != 0) return false;
if (sd->desc.cmd != SDT_BOOLX && sd->desc.cmd != SDT_NUMX) return false;
return ScriptObject::DoCommand(0, index, value, CMD_CHANGE_SETTING);
return ScriptObject::DoCommand(0, GetSettingIndex(sd), value, CMD_CHANGE_SETTING);
}
/* static */ bool ScriptGameSettings::IsDisabledVehicleType(ScriptVehicle::VehicleType vehicle_type)

View File

@@ -372,7 +372,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
IncreaseDoCommandCosts(res.GetCost());
/* Suspend the script player for 1+ ticks, so it simulates multiplayer. This
* both avoids confusion when a developer launched his script in a
* both avoids confusion when a developer launched the script in a
* multiplayer game, but also gives time for the GUI and human player
* to interact with the game. */
throw Script_Suspend(GetDoCommandDelay(), callback);

View File

@@ -34,7 +34,9 @@ public:
class ScriptWaypointList_Vehicle : public ScriptList {
public:
/**
* @param vehicle_id The vehicle to get the list of waypoints he has in its orders from.
* Get the waypoints from the orders of the given vehicle. Duplicates are
* not added. Waypoints are added in the order of the vehicle's orders.
* @param vehicle_id The vehicle to get the list of waypoints for.
*/
ScriptWaypointList_Vehicle(VehicleID vehicle_id);
};

View File

@@ -179,9 +179,9 @@ int ScriptConfig::GetVersion() const
return this->version;
}
void ScriptConfig::StringToSettings(const char *value)
void ScriptConfig::StringToSettings(const std::string &value)
{
char *value_copy = stredup(value);
char *value_copy = stredup(value.c_str());
char *s = value_copy;
while (s != nullptr) {
@@ -205,8 +205,10 @@ void ScriptConfig::StringToSettings(const char *value)
free(value_copy);
}
void ScriptConfig::SettingsToString(char *string, const char *last) const
std::string ScriptConfig::SettingsToString() const
{
char string[1024];
char *last = lastof(string);
char *s = string;
*s = '\0';
for (const auto &item : this->settings) {
@@ -216,7 +218,7 @@ void ScriptConfig::SettingsToString(char *string, const char *last) const
/* Check if the string would fit in the destination */
size_t needed_size = strlen(item.first) + 1 + strlen(no);
/* If it doesn't fit, skip the next settings */
if (string + needed_size > last) break;
if (s + needed_size > last) break;
s = strecat(s, item.first, last);
s = strecat(s, "=", last);
@@ -226,6 +228,8 @@ void ScriptConfig::SettingsToString(char *string, const char *last) const
/* Remove the last ',', but only if at least one setting was saved. */
if (s != string) s[-1] = '\0';
return string;
}
const char *ScriptConfig::GetTextfile(TextfileType type, CompanyID slot) const

View File

@@ -116,7 +116,7 @@ public:
void AnchorUnchangeableSettings();
/**
* Get the value of a setting for this config. It might fallback to his
* Get the value of a setting for this config. It might fallback to its
* 'info' to find the default value (if not set or if not-custom difficulty
* level).
* @return The (default) value of the setting, or -1 if the setting was not
@@ -169,13 +169,13 @@ public:
* Convert a string which is stored in the config file or savegames to
* custom settings of this Script.
*/
void StringToSettings(const char *value);
void StringToSettings(const std::string &value);
/**
* Convert the custom settings to a string that can be stored in the config
* file or savegames.
*/
void SettingsToString(char *string, const char *last) const;
std::string SettingsToString() const;
/**
* Search a textfile file next to this script.

View File

@@ -15,7 +15,7 @@
#include "../safeguards.h"
/* The reason this exists in C++, is that a user can trash his ai/ or game/ dir,
/* The reason this exists in C++, is that a user can trash their ai/ or game/ dir,
* leaving no Scripts available. The complexity to solve this is insane, and
* therefore the alternative is used, and make sure there is always a Script
* available, no matter what the situation is. By defining it in C++, there

View File

@@ -55,7 +55,7 @@ public:
virtual class ScriptInfo *FindLibrary(const char *library, int version) = 0;
/**
* A script in multiplayer waits for the server to handle his DoCommand.
* A script in multiplayer waits for the server to handle its DoCommand.
* It keeps waiting for this until this function is called.
*/
void Continue();