How would I create Gamelogic with GSes AND NewGRFs?
Moderator: OpenTTD Developers
How would I create Gamelogic with GSes AND NewGRFs?
Hello, in my previous thread I figured out, that for what I intend to do (industry / city value change, custom triggers etc) probably requires a patch.
This seems like a daring endeavour, but I am willing to try.
One questions I have left after taking a look into the repository.
Would I be able to develop in C# and compile a working binary using Mono/dot Net? Or is there any method to create code in C# and get a working copy of openttd after compiling? Thanks!
This may be a very dumb question, some of you may cringe , but I want to know.
This seems like a daring endeavour, but I am willing to try.
One questions I have left after taking a look into the repository.
Would I be able to develop in C# and compile a working binary using Mono/dot Net? Or is there any method to create code in C# and get a working copy of openttd after compiling? Thanks!
This may be a very dumb question, some of you may cringe , but I want to know.
Last edited by Openend on 08 Jul 2015 10:00, edited 1 time in total.
Re: Converter / Mono usable for source modification?
No.
OpenTTD is in C++. While it might be possible to automatically convert it to C# (there are working demos of conversion to in-browser javascript) the output of tools like that tends to be rather unreadable by humans. You'd also be unable to create a standalone patch (reverse conversion would end up with almost every line being different), which would make updating against newer OTTD versions or applying other patches a case of rewriting the whole thing each time.
OpenTTD is in C++. While it might be possible to automatically convert it to C# (there are working demos of conversion to in-browser javascript) the output of tools like that tends to be rather unreadable by humans. You'd also be unable to create a standalone patch (reverse conversion would end up with almost every line being different), which would make updating against newer OTTD versions or applying other patches a case of rewriting the whole thing each time.
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
Re: Converter / Mono usable for source modification?
Well, that means I'll have to use c++?
Is there any sort of flow chart for the repository? I can understand the basic structure, but it would be very nice to have an overview, how the code is executed. Thanks anyway!
Is there any sort of flow chart for the repository? I can understand the basic structure, but it would be very nice to have an overview, how the code is executed. Thanks anyway!
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Converter / Mono usable for source modification?
Of course it means to use C/C++. Or can you write an English text in Chinese?Openend wrote:Well, that means I'll have to use c++?
Is there any sort of flow chart for the repository? I can understand the basic structure, but it would be very nice to have an overview, how the code is executed. Thanks anyway!
There is no flow chart. Start with openttd.cpp and continue from the main loop found within. Also make use of the doxygen documentation: http://docs.openttd.org/classGame.html
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Converter / Mono usable for source modification?
The "overview" concept is overrated probably, I'd start at files that look city-ish or industry-ish, and go from there.
Being a retired OpenTTD developer does not mean I know what I am doing.
Re: Converter / Mono usable for source modification?
depending on how sophisticated your IDE is, it could generate you a call graph or similar for you to navigate through
Re: Converter / Mono usable for source modification?
@planetmaker
Thanks for the warm welcome and the info provided!
At the moment I am really torn between digging into it, and developing a standalone (related, but no clone) game in Unity.
Thanks for the warm welcome and the info provided!
At the moment I am really torn between digging into it, and developing a standalone (related, but no clone) game in Unity.
Re: Converter / Mono usable for source modification?
OpenTTD is 300K+ lines, assuming you can do 20K / year, that will take 15 years. Maybe you can skip some functionality, but you'll soon need a decade or so if you know how to build a program like that at that scale.
Being a retired OpenTTD developer does not mean I know what I am doing.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Converter / Mono usable for source modification?
In order to add to Alberth's reasoning: the road to a functional game at this scale is very lengthy. On the other hand, if you know how to programme in any programming language, then programming in another is a comparatively small step. Most concepts stay the same, mostly only syntax varies slightly.Openend wrote:@planetmaker
Thanks for the warm welcome and the info provided!
At the moment I am really torn between digging into it, and developing a standalone (related, but no clone) game in Unity.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
-
- Route Supervisor
- Posts: 429
- Joined: 27 Mar 2013 08:58
- Location: Strumien
- Contact:
Re: Converter / Mono usable for source modification?
OpenTTD is 300k LOC but most of this code is implementing low level functionality, like blitters, sound and music drivers. I guess that effectively there is maybe 50k LOC that are used for the real game-logic. I've also found that OTTD code is not the best quality and could be optimized away, cutting another 10k of LOC.Alberth wrote:OpenTTD is 300K+ lines, assuming you can do 20K / year, that will take 15 years. Maybe you can skip some functionality, but you'll soon need a decade or so if you know how to build a program like that at that scale.
Another thing is that 20k LOC/year is 50 lines a day. That's pretty low. When I was actively programming, sometimes I've got from 200-300 LOC a day.
So your calculations are pretty bad and inaccurate.
Re: Converter / Mono usable for source modification?
Please point me to the 250K lines of driver stuff.lukasz1985 wrote:OpenTTD is 300k LOC but most of this code is implementing low level functionality, like blitters, sound and music drivers. I guess that effectively there is maybe 50k LOC that are used for the real game-logic.
The 300K lines is all in trunk/src, I didn't count SDL, and other libraries that we use.
Like you always write top-most quality in a language at all times. You will mess up in a program of this scale, and get less than optimal quality. It's not a problem, but claiming you will not at that complexity seems very unlikely to me.lukasz1985 wrote:I've also found that OTTD code is not the best quality and could be optimized away, cutting another 10k of LOC.
It's quite realistic, perhaps even optimistic, depending on how you are counting. In the about 4 years I am writing FreeRCT, I managed to produce around 80K lines, and deleted 30K lines again (this also includes changes in the lines, so not everything is deleting). So I have about 50K lines as a result after 4 years.lukasz1985 wrote:Another thing is that 20k LOC/year is 50 lines a day. That's pretty low. When I was actively programming, sometimes I've got from 200-300 LOC a day.
When you typing away, sure it's easy to produce a 1000 lines a day. But you cannot type 24/7. There is this thing called Real Life (work/study/parents/etc) so your time is the weekend alone mostly, also you need time to think about what to do next, debug your code, and take the occasional day off from it all.
Not so sure about that, but feel free to ignore my calculations, and proof prove me wrong. I'd be happy for you.lukasz1985 wrote:So your calculations are pretty bad and inaccurate.
In general though, people grossly underestimate the amount of effort and dedication that it takes to pull it off. FreeRCT isn't close to being playable after 4 years.
Edit: As another reference (thanks planetmaker): https://www.openhub.net/p/openttd claims even less lines / year than both you and me (241K reall code lines with 63 year of work according to the COCOMO model). My 300K lines is really everything, they probably skip comments and blank lines.
Being a retired OpenTTD developer does not mean I know what I am doing.
Re: Converter / Mono usable for source modification?
Well I am not talking about cloning the game. I would try to distill, what I really like in Openttd and recreate it in another context. This is still a large project for the two of us (hobbyists)
And I wouldnt have the build the engine.
But first Ill have another look at gamescripts. If there would only be a way to influence industries by using GSes....
And I wouldnt have the build the engine.
But first Ill have another look at gamescripts. If there would only be a way to influence industries by using GSes....
Re: Converter / Mono usable for source modification?
Maybe you should point out exactly (in your previous thread), which new features you want to achieve? That should help to show proper path.Openend wrote: But first Ill have another look at gamescripts. If there would only be a way to influence industries by using GSes....
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Re: Converter / Mono usable for source modification?
your calculation has a lot of flaws, but maybe let me point out these two major ones:lukasz1985 wrote:Another thing is that 20k LOC/year is 50 lines a day. That's pretty low. When I was actively programming, sometimes I've got from 200-300 LOC a day.
- if you're writing more than 10 lines per hour, you've not spent enough time thinking about how to solve the problem with as few lines as possible. programming is not a contest of who can write the most lines in the shortest time. a bad programmer can easily write 100 lines per hour. a good programmer writes 10 lines per hour doing the exact same stuff, but it probably runs 10 times faster and is maintainable in the future.
- you can't expect to work full time (8h/day) for a whole year on a hobby project
Re: Converter / Mono usable for source modification?
@mcZapkie
Edit: That was meant to be: Ill do it here because...I'll do it because
Last edited by Openend on 07 Jul 2015 21:39, edited 1 time in total.
Re: Converter / Mono usable for source modification?
OK, but more general - why you want to control it. What is a whole idea?Openend wrote:@mcZapkie
I'll do it because it is quite simple: I want to control the production of industries via Gamescript. From what I heard so far, it is not possible.
Re: Converter / Mono usable for source modification?
The basic idea is to reward the player (like in BusyBee) with City Growth and Industrial Growth when some conditions are fulfilled. City Growth should be no problem, but afaik you cannot influence industrial production from Gamescripts, or can you? Thanks a lot for your help, by the way
Re: Converter / Mono usable for source modification?
No you cannot.
The reason is that NewGRF specifications do not allow it. The only thing that OpenTTD can do within the specification is ask a NewGRF to open a new industry at some spot. If it doesn't like the spot or it doesn't like the terrain, you're out of luck.
You cannot ask the industry what terrain (shape) it wants.
Once created, industries themselves decide to increase or decrease production.
Once created, industries themselves decide whether or not to close.
You cannot inform industries of the world status. Something like "He, there are 54 of your kind, while the map chance indicates there should be only 28". You cannot ask an industry to close down.
Total control like you may want is even further away.
The reason is that NewGRF specifications do not allow it. The only thing that OpenTTD can do within the specification is ask a NewGRF to open a new industry at some spot. If it doesn't like the spot or it doesn't like the terrain, you're out of luck.
You cannot ask the industry what terrain (shape) it wants.
Once created, industries themselves decide to increase or decrease production.
Once created, industries themselves decide whether or not to close.
You cannot inform industries of the world status. Something like "He, there are 54 of your kind, while the map chance indicates there should be only 28". You cannot ask an industry to close down.
Total control like you may want is even further away.
Being a retired OpenTTD developer does not mean I know what I am doing.
Re: Converter / Mono usable for source modification?
Thank you for the information. Ive been told, that GSes cannot rely on specific NEWGRF's presence. But may it be possible to combine a NEWGRF and a Gamescript to achieve this effect, and write a warning into the readme's that both need to be present?
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Converter / Mono usable for source modification?
An industry can get many information about cargo being transported away from it or being delivered and of course it can adjust its production based on it or even close down.Openend wrote:Thank you for the information. Ive been told, that GSes cannot rely on specific NEWGRF's presence. But may it be possible to combine a NEWGRF and a Gamescript to achieve this effect, and write a warning into the readme's that both need to be present?
And a game script can check the amount of industries, the stations and the cargo delivered / transported and try to found new industries.
While documentation can be shipped with both, GS and NewGRF, and even be viewed ingame, it's a good idea to prepare one. However experience has it that any documentation you provide, is usually written for yourself and usually only serves the purpose so that the developer (aka you) can tell the users "you could have known, if you had read the documentation"
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Who is online
Users browsing this forum: No registered users and 32 guests