Add cmresettowngrowth command to reset growth rate of all towns to normal

This commit is contained in:
dP
2021-02-07 21:17:32 +03:00
parent 440e42622e
commit 7e2ade139c
4 changed files with 26 additions and 0 deletions

View File

@@ -10,6 +10,7 @@
#include "../fileio_type.h"
#include "../map_type.h"
#include "../map_func.h"
#include "../town.h"
#include "../tree_map.h"
#include "../safeguards.h"
@@ -108,4 +109,23 @@ bool ConTreeMap(byte argc, char *argv[]) {
return true;
}
extern void (*UpdateTownGrowthRate)(Town *t);
bool ConResetTownGrowth(byte argc, char *argv[]) {
if (argc == 0) {
IConsoleHelp("Loads heighmap-like file and plants trees according to it, values 0-256 ore scaled to 0-4 trees.");
IConsoleHelp("Usage: 'cmtreemap <file>'");
IConsoleHelp("Default lookup path is in scenario/heightmap in your openttd directory");
return true;
}
if (argc > 1) return false;
for (Town *town : Town::Iterate()) {
ClrBit(town->flags, TOWN_CUSTOM_GROWTH);
UpdateTownGrowthRate(town);
}
return true;
}
} // namespace citymania

View File

@@ -6,6 +6,7 @@ namespace citymania {
bool ConStep(byte argc, char *argv[]);
bool ConExport(byte argc, char *argv[]);
bool ConTreeMap(byte argc, char *argv[]);
bool ConResetTownGrowth(byte argc, char *argv[]);
} // namespace citymania

View File

@@ -2214,4 +2214,5 @@ void IConsoleStdLibRegister()
IConsoleCmdRegister("cmstep", citymania::ConStep, ConHookNoNetwork);
IConsoleCmdRegister("cmexport", citymania::ConExport);
IConsoleCmdRegister("cmtreemap", citymania::ConTreeMap, ConHookNoNetwork);
IConsoleCmdRegister("cmresettowngrowth", citymania::ConResetTownGrowth, ConHookNoNetwork);
}

View File

@@ -4006,3 +4006,7 @@ void ResetHouses()
/* Reset any overrides that have been set. */
_house_mngr.ResetOverride();
}
namespace citymania {
auto UpdateTownGrowthRate = &::UpdateTownGrowthRate;
}