summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/company_cmd.cpp6
-rw-r--r--src/genworld_gui.cpp2
-rw-r--r--src/settings.cpp13
-rw-r--r--src/settings_func.h1
4 files changed, 16 insertions, 6 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 06948ee6c..58ff40a97 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -436,11 +436,7 @@ Company *DoStartupNewCompany(bool is_ai)
c->inaugurated_year = _cur_year;
RandomCompanyManagerFaceBits(c->face, (GenderEthnicity)Random(), false); // create a random company manager face
- /* Settings for non-ai companies are copied from the client settings later. */
- if (is_ai) {
- c->settings.engine_renew_money = 100000;
- c->settings.engine_renew_months = 6;
- }
+ SetDefaultCompanySettings(c->index);
GeneratePresidentName(c);
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index dd5993892..379ec8fa4 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -7,7 +7,6 @@
#include "heightmap.h"
#include "gui.h"
#include "variables.h"
-#include "settings_func.h"
#include "debug.h"
#include "genworld.h"
#include "network/network.h"
@@ -27,6 +26,7 @@
#include "querystring_gui.h"
#include "town.h"
#include "thread.h"
+#include "settings_func.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/settings.cpp b/src/settings.cpp
index ad0ac1de3..af99588e7 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1508,6 +1508,19 @@ void SetCompanySetting(uint index, int32 value)
}
/**
+ * Set the company settings for a new company to their default values.
+ */
+void SetDefaultCompanySettings(CompanyID cid)
+{
+ Company *c = Company::Get(cid);
+ const SettingDesc *sd;
+ for (sd = _company_settings; sd->save.cmd != SL_END; sd++) {
+ void *var = GetVariableAddress(&c->settings, &sd->save);
+ Write_ValidateSetting(var, sd, (int32)sd->desc.def);
+ }
+}
+
+/**
* Sync all company settings in a multiplayer game.
*/
void SyncCompanySettings()
diff --git a/src/settings_func.h b/src/settings_func.h
index f1824fd7a..e04038ef7 100644
--- a/src/settings_func.h
+++ b/src/settings_func.h
@@ -27,5 +27,6 @@ void DeleteGRFPresetFromConfig(const char *config_name);
uint GetCompanySettingIndex(const char *name);
void SyncCompanySettings();
+void SetDefaultCompanySettings(CompanyID cid);
#endif /* SETTINGS_FUNC_H */