Patch: Found a town [In trunk: r18281]

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Patch: Found a town [In trunk: r18281]

Post by Terkhen »

Since r18281, Found a town is in trunk.

---------------------------------------------------------------

After getting interested in this patch because of its usefulness for future projects, I checked the patch original thread to see its status. I was surprised to find a version made by belugas and corrected by Roujin that was ignored by the people who was updating the patch to trunk (I was not surprised to see their understandable disappointment), even when it was clearly the version most close to trunk inclusion. Then I decided to get *that* version working in current trunk, add any missing features the patch needed, correct any bugs and reopen the debate about all points that belugas and Roujin already mentioned back then. I have opened a new thread to prevent any further confusions with the old-but-updated version.

The hard part was done back then: allow transport companies to found new towns ingame. But that's not enough: there is a lot of decisions to make, details to polish and finally test it in real games. I can implement the features and mantain the patch, but I need your help for everything else. I'm expecting your feedback and opinions!

List of points to debate
  • What should be the price for founding a town?. Right now the prize is 1 875 000, as I found it big enough for new towns.
  • What features is the patch missing?. If you think that something important (but only features strictly related to founding towns) is missing, please post your ideas!.
Version history
  • v15-r17654: Code changes only. Update to current trunk.
  • v14-r17558: Don't allow to build a town if the "allow towns to build roads" setting is off and there are no roads available nearby. Now towns are not populated when they are built: only the foundations of the town buildings are placed, and the town will slowly get population when each building is finished.
  • v13-r17460: Update to economy changes in trunk.
  • v12-r17295: Code for the toolbar GUI simplified (SmatZ). Setting renamed and placed with economy settings. Renaming implementation removed.
  • v11-r17288: More code changes and coding style corrections.
  • v10-r17285: Some code changes, corrections and optimizations.
  • v09-r17260: In multiplayer, allow the company that founded a town to change its name. The server still can change all town names. SAVEGAMES MAY BE INCOMPATIBLE WITH PREVIOUS VERSIONS.
  • v08-r17143:
    • String names reworked to match trunk style.
    • Coding style corrections.
    • Checked NewGRF compatibility of the added base cost. (See NewGRF provided)
  • v07-r16958:
    • Corrected a bug where you could still found towns after disabling their option if you had the found town window opened. Now the window closes when the option is disabled and the game is not at the scenario editor.
    • Reduced the cost of building towns (1.875.000 pounds). After some testing games, I found this cost big enough for new towns. Just my personal opinion, though.
    • The title of the found town window changes when ingame.
    • Showing the cost of building a town in the GUI is back, implementing the DrawWidget function. As with the old GUI, the window is redrawn when inflation changes (actually the code was still there :D).
    • The GUI code have been remade to use UpdateWidgetSize to hide widgets conditionally, instead of a construction function called at the NWidgetPart array. As a result, the GUI code is much cleaner and understandable. Thanks again, Alberth!
    • Minor STR naming corrections.
  • v06-r16871: A real GUI is implemented again.
  • v05-r16708: Corrected an unchecked use of _current_company. Update of version_number.
  • v04-r16679: Added a network-safe news page for town founding.
  • v03-r16671: Update to current trunk. Trunk now generates town names in the same way than the original patch did (passing town name parts as a parameter) so that part of the patch was removed. The original GUI was removed and needs to be remade. As a result of trunk allowing towns with different layouts in the same game, now the player can decide the road layout of a town before founding it. The setting for this feature now appears at Economy -> Towns. There were a lot of small changes to the code, and I had to move some parts between files as the result of some reorganizations in trunk.
  • v02-r14536 (by Roujin): Invenville town name issue solved. Changed the behaviour of the patch to allow founding only small towns. Their actual size is somewhere between normal "Small" and "Medium" sized towns. Made the command non-offline only.
  • v01-r14536 (by belugas): Compared to other versions of founding town patches, it has these advantages: The CreateTownName has been used out of the command handler, making it more network safe. The price of town's funding is now assigned to a new member of the price array. This means that it will now be linked to inflation, something you can verify by letting the window opened around end of month. A few code-style changes have been applied.
Flyspray task: #3142
Attachments
found_town_v15-r18203.diff
Latest version of the old patch.
(17.25 KiB) Downloaded 138 times
Last edited by Terkhen on 24 Nov 2009 22:27, edited 25 times in total.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Found a town [v3-r16671]

Post by Alberth »

Terkhen wrote:What is correct, "funding a town" or "founding a town"?. I'm almost sure that it is "founding" but I'd prefer to know for sure.
Both, in some sense.
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Found a town [v3-r16671]

Post by CommanderZ »

After founding, the company will have exclusive rights at the town for the normal duration. What to do if the exclusive rights setting is disabled?
Just don't give the exclusive rights :)
Eddi
Tycoon
Tycoon
Posts: 8273
Joined: 17 Jan 2007 00:14

Re: Found a town [v3-r16671]

Post by Eddi »

i'm not sure if the patch already does this, but it seems natural that the town would build a statue of its founder. price should be somewhere in the range of primary industries.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Found a town [v3-r16671]

Post by Terkhen »

Mmm... "Fund a new town" would be a good name, then?

CommanderZ: I forgot to add to that sentence that I wanted to discuss the possibility of giving 6 months of exclusive rights even if they are off. But maybe what Eddi suggests is more appropriate.
Eddi
Tycoon
Tycoon
Posts: 8273
Joined: 17 Jan 2007 00:14

Re: Found a town [v3-r16671]

Post by Eddi »

i'd go with found, it seems more appropriate
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Found a town [v3-r16671]

Post by Alberth »

To avoid confusion about ownership of the town, 'found' may be better.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Found a town [v3-r16671]

Post by Roujin »

Personally, I like "found" better, but you can already "fund" industries, so consistency with that may be an argument...
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Found a town [v3-r16671]

Post by Rubidium »

How does "Fund the town foundation" sound?
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Found a town [v3-r16671]

Post by Roujin »

Rubidium wrote:How does "Fund the town foundation" sound?
ahaha :lol: wait, you're serious? :shock:

it sounds like you'd only fund the stuff the buildings are built on top. = the foundation
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
SirXavius
Transport Coordinator
Transport Coordinator
Posts: 302
Joined: 28 Jun 2006 18:25
Location: Florida

Re: Found a town [v3-r16671]

Post by SirXavius »

I always wanted to try the old patch, but never got around to trying the build that someone posted. (I'd RATHER see new towns sprout up randomly but that's for another thread. :wink: )

If a player can basically create a town in-game, what impact does that have on existing industries? The only advantages i can see a player having is that it allows for more industries on the map (at least in that area), and another source of income for passenger/tourist transport. Of course, exclusive rights, even if temporary, can give an advantage in MP games, so it must be VERY expensive for balance issues. Another balance might be that the town always starts out small -- a few streets and a few houses, no out-of-the-box delivery of goods or food (altho as Eddi suggested, a commemorative statue would be in order :) ).

I'm interested what criteria will be used to determine WHERE a player can place the town -- the same as the scenario editor? I'm sure there would be in-game matters to consider, such as whether to place it on an existing road/rail line (that the player owns) or not (in the middle of nowhere), or proximity to existing industries.

Perhaps later we can include such features as (just jotting while i'm thinking about it :wink: ):

1. The selling of one's exclusive rights
2. A discount on bribes or perpetual good relations with the player's company.
3. The inability for a rival player or AI to Fund Road Construction in a player's own town.
4. The player who founds it must maintain it, or be levied a perpetual or temporary municipal tax (or some other gameplay balance).
5. Option for the player to build his own roads for his town.

You do very good work, Terkhen, so i look forward to your try at this concept. 8)
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Found a town [v4-r16679]

Post by Terkhen »

New update.

v4-r16679: Added a network-safe news page for town founding.

After trying to understand your dialogue about using "fund" or "found", the part of my brain in charge of english went offline :D. I'll just change the name when you reach a conclusion as I cannot help much with that.

SirXavius: The town always starts small, so you cannot use it as a goods dumping place. Right now the town can be placed anywhere. A check against near industries that cannot be placed near towns should be done. If the scenario editor already does this it will be easy. If not a separate patch that implements that behaviour for trunk should be in order. I'll have a look at this. About the rest of restrictions to where to place a town, I'll test what happens if you found a town over existing roads.

About your suggestions: the player just gives funds for a new town, but he does not have any special privileges over it (besides maybe exclusive rights or a statue). This is the same behaviour as with industries.
Timmaexx
Transport Coordinator
Transport Coordinator
Posts: 301
Joined: 03 Jan 2009 17:55

Re: Found a town [v4-r16679]

Post by Timmaexx »

Nice to see this Patch renewed!
The Josh would be happy!

One Question:
Could you create an option which determines how many cities per player may be created?
So there will not be an overflooding of Towns in MP...
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Found a town [v4-r16679]

Post by Terkhen »

Since there's no such control for building anything else in OpenTTD and I am just aiming for simple (yet complete) functionality to get this patch as close to trunk inclusion as possible, there's no need to implement that feature right now. Maybe when (and if :? ) the patch is tested we find that funding new towns needs special restrictions due to some kind of abuse.
Tanoh
Engineer
Engineer
Posts: 14
Joined: 26 Sep 2008 14:37

Re: Found a town [v4-r16679]

Post by Tanoh »

Very nice to see that someone else thinks the ability to build new towns is good. :)

I wrote one of the earlier revisions and gave up due to lack of time and finding any information about multiplayer. Have you tried this in multiplayer?
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Found a town [v4-r16679]

Post by Terkhen »

Tanoh: As I posted in the introduction, I only did simple tests. That proves that the town building itself is network secure, but we can't be sure if it lets the game in a insecure state until some serious testing in multiplayer is done.

Right now I discovered that the game crashes whenever you try to build a town with the scenario editor. Since I left such an obvious bug slip and I had no feedback about testing, I am going to test everything more throroughly. Expect a corrected v5 when I am done.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Found a town [v4-r16679]

Post by Terkhen »

New version.

v5-r16708: Corrected an unchecked use of _current_company. Update of version_number.

Now it seems to be bug-free. It still needs some serious network checking, though. I ran some tests with new houses GRFs and the patch worked fine with them. Can anyone point me to a GRFs which have industries that must be built far from towns?. I only was able to find GRF with industries that must be built near towns.

Next thing I'll do when I have some free time is to remake the GUI.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Found a town [v5-r16708]

Post by Roujin »

I think the farms in George's ECS implementation are supposed to close down if near to a town. At least I read so somewhere else in the forums..
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Found a town [v5-r16708]

Post by Terkhen »

Thank you, Roujin. Now i was able to continue doing tests.

It seems that checking distance between industries and towns is only done when placing industries. I had no problems placing a town next to a ECS farm in the scenario editor (using clean trunk) so it seems that this issue don't have to be checked when creating towns. Anyways, probably it is too costly to check all close industries when placing a town. Or maybe the check is missing from trunk?
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Found a town [v5-r16708]

Post by Terkhen »

I have been trying to hide the unneeded buttons of the found town window when the command is being used instead of disabling them, but no matter how I try to do it (after looking at all the places of the code where a widget is made hidden), I always get the same assertion:

Code: Select all

Reason: Assertion failed at c:\users\terkhen\desktop\mis cosas\openttd\compilar\town\src\window_gui.h:323:
widget_index < this->widget_count
I have tried a lot of variants, but right now my code (placed in the FoundTownWindow constructor) is:

Code: Select all

found_town = _game_mode != GM_EDITOR;

if (found_town) {
	this->HideWidget(TSEW_RANDOMTOWN);
	this->widget[TSEW_MANYRANDOMTOWNS].left = this->widget[TSEW_RANDOMTOWN].left;
} else {
	/* Both are visible, adjust the size of each */
	ResizeButtons(this, TSEW_RANDOMTOWN, TSEW_MANYRANDOMTOWNS);
}

this->FindWindowPlacementAndResize(desc);

this->UpdateButtons();

I know I am missing some key part of the required code for hiding widgets (or doing it all completely wrong), but I can't find what. Can anyone point me in the right direction?
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 5 guests