Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLength())

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

Post Reply
TopTechDreamer
Engineer
Engineer
Posts: 34
Joined: 22 Feb 2012 12:21
Location: Ukraine
Contact:

Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLength())

Post by TopTechDreamer » 22 May 2019 22:25

[Edited 20190607 22:22 : This TASK is SUCCESSFULLY IMPLEMENTED (by me as prototype) :!: - to DOWNLOAD .exe and .sav files
openttd test NO PLATFORM PENALTY OK++.exe.zip
(This is modified openttd-1.9.1. It works on Windows XP SP3, Windows 8.1, Windows 10 (and so on) - all of 32 bit or 64 bit - tested with WinXP_SP3 32 bit, Win8.1 32 bit and Win10 64 bit)
test NO PLATFORM PENALTY OK++ sav.zip
and for more detailed description of RESULTS - look at 9th post (26 May 2019 00:24) in this topic - viewtopic.php?p=1222322#p1222322 ]


This means penalty for loading speed if train length > station platform length.

I know this will break an old rule... and some part of illusion of physics in game (faster brake)... and some measure of "eyecandy" (not for all players - it doesn't matter for some players)...
BUT:
1. This (penalty) will be just an option, that server admins can switch to ON (do not use the possibility of this new option).
2. If some players (like me) use it (the loading speed penalty switched to OFF), so they will have (this way) the 0-stage approximation for the next possibilities:
2.1. To simulate stations in tunnels and on bridges - in the way as shown on the pictures in the topic "Allow existing tunnels and bridges to increase "platform length" parameter for directly adjacent station tiles" - viewtopic.php?f=32&t=85330 .
2.2. To simulate stations with "diagonal" platforms (or even with "not strait" = with "curved" platforms) !
/* Edited 20190523:
2.3. To simulate stations on slopes.
2.4. To simulate stations under bridges.
( but 2.1 is the most interesting possibility - it is significant advantage and development of 3D-space ) */
3. This option (Setting) is extraordinary easy to implement in the existing code of OpenTTD: it's enough to add this option to Settings and then to modify few strings of code in just one procedure to get this result.

If we don't take into account changes to Settings (to add + one option), then it would be enough to modify JUST ONE STRING of the existing code (in the procedure UpdateLoadUnloadTicks below) to achieve this purpose:
- if (overhang > 0) {
+ if ( false && (overhang > 0) ) {

Procedure UpdateLoadUnloadTicks(...) determines the platform length penalty for loading speed. It is in economy.cpp :

Code: Select all

/**
 * Update the vehicle's load_unload_ticks, the time it will wait until it tries to load or unload
 * again. Adjust for overhang of trains and set it at least to 1.
 * @param front The vehicle to be updated.
 * @param st The station the vehicle is loading at.
 * @param ticks The time it would normally wait, based on cargo loaded and unloaded.
 */
static void UpdateLoadUnloadTicks(Vehicle *front, const Station *st, int ticks)
{
   if (front->type == VEH_TRAIN) {
      /* Each platform tile is worth 2 rail vehicles. */
      int overhang = front->GetGroundVehicleCache()->cached_total_length - st->GetPlatformLength(front->tile) * TILE_SIZE;
      if (overhang > 0) {
         ticks <<= 1;
         ticks += (overhang * ticks) / 8;
      }
   }
   /* Always wait at least 1, otherwise we'll wait 'infinitively' long. */
   front->load_unload_ticks = max(1, ticks);
}



I can not to compile the OpenTTD source code in the MS Visual Studio 2019 Community Edition by now because of many errors even over those, that are described in https://wiki.openttd.org/Compiling_on_W ... 2B%2B_2015 .
It looks like this edition doesn't work correctly with its Directories settings and can not find libraries from points 2.9 and 2.10 ( (WorkFolder)\OpenTTD essentials\shared\include and (WorkFolder)\OpenTTD essentials\win32\library ) of this manual from wiki.
If I will be able to compile the code, of course, I wish to modify it - at least, one string as I wrote here above.


OpenTTD Developers, please, could you add this simple option to our favorite game - to OpenTTD. Thank you.
Last edited by TopTechDreamer on 07 Jun 2019 22:22, edited 6 times in total.

Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by Supercheese » 22 May 2019 22:50

Yeah, I've for quite some time wanted a new entry in the Cheat menu to disable this penalty for long trains at short stations...
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton

TopTechDreamer
Engineer
Engineer
Posts: 34
Joined: 22 Feb 2012 12:21
Location: Ukraine
Contact:

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by TopTechDreamer » 22 May 2019 23:02

I think, that it will be better to add this option not as a Cheat, but as a Setting.
Those, who don't like such setting, can just don't use it.
I don't want to use it everywhere, but for tunnels and bridges, for diagonal and curved platforms it is the most simple (and the fastest) way to implement them.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9278
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by planetmaker » 23 May 2019 08:28

As you know the code, you sure know how to create pull requests.

Cheats are just settings with a special tag. This would just be a setting (and imho not a cheat)

McZapkie
Tycoon
Tycoon
Posts: 1175
Joined: 18 Jan 2014 18:10

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by McZapkie » 23 May 2019 14:54

By the way, in JGR Patch Pack there is, beside of standard far/middle/near, additional 'trough' option -
instead of applying penalty, it just load/unload these wagons, which fit to the platform length, then proceed further to load/unload other part of the train.
It sound more reasonable then no penalty cheat, however there are some issues related with full load+autorefit.
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension, V4 CEE train set.
Addicted to freeciv longturn.

User avatar
jfs
Director
Director
Posts: 513
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by jfs » 23 May 2019 20:06

TopTechDreamer wrote: I can not to compile the OpenTTD source code in the MS Visual Studio 2019 Community Edition by now because of many errors even over those, that are described in https://wiki.openttd.org/Compiling_on_W ... 2B%2B_2015 .
It looks like this edition doesn't work correctly with its Directories settings and can not find libraries from points 2.9 and 2.10 ( (WorkFolder)\OpenTTD essentials\shared\include and (WorkFolder)\OpenTTD essentials\win32\library ) of this manual from wiki.
If I will be able to compile the code, of course, I wish to modify it - at least, one string as I wrote here above.
You should be reading the README file instead.

TopTechDreamer
Engineer
Engineer
Posts: 34
Joined: 22 Feb 2012 12:21
Location: Ukraine
Contact:

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by TopTechDreamer » 24 May 2019 20:10

jfs wrote:You should be reading the README file instead.
OK, I have read some part of this README file:
README wrote:...
7.0) Compiling
Windows:
You need Microsoft Visual Studio 2015 Update 3 or more recent. Open the project file and it should build automatically. In case you want to build with SDL support you need to add WITH_SDL to the project settings.

PNG (WITH_PNG), ZLIB (WITH_ZLIB), LZO (WITH_LZO), Freetype (WITH_FREETYPE) and libLZMA (WITH_LIBLZMA) support is enabled by default. For these to work you need their development files. To get them just use vcpkg from https://github.com/Microsoft/vcpkg using x86-windows-static and x64-windows-static triplets. For more help with VS see docs/Readme_Windows_MSVC.md.

You can also build it using the Makefile with MSYS/MinGW or Cygwin/MinGW. Please read the Makefile for more information.

Solaris, FreeBSD, OpenBSD:
Use 'gmake', but do a './configure' before the first build.

Linux/Unix:
...
So, what does this mean? - I don't understand:

- Open the project file and it should build automatically. - Open how? With what program? - With Visual Studio 2019 Community Edition? - I opened solution "openttd_vs142.sln" from "openttd-1.9.1-source.zip" and tried to compile it. Result is: compilation FAILED (errors: compiler cannot find files with libraries).

- ... support is enabled by default. For these to work you need their development files. - I don't need these libraries - I want just compile main program. So how to disable this libraries? Why project don't work (don't want to be compiled successfully) without them if OpenTTD does not require any of the libraries to be present?
7.1) Required/optional libraries
The following libraries are used by OpenTTD for:
libSDL/liballegro: hardware access (video, sound, mouse)
zlib: (de)compressing of old (0.3.0-1.0.5) savegames, content downloads, heightmaps
liblzo2: (de)compressing of old (pre 0.3.0) savegames
liblzma: (de)compressing of savegames (1.1.0 and later)
libpng: making screenshots and loading heightmaps
libfreetype: loading generic fonts and rendering them
libfontconfig: searching for fonts, resolving font names to actual fonts
libicu: handling of right-to-left scripts (e.g. Arabic and Persian) and natural sorting of strings.
OpenTTD does not require any of the libraries to be present, but without liblzma you cannot open most recent savegames and without zlib you cannot open most older savegames or use the content downloading system. Without libSDL/liballegro on non-Windows and non-macOS machines you have no graphical user interface; you would be building a dedicated server.


- Even if I decide to use this libraries, so where have I to put them and what additionally have I to do (maybe, to change some "Directories" settings in Visual Studio 2019) to achieve positive result = successfully compiled openttd.exe file?

Earlier I used the instructions from https://wiki.openttd.org/Compiling_on_W ... 2B%2B_2015 . And (using "OpenTTD essentials 6.0") I had 65 errors of the same type "LNK2001: unresolved external symbol _png_get_libpng_ver, _zlibVersion, ... <name>" from crashlog.obj, fontcache.obj, heightmap.obj, network_content.obj, screenshot.obj, textfile_gui.obj, saveload.obj and "LNK1120 65 unresolved externals" from openttd.exe. So "Done building project "openttd_vs142.vcxproj" -- FAILED."
(But now that wiki-page was changed to a "not clear" state.)

But without those libraries - as "OpenTTD does not require any of the libraries to be present" - I have just 9 errors of the same type: "C1083: Cannot open include file: 'png.h': No such file or directory" from crashlog.cpp and so on: no 'png.h' again from heightmap.cpp and from screenshot.cpp, no 'zlib.h' from network_content.cpp and from textfile_gui.cpp, no 'ft2build.h' from fontdetection.h, no 'lzo/lzo1x.h' from saveload.cpp.

So, total result is: unable to compile the openttd.exe file anyway. And I don't understand, why it is so hard and complicated. Why don't to assemble the whole, the full source set (with all needed libraries and folders included), that will allow users to compile the resulting openttd.exe file without any troubles, easy and fast in one-run command?
/* Economy of disk place? - But Visual Studio 2019 takes a lot of GIGABYTES on disk! Where any economy here?
Economy of disk place on openttd.org server? - But it means so many troubles for those users, who want to compile the source code and can not to do this AT ALL! (Spending so much time to try it.) %) */

So I don't understand this all - both: reasons of such source technique and how to compile the openttd.exe file successfully.


If someone can compile the openttd.exe from "openttd-1.9.1-source.zip", could You describe it in a more clear = more step-by-step detailed way - how to do this, please?

User avatar
jfs
Director
Director
Posts: 513
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by jfs » 24 May 2019 22:48

You missed the part (in the text you even quoted yourself) that suggests you use the vcpkg program to download and install the dependencies.

If you wanted to disable support for various of the dependencies you would modify the project settings, removing the various defines for those dependencies. This is not autodetected, because it would be a huge undertaking in itself to attempt to do that.

I don't want to discourage you, but your way of posting comes off as rather blameful and demanding, as if someone else was at fault for your wish not being implemented already.

At the core of the problem, however, is that building software is hard, because building software actually is hard. OpenTTD is a large project with a long history, it's unavoidable that an old project like this accumulates oddities and idiosyncrasies you will just need to learn and live with if you want to work on it. Attempting to assemble a package of "everything needed to build OpenTTD" would be a failed project from the outset, since we would need to attempt to anticipate an infinity of unique system configurations that each could affect the outcome and cause all sorts of errors. It's not realistic, the best approach is to assume people are either already proficient with the tools required, or they are otherwise willing to sit down and take the time to learn the tools well.

However the entire process of setting up a functional build environment can be fully automated, if you know the starting configuration, and this is what happens with the nightly builds. They load up a virtual machine with just Visual Studio and vcpkg preinstalled, and then run some scripts that automatically download and configure the dependencies, then configures the OpenTTD project, and then builds it.


So just to repeat my main point: Building software is hard, there is no good replacement for taking the time to learn the tools.

TopTechDreamer
Engineer
Engineer
Posts: 34
Joined: 22 Feb 2012 12:21
Location: Ukraine
Contact:

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by TopTechDreamer » 26 May 2019 00:24

Here is no new Settings - I JUST MODIFIED JUST ONE STRING of the existing code (in the procedure UpdateLoadUnloadTicks) AND HAVE ACHIEVED this PURPOSE (it's AMAZING!!!) :

Code: Select all

- if (overhang > 0) {
+ if ( false && (overhang > 0) ) {
( Procedure UpdateLoadUnloadTicks(...) determines the platform length penalty for loading speed. It is in economy.cpp .)
It's just test version of modified "openttd-1.9.1-source.zip" - attached "openttd test NO PLATFORM PENALTY OK++.exe" (for Windows 8.1 32 bit - don't know if it will work on Windows 32 bit earlier versions - hope so).
openttd test NO PLATFORM PENALTY OK++.exe.zip
(1.84 MiB) Downloaded 12 times
test NO PLATFORM PENALTY OK++ sav.zip
Couple of examples in *.sav (be careful: some NewGRF needed).
Testing on stations:
>> Tulcán South
>> San Luis North
>> San Luis Water Supply 1
(1.12 MiB) Downloaded 19 times
P.S. Let's continue... :D
Alan Walker, Sabrina Carpenter & Farruko - On My Way - wrote:I’m sorry but
Don’t wanna talk
I need a moment before i go
It`s nothing personal

I draw the blinds
They don’t need to see me cry
Cause even when they understand
They don’t understand

So then when I’m finished
I’m all ‘bout my business
And ready to save the world
I’m takin my misery
Make it my b****
Can’t be everyone’s favourite girl

So, take aim and fire away
I’ve never been so wide awake
No, nobody but me can keep me safe
And I'm on my way
The blood moon is on the rise
The fire burning in my eyes
No, nobody but me can keep me safe
And I'm on my way

Lo siento mucho, pero me voy
Por que a tu lado me di cuenta que nada soy
Y me cansé de luchar y de guerrear en vano
De estar en la línea de fuego y de meter la mano
Acepto mis errores, también soy humano
Y tu no vez que lo Hago por que te amo

Pero ya, no tengo mas na' que hacer aquí
Me voy, llego la hora de partir
En mi propio camino seguiré lejos de ti

So, take aim and fire away
I’ve never been so wide awake
No, nobody but me can keep me safe
And I’m on my way
The blood moon is on the rise
The fire burning in my eyes
No, nobody but me can keep me safe
And I’m on my way

Eddi
Tycoon
Tycoon
Posts: 7390
Joined: 17 Jan 2007 00:14

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by Eddi » 29 May 2019 22:40

TopTechDreamer wrote:Here is no new Settings - I JUST MODIFIED JUST ONE STRING of the existing code (in the procedure UpdateLoadUnloadTicks) AND HAVE ACHIEVED this PURPOSE (it's AMAZING!!!) :

Code: Select all

- if (overhang > 0) {
+ if ( false && (overhang > 0) ) {
sorry if i'm being blunt, but is this the first line of code you have ever written?
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by PikkaBird » 30 May 2019 00:21

Eddi wrote:sorry if i'm being blunt, but is this the first line of code you have ever written?
As an experimental change, what's wrong with it?

TopTechDreamer
Engineer
Engineer
Posts: 34
Joined: 22 Feb 2012 12:21
Location: Ukraine
Contact:

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by TopTechDreamer » 30 May 2019 00:41

Eddi wrote:sorry if i'm being blunt, but is this the first line of code you have ever written?
Is this important? - No, it is not my first line of code. But I have just a little experience in C++ and with OpenTTD source code. This is my first line of modified OpenTTD code, which was compiled in .exe-file, but... I think, it doesn't matter, because the modified version "openttd test NO PLATFORM PENALTY OK++.exe" (for Windows 8.1+ 32 bit) does exactly what it has to do: it works and keeps the platform length penalty for loading/unloading speed = 0, and, such the way, it allows players to include bridges and tunnels into train stations platforms as parts, i.e. it allows to simulate all the possibilities 2.1-2.4, that was declared in the first post of this topic.

( So, I wonder why there are so few downloads of this modified .exe-file. :?
Maybe, all people here have Linux?.. Or people don't want to try these new possibilities?.. :? )

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by PikkaBird » 30 May 2019 03:32

TopTechDreamer wrote:Maybe, all people here have Linux?.. Or people don't want to try these new possibilities?.. :? )
I suspect it's the latter - unrestricted station smallness is a bit of a niche desire. But more power to you that you wanted a change, and you made it happen!

TopTechDreamer
Engineer
Engineer
Posts: 34
Joined: 22 Feb 2012 12:21
Location: Ukraine
Contact:

Re: Please, add Cheat or Setting: switch to OFF (to 0) penalty if(train->cached_total_length > station->GetPlatformLengt

Post by TopTechDreamer » 30 May 2019 22:05

I wanted first the ability to "convert" existing objects bridges and tunnels making them stations at the same time as they still to be bridges and tunnels - explanation is in the topic Existing objects bridges and tunnels as stations. But I received quickly answers, that this task seems too complicated to implement. I think differently, then started to search the way, how it may be possible to implement. First searches showed me that it is definitely possible but not as easy as wanted. But I was getting some knowledge about OpenTTD source code and made some additional conclusions - viewtopic.php?p=1221523#p1221523 .

After that I thought that more easy way is this - Allow existing tunnels and bridges to increase "platform length" parameter for directly adjacent station tiles. Because here is no need to change any pathfinder algorithms, i.e. existing functions or procedures in this part of the code. But this way will give a good results as approximation of previous main purpose. Analysis of this second (not completely but near) purpose shows that it is more simple but anyway not trivial task. But more conclusions were done - viewtopic.php?p=1221880#p1221880 (what driven me to formulate this (current) topic) - and the most important - viewtopic.php?p=1221919#p1221919 (what opens the way to the second and to the first (main) purposes, but isn't implemented yet :oops: ) .

Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 2 guests