JGR's Patch Pack

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

aberro
Engineer
Engineer
Posts: 64
Joined: 20 May 2013 20:20

Re: JGR's Patch Pack

Post by aberro »

JGR wrote:I've implemented a fix for this which will be in the next release.
Could you please attach patch file? Or is this fix in your git repo?
JGR wrote:Interestingly this bug is in trunk and can be triggered by using the same GRF list as in your savegame.
Yup, I'm a lucky man! When I've compiled ottd with full optimization, I've found another little but, but this time in compiler, in MS VC++ compiler! It just ignored "value == 0 ? last_value : " part and compiled only "last_value / value". I've found this by inspecting asm code; nothing like "cmp" nor "je/jne", only "div".

Upd.: yeah, clipboard brokes transportaion. Trains loading only by half, they ignore other freight, cargodist is in panic, timetables going mad, freight isn't removed from station after it's loaded to transport. Dunno, maybe I'll try to rewrite it to be less invasive. What's so hard in copying chunk of map anyway? As I see it, it's just create a buffer, copy map data into it (maybe exclude something like town buildings, industry, trees, etc), and then rebuild tile by tile starting from given tileindex and using cmd's to calculate price.
User avatar
JGR
Tycoon
Tycoon
Posts: 2557
Joined: 08 Aug 2005 13:46
Location: Ipswich

Re: JGR's Patch Pack

Post by JGR »

aberro wrote:Could you please attach patch file? Or is this fix in your git repo?
It's in the repo, commit 86a94380
aberro wrote:Yup, I'm a lucky man! When I've compiled ottd with full optimization, I've found another little but, but this time in compiler, in MS VC++ compiler! It just ignored "value == 0 ? last_value : " part and compiled only "last_value / value". I've found this by inspecting asm code; nothing like "cmp" nor "je/jne", only "div".
If the compiler can infer that the value will always be non-zero (assuming defined behaviour) by analysing caller sites, prior and subsequent code paths, etc, it can omit the branch.
This is particularly the case when using whole program optimisation, which it sounds like you're using.
As I see it, it's just create a buffer, copy map data into it (maybe exclude something like town buildings, industry, trees, etc), and then rebuild tile by tile starting from given tileindex and using cmd's to calculate price.
This is the basic idea, but there are many details to be handled, doing it correctly is non-trivial. Generally clipboard patch implementations make sweeping changes to map storage and access methods which doesn't help for compatibility with other patches/features either.
Redirect Left wrote:Hopefully you can submit it trunk for fixing too then? If you have that sort of access.
I will look to draft a bug report at some point.
Ex TTDPatch Coder
Patch Pack, Github
aberro
Engineer
Engineer
Posts: 64
Joined: 20 May 2013 20:20

Re: JGR's Patch Pack

Post by aberro »

JGR wrote:If the compiler can infer that the value will always be non-zero (assuming defined behaviour)
But it was zero (why else would I want to check assembler code?)
JGR wrote:clipboard patch implementations make sweeping changes to map storage and access methods which doesn't help for compatibility with other patches/features either.
Current implementation, yes. That's what I've meant by saying "do it less invasive". I don't see any real necessity in doing any changes in main map and especially in rewriting most of functions accepting TileIndex into triplets of template function with two specialization functions. Don't know why author made it that way and in any case it was very arguable decision. But anyway, I need to dive into the code to see what I can do (right now I've finished with checking diffs and importing everything which isn't breaking other stuff, like new files, separate functions, new constants, etc. and soon will start reimplementing this patch)

Upd.: oh my... How's that code even launched?! It has so many incompatibilities, it's ignoring all btree optimizations... How's that even possible to run the game in such state? :shock:
aberro
Engineer
Engineer
Posts: 64
Joined: 20 May 2013 20:20

Re: JGR's Patch Pack

Post by aberro »

Here is build of this patchpack optimized for modern CPUs (without clipboard, so you could play in multiplayer and it should be as stable as JGR's version). With latest JGR's fix of crash at some newgrfs reload. Again, usual warning - you shouldn't download builds from random persons like me.
But I'll look to downloads counter this time to see if there is any point in publishing my builds further.
Attachments
openttd.7z
(4.92 MiB) Downloaded 77 times
EG0611
Engineer
Engineer
Posts: 49
Joined: 19 Feb 2012 08:39

Re: JGR's Patch Pack

Post by EG0611 »

So hello people,

I was wondering why Vanilla OpenTTD have many multiplayer server but JGR Patch Pack have only a couple of MP servers and most of them are passworded. I would love to play patch features with other people.

Thanks
pelya
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 18 Nov 2010 19:48
Contact:

Re: JGR's Patch Pack

Post by pelya »

I guess because it's not featured on the openttd.org main page, there are not that many people knowing about this patchpack. Start your own dedicated server, I guess.
User avatar
Gwyd
Chief Executive
Chief Executive
Posts: 721
Joined: 17 Apr 2017 16:52
Location: Western Ile-de-France Region

Re: JGR's Patch Pack

Post by Gwyd »

The servers tend to be passworded because the players tend to take the game more seriously... I guess
aberro
Engineer
Engineer
Posts: 64
Joined: 20 May 2013 20:20

Re: JGR's Patch Pack

Post by aberro »

JGR, here is a little patch I've made, which changes vehicle group display name to format "parent group.nested group". It's changed only in vehicles list. Also, requirement for group name to be unique was removed. As far as I checked the code, it's not required to be unique by code, so anyway what's the point to make it so. If player wants - he should be able to make ten groups with same name, for whatever reason.
But mostly this patch makes more use of group nesting, like, naming scheme "PAS.Nonamewille", or "Nonamewille.Suburb.Line 1.Mail". Of course, such names could be entered by hand, but it's very annoying to type same names over and over again for every group.
It'd be a honor if you'd include this patch in your pack.
Attachments
group-name-patch_r27927.diff
(63 KiB) Downloaded 99 times
aberro
Engineer
Engineer
Posts: 64
Joined: 20 May 2013 20:20

Re: JGR's Patch Pack

Post by aberro »

Yet another patch, which allows filter vehicles in company vehicles lists by cargo they able to accept. This one I'll post in separate topic (as soon as I'll check it's applies for trunk version), because it's not depended on groups nesting.
Attachments
filter_by_cargo_r27927.diff
(8.49 KiB) Downloaded 100 times
Auge
Director
Director
Posts: 633
Joined: 23 Oct 2006 02:07
Location: Berlin

Re: JGR's Patch Pack

Post by Auge »

Hello

I got a crash every time I want to exit a game to the welcome window. The tar/bz2 file contains the log-, png-, and sav-files of the crash. I hope it helps.
crash-jgrpp-0.21.auge.tar.bz2
(443.59 KiB) Downloaded 60 times
Tschö, Auge
aberro
Engineer
Engineer
Posts: 64
Joined: 20 May 2013 20:20

Re: JGR's Patch Pack

Post by aberro »

Auge wrote:I got a crash every time I want to exit a game to the welcome window.
This is the same crash I've reported and it was fixed already but not yet build into new version (not for 'nix at least).
User avatar
JGR
Tycoon
Tycoon
Posts: 2557
Joined: 08 Aug 2005 13:46
Location: Ipswich

Re: JGR's Patch Pack

Post by JGR »

aberro wrote:JGR, here is a little patch I've made, which changes vehicle group display name to format "parent group.nested group". It's changed only in vehicles list. Also, requirement for group name to be unique was removed. As far as I checked the code, it's not required to be unique by code, so anyway what's the point to make it so. If player wants - he should be able to make ten groups with same name, for whatever reason.
But mostly this patch makes more use of group nesting, like, naming scheme "PAS.Nonamewille", or "Nonamewille.Suburb.Line 1.Mail". Of course, such names could be entered by hand, but it's very annoying to type same names over and over again for every group.
It'd be a honor if you'd include this patch in your pack.
Conceptually this has some non-trivial implications as various other areas of the codebase and UI assume a mostly flat namespace. I'll take a look soonish.
aberro wrote:Yet another patch, which allows filter vehicles in company vehicles lists by cargo they able to accept. This one I'll post in separate topic (as soon as I'll check it's applies for trunk version), because it's not depended on groups nesting.
Thanks, I've merged this with some slight adjustments/additions.
aberro wrote:
Auge wrote:I got a crash every time I want to exit a game to the welcome window.
This is the same crash I've reported and it was fixed already but not yet build into new version (not for 'nix at least).
It shouldn't be too long before I can do another release.
Ex TTDPatch Coder
Patch Pack, Github
aberro
Engineer
Engineer
Posts: 64
Joined: 20 May 2013 20:20

Re: JGR's Patch Pack

Post by aberro »

I have some strange bug - I barely can scroll map in cargo flow mode. It's like it's returning to same point it was a frame before. And the more stations there is the harder becomes to scroll map. Sadly, I don't have time to debug now.
Attachments
1.sav
(10.39 MiB) Downloaded 123 times
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: JGR's Patch Pack

Post by Leanden »

Im playing on an 8k x 8k map, currently with only a single train running, but the games feels sluggish and the fast forward does nothing.

I have a reasonably powerful computer with 24GB RAM and the game is only using 13% CPU.

Any ideas how i can improve performance and why its goung so slow?
Image
aberro
Engineer
Engineer
Posts: 64
Joined: 20 May 2013 20:20

Re: JGR's Patch Pack

Post by aberro »

Leanden wrote:Im playing on an 8k x 8k map, currently with only a single train running, but the games feels sluggish and the fast forward does nothing.

I have a reasonably powerful computer with 24GB RAM and the game is only using 13% CPU.

Any ideas how i can improve performance and why its goung so slow?
Well, I'm full of ideas, from multithreading to optimization. But only few of them are realistic. First of all, if you're running Win x64 version, you could download my build, just look in previous messages. Then, you could try to make your build with optimization flags according to your CPU capabilities, but results are highly depends on used compiler.
As for "why" - because OTTD uses only single thread to do almost everything. And in your case it's doing mostly tile ticking: every tick the game checks and updates 1/8 (if i'm not mistaken) of all ticks. Like, do it need to grow grass on freshly demolished tile, or do this tile need to be flooded by water from neighboring tile. Furthermore, there is animated tiles, which checked and updated every tile. And on large maps there are probably many animated tiles.
Therefore, the game very weakly depends on your CPU (only on it's frequency) and don't depend on your RAM at all (unless it's lower than required; or actually OTTD depends on it's timings, but changing that is far too much for one game).
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: JGR's Patch Pack

Post by Leanden »

I am running a 64x computer. Even with animation switched off it doesnt go any quicker.

I also host a server, is your build compatible with 0.21 of JGR for Multiplayer purposes?
Image
aberro
Engineer
Engineer
Posts: 64
Joined: 20 May 2013 20:20

Re: JGR's Patch Pack

Post by aberro »

Leanden wrote:I am running a 64x computer.
Windows?
Leanden wrote:I also host a server, is your build compatible with 0.21 of JGR for Multiplayer purposes?
It should be (it's compiled from JGR's version 0.21). I doesn't changed anything, all patchs which I've posted here isn't included in that build.
Hey, but anyway I wouldn't recommend you to run 8kx8k map, because it's too large even for optimized build. I'm running 2kx8k (same as 4kx4k) on Core i7 3770 and I think it's largest map which can run smoothly even on better CPUs.
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: JGR's Patch Pack

Post by Leanden »

aberro wrote:
Leanden wrote:I am running a 64x computer.
Windows?
Leanden wrote:I also host a server, is your build compatible with 0.21 of JGR for Multiplayer purposes?
It should be (it's compiled from JGR's version 0.21). I doesn't changed anything, all patchs which I've posted here isn't included in that build.
Hey, but anyway I wouldn't recommend you to run 8kx8k map, because it's too large even for optimized build. I'm running 2kx8k (same as 4kx4k) on Core i7 3770 and I think it's largest map which can run smoothly even on better CPUs.
Yep Windows

The map size unfortunately has to stay as it is because of a project i am working on which needs the smaller scale
Image
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: JGR's Patch Pack

Post by Wahazar »

omer584 wrote: I was wondering why Vanilla OpenTTD have many multiplayer server but JGR Patch Pack have only a couple of MP servers and most of them are passworded. I would love to play patch features with other people.
I apply to use latest JGRPP on my PlExp server, without password. It is the only patchpack which offer glimpse of economic challenge (maximal loan can be set to 5M GBP instead of vanilla 500k, and purchase prices can be increased accordingly, so investment returns are matter of few years, not half of year, and player must take interest rates into account).
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.
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7238
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: JGR's Patch Pack

Post by Redirect Left »

If there is demand, I can easily throw together a UK based JGR Patch server on my RaspberryPI3 (assuming the patchpack has equal low requirements as the vanilla does server wise).
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 10 guests