Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch: Found new towns #2327

Closed
DorpsGek opened this issue Sep 29, 2008 · 16 comments
Closed

Patch: Found new towns #2327

DorpsGek opened this issue Sep 29, 2008 · 16 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

Tanoh opened the ticket and wrote:

Hello.

I posted this on the forums, but didn't get any feedback so figured I should try posting it here also. :>

This patch adds an option to allow construction of new towns. It's very expensive, but that's how it should be (imo). I have often thought about how silly it is that you can't build new towns. Rather than just be another user requesting a feature, I decided to use some of my spare time and investigate the code and see how it works and from there try it myself.

Features:
* An option if founding towns should be allowed or not.
* Ability to found three different sized towns, at different cost.
* Uses the same base GUI as the one in the scenary editor, though modified to suit us better (the old behaviour in scenary editor is of course unchanged)

Notes:
* The normal constraints to founding towns still apply, not too close to another, not too close to the borders, etc.
* You do not get any special status at all in the towns you fund, this is a design choice and very unlikely to change.
* This is my first patch, I'm following the coding standards I found on the wiki. Softer issues like what you shouldn't do with windows/widgets/etc might not be up to par with what is considered good practice. Especially the Town GUI is quite hm.. interesting. Maybe I should just have made a new window for it rather than reusing and resizing the one from scenary editor.

Known issues:
* Multiplayer is totaly untested, and possibly (read: probably) very buggy.

History:
2008-09-29: First version released.

Attachments

Reported version: 0.6.2
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/2327
@DorpsGek
Copy link
Member Author

Tanoh wrote:

Forgot to mention, patch is against rev "r14412M" fresh from SVN as of a few minutes ago. :>


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4795

@DorpsGek
Copy link
Member Author

SmatZ wrote:

#759 does the same (just to mention if anyone wants to compare those two patches)


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4796

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 5, 2008

batti5 wrote:

I tested it against r14440 and it work i did not find any bug, all its left is to get it in trunk.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4817

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 5, 2008

Tanoh wrote:

Did some inital multiplayer testing and it instantly disconnected me. I'm not sure how to go further and debug multiplayer (or even how multiplayer works.) Hmm.. probably the easiest solution would be to just not allow it in multiplayer until it's fixed.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4819

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 5, 2008

batti5 wrote:

Multyplay dose not work for nightlys from svn, and its normal you can only connect to servers or users if thej haw the patch tow.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4821

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 5, 2008

batti5 wrote:

Now i have updated from r14440 to r14442 whit r14440 patched, no problem at all.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4822

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 6, 2008

SmatZ wrote:

Hello, thanks for your effort. However, there are some problems:

nice you tried to have correct coding style, but:
if (a)
command; is wrong, missing { }

similiar should be
if (a) {
command;
} else {
command;
}

"(size+1)" is missing a space around +

(flyspray will probably break formatting / whitespaces)

Cost for funding new town is a strange constant, not affected by inflation. (try to use the _price variable)
Also, GetNewTownConstructionCost() should return Money or CommandCost (not int).

What I tested:
airport noise level won't cause any problem, st->town is used
roadside of player-built roads may change... not serious

Serious would be if it doesn't work in multiplayer...

You don't seem to check parameter validity in CmdBuildTown, at least p1 is not checked.
(price is computed from p1, but it is not affected by p2? when it is a city (has 't->larger_town==true'), it should be more expensive)
You may return non-zero CommandCost in the scenario editor (I think)

CreateTownName() may succeed in test run and fail in exec run, so it desyncs (and asserts the server).

Maybe there are further problems in coding style / logic... but fixing this is a good start :)

edit:
using Random() in CreateTownName() will desync, #759 handles that... in a way that each client will have different town name, causing problems and desyncs later.

I wonder how batti5 tested this patch when it desyncs upon first use...

(all of the above may be wrong, but I believe most of it is true... I didn't test it in multiplayer)


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4825

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 6, 2008

batti5 wrote:

i did int, multilayer wont connect at all for me , with or without this patch on nightly i compile, but i got all the dependencies specified at the ottd dev linux site.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4828

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 6, 2008

Tanoh wrote:

Hello. Thanks for the feedback.

New patch against r14442M.

ChangeLog:
* Fixed, hopefully all of, the coding style issues.
* GetNewTownConstructionCost now returns a CommandCost() and uses a _price, however not it's own (see notes below).
* Check the size of the town (p1) in CmdBuildTown.

Notes:
I really am a novice in OpenTTD coding. I tried to add a new _price but I wasn't succesful, it crashed left and right after I added a new and increased NUM_PRICES. Also none of the old saves worked and generally seemed quite unstable, so using "build_industry" at least for now instead.

As for network, as far as I can tell it works fine until you actually create a town. I was able to play against myself with two copies of openttd up, once I tried to build a town on either "server" or client I got instantly disconnected. ie, actually pressing the "Fund" button and having enough cash etc. I really have no clue how networking works in openttd. Any ideas where to start learning/debugging it? I looked at the wiki but not much info there.

Town mode should be looked into more, the same functions are used by the scenary editor to create (many) random towns. A lot of it is not needed, might be an idea to split it into a new function instead.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4829

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 6, 2008

batti5 wrote:

Hunk # 2 FAILED at 1536.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4830

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 6, 2008

batti5 wrote:

if patched with r14412 ver it cant be updated, only if you patch it against r14442


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4831

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 6, 2008

batti5 wrote:

This patch is compatible with distant_joint_station patch r14442M


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4832

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 6, 2008

Tanoh wrote:

Sorry, revision in openttd is a bit confusing for me. Thought you could look in src/rev.cpp and get it, but apparently not.

SVN says "14443" so assume it's the way to find it. :)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4834

@DorpsGek
Copy link
Member Author

DorpsGek commented Oct 6, 2008

Tanoh wrote:

edit: stupid reload.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4835

@DorpsGek
Copy link
Member Author

burty wrote:

checked against R14505 and diffed here

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327#comment4923

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 9, 2009

Rubidium closed the ticket.

Reason for closing: Duplicate

Of #3142


This comment was imported from FlySpray: https://bugs.openttd.org/task/2327

@DorpsGek DorpsGek closed this as completed Sep 9, 2009
@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant