Patch: Limit Town Growth
Moderator: OpenTTD Developers
Patch: Limit Town Growth
This is my first little patch to Open TTD. What it does is add a population limit to town growth. On the Economy page of the patch config you can set a value from 0 to 255 indicating the population limit of all towns. Setting this value to zero disables the limit. If the value was 1 towns with a population greater than 100 will not grow. If the value was 20, towns with a population greater than 2000 will not grow. However towns can grow past this value. Say for example a town has a population of 995, and the limit is set to 10 (1000 population.) then this town could grow. It might grow above 1000, but it will not grow again until its population shrinks down below 1000. The nice result is that the towns population continues to fluctuate and buildings decay and rebuild giving the town a nice dynamic feel despite the growth limit. This really wasn't what I intended when I started the patch, but because of the way the town grow code works, I think its a pretty pleasant side effect. Smaller towns that are below the population limit will continue to grow normally.
I have been testing this patch on revision 9867 of the trunk.
I have been testing this patch on revision 9867 of the trunk.
- Attachments
-
- Shows the patch config for limiting town growth.
- LimitTownGrowth.png (89.44 KiB) Viewed 8849 times
-
- Limit_Town_Size_r4.patch
- patch to limit town growth and move town patches to their own patch page.
- (6.33 KiB) Downloaded 304 times
Last edited by wleader on 09 Jun 2007 22:26, edited 2 times in total.
Check how to bump a savegame. Your patch will get problems with older savegames.
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
skidd13,
I think I see the problem, would you agree that
should be:
That would specify to sync with the network, save in openttd.cfg and do not save in the save game. Only trouble is that line does not compile. NS is not defined.
alternately after reading the wiki page again (which seems to be slightly out of date) that I could just resolve this by making a change to saveload.cpp?:
I think I see the problem, would you agree that
Code: Select all
SDT_VAR(Patches, town_size_limit, SLE_UINT8, 0, NC, 0, 0, SL_MAX_VERSION, 1, STR_CONFIG_PATCHES_TOWN_SIZE_LIMIT, NULL),
Code: Select all
SDT_VAR(Patches, town_size_limit, SLE_UINT8, NS, NC, 0, 0, SL_MAX_VERSION, 1, STR_CONFIG_PATCHES_TOWN_SIZE_LIMIT, NULL),
alternately after reading the wiki page again (which seems to be slightly out of date) that I could just resolve this by making a change to saveload.cpp?:
Code: Select all
extern const uint16 SAVEGAME_VERSION = 59;
becomes
extern const uint16 SAVEGAME_VERSION = 60;
The saveload.cpp thing is right but you should use SDT_CONDVAR(...) from revision 60 (current SL_MAX_VERSION +1) to SL_MAX_VERSION.
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
Yeah, NS was removed as it causes desyncs (it didn't syncronise the value when you joined a game; only when you changed the setting). I didn't know it was in the wiki as well...wleader wrote:That would specify to sync with the network, save in openttd.cfg and do not save in the save game. Only trouble is that line does not compile. NS is not defined.
No-one's more important than the earthworm.
Looks fine now. If you wanna play a bit further with the code, try to add another tab in the patch_settings window and group the town settings together.
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
skidd13,
Your just trying to hook another developer.. But maybe your right. there does seem to be a lot of town related patches now, so re-organizing may be appropriate.
Acerbus,
While I have no doubt that this could be done, it would involve adding to the town structure, which I would expect would cause changes to loading and saving. Additionally there would have to be a change to the Town GUI too. For me, since I don't really know what I am doing yet, It seems like a lot of work for something I don't really see a benefit to gameplay. I think that manipulating these things directly for each city only lends itself to abuse.
However, I have been looking at the code and there is another patch for lager_towns that causes some towns to instead be 'cities' that grow faster. This already exists as a boolean value in a town, so I could use it to have a town size limit and a seperate city size limit.
The result would be that Some towns would grow faster with a different limit than others, but without any control over which towns grow faster and larger. This way with this patch enabled, some towns could still be larger than others and still have a population limit. Since this is so easy to do I might just try it out. But I have a concert to go to so I probably won't get a chance to put up a patch until tomorrow night.
Your just trying to hook another developer.. But maybe your right. there does seem to be a lot of town related patches now, so re-organizing may be appropriate.
Acerbus,
While I have no doubt that this could be done, it would involve adding to the town structure, which I would expect would cause changes to loading and saving. Additionally there would have to be a change to the Town GUI too. For me, since I don't really know what I am doing yet, It seems like a lot of work for something I don't really see a benefit to gameplay. I think that manipulating these things directly for each city only lends itself to abuse.
However, I have been looking at the code and there is another patch for lager_towns that causes some towns to instead be 'cities' that grow faster. This already exists as a boolean value in a town, so I could use it to have a town size limit and a seperate city size limit.
Code: Select all
uint32 pop_limit = t->larger_town ? (_patches.city_size_limit * 100) : (_patches.town_size_limit * 100);
if ((pop_limit != 0) && (t->population >= pop_limit)){
return false;
}
Nice work, but don't change the order of existing SDT_*VAR's, that will change the savegame. So change the positions only in settings_gui.cpp.
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
If you change the sequence of existing SDT_* stuff you change the savegame internaly (that would normaly break the savegame compatibility).
You can add SDT_COND* stuff everywhere cause it is limited to min and max revison (and so keep the savegame compatibility).
You can add SDT_COND* stuff everywhere cause it is limited to min and max revison (and so keep the savegame compatibility).
What does that mean - the circumstances? I determine what circumstances prevail. -- Napoleon Bonaparte
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
---
If we cannot end now our differences, at least we can help make the world safe for diversity. -- John F. Kennedy
---
Our problems are man-made, therefore they may be solved by man. No problem of human destiny is beyond human beings. -- John F. Kennedy
Who is online
Users browsing this forum: No registered users and 6 guests