Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Thu May 25, 2017 2:16 pm

All times are UTC




Post new topic  Reply to topic  [ 119 posts ]  Go to page 1 2 3 4 5 6 Next
Author Message
PostPosted: Fri Mar 16, 2012 9:17 am 
Offline
Engineer
Engineer
User avatar

Joined: Fri Jan 29, 2010 12:56 pm
Posts: 116
Hi,

after a long while of sporadic tinkering, here is the first released version of my first very own OpenTTD project!

Links to patches, binaries and screenshots will be kept up-to-date at the bottom of this post.
As well as the trunk version that I tested this patch against, last.
And there is a TODO list of upcoming features or fixes.


___What does it do ?___

In short:
  • it provides an advanced auto-replace mechanism for trains and the various subtypes
  • it allows the player to pre-define 'templates' of how a train should look like
  • a vehicle group is then set up to replace all of its trains to look exactly like the defined template
  • on the next depot visit of any train in that group, it will get changed to match the template, buying new vehicles, moving old ones around as necessary
  • remaining parts of a train after the replacement step may either be kept in the depot for later reuse or may be sold automatically

(I was going to post a screenshot here but the forum doesn't support spoiler wraps and it is really large, so I put it in as an attachement).

___Why use it ?___
The motivation of this patch is to reduce micro-management in larger scale games. There are multiple scenarios where I don't think the current auto-replace feature is sufficient:

  • You are running a line for any good which you set up nicely to support the needed amount of transported cargo. At some later point in the game, new wagons become available that have significantly increased capacities. You can either replace them all via autoreplacement but then lack efficiency as you wouldn't have needed as many due to the increased capacity of each wagon. Or you would need to change all trains by hand to contain a smaller number of the newer, better wagons.
  • You are running heavy trains that require multiple engines to be efficient. When later in the game newer and stronger engines become available it might be sufficient to use a single engine for each train instead of multiple ones due to higher power of latest technologies. And you now want to change up your trains to use 1 new engine instead of 2 or more old ones.

Both scenarios (and possibly more) are really only solvable with a lot of manual sending-trains-to-depot-and-modifying-them-by-hand. Both scenarios occurred to me especially in larger scale games with custom newgrf sets where the change in capacity and power of vehicles over time can be severe.
With template based train replacement, you can specify exactly what you want your trains to be composed of - and what refit they should use - and have them changed up in the depot automatically.

___How to use it ?___
There are a couple of notes about its usage:
  • When opening a group window (for trains, please), you find a new drop-down entry for managing the group which reads Template Replacement and will open up the new gui element.
  • Select a group from the top list and a template-train from the bottom list, then press 'start replacing' which will trigger the replacement function whenever any train of the selected group will enter a depot the next time.
  • Autoreplacement as you know it, is of course still available for use
  • The functionality is tightly tied to using groups, i.e. all automatic replacements are set up on a per-group basis, otherwise it would be very hard to specify which train should be composed in which way
  • the template replacement function will _always_ attempt to reuse as much of the treated train as possible so that as few vehicles as possible will be bought
  • the order in which vehicles of a template are defined is essential to the replacement, so we will not only make sure that the new train includes every vehicle from the template, but also in the correct order to prevent messed up trains roaming the game world ;)
  • configurable behaviour:
    • a train that is getting template replaced in any depot, might be using vehicles that are idle inside the depot instead of buying new ones, so you can leave old engines or wagons in depots for later re-composition of other trains.
    • after a train got changed by template-replacement, its old engines and wagons which are not part of the consist anymore, can optionally remain inside the depot in a neutral and idle state for later usage, and are not sold automatically if the option is set so

I will add suggestions or criticism to a todo-list in this thread if you want to help me by providing some.

Thanks for reading, trying it and hopefully providing feedback :)

--------------------------------------------------------------------------------------------------------------------------------
---------- Todo --------------------------------------------------------------------------------------------------------------

|___black: planned
|___white: rejected
|___green: done
|___red: something aweful


  • Combination of Auto- and TemplateReplacement
    • Have template replacement override auto replacement if the former is set
  • Ability to filter template list for specific train-subtype
    • Include new All-types filter
  • Set of game options to define replacement behaviour
    • implemented as template-specific setting
  • Cargo refit for trains treated by tmpl rplm
  • Clone a template from a train
  • Display current refit setting for template
  • Transfer cargo to new train from left-over chain
    • currently, only vehicles that remain in the chain keep their cargo
  • Exchange specific type of vehicle by another for all templates at once
  • TemplateReplacement on all vehicles inside a specific depot
  • ('Meta-Templates' to compose templates of smaller ones and reduce the overall number of defined templates)
    • If anyone thinks these last two points are useful, please notify me, otherwise I probably won't do them

  • Clone a template from another template
  • Optionally auto-disable template replacements when all trains are finished
  • Ensure networking compatibility
  • Game settings entry
  • Hotkey for opening the main GUI window
  • Rework the main GUI, I envision the following:
    • single click: select/deselect current template (like it is now)
    • double click: open the window for buying new vehicles in order to add them to the double-clicked template
    • drag-n-drop: moving around the individual wagons and engines of the template, directly from the main GUI window
  • The ability to use a template replacement as a vehicle order
    • the template would be used independently of a vehicle group
    • replacement order can be inserted similar to 'visit depot for maintenance'


--------------------------------------------------------------------------------------------------------------------------------
---------- Compatibility ---------------------------------------------------------------------------------------------------
working:
- trunk r27742

--------------------------------------------------------------------------------------------------------------------------------
---------- Versions ---------------------------------------------------------------------------------------------------
v0.1:
  • initial release
v0.1b:
  • no autoreplacement if tmpl rpl is scheduled
  • print length in tiles of tmpl consists in main gui
  • enabled dropdown list to filter templates for railtypes
  • gui enhancements
  • fixed: missing header files in sources.list
v0.2x:
  • trains composed under template replacement receive the specified cargo refit
  • now configurable replacement behaviour (as described in the OP - set the reuse of idle vehicles in depot and set whether remaining vehicles should be kept or sold)
  • template length (in tile units) displayed in edit window
  • fixes by Zuu
  • sub-versions include hotfixes for v0.2
v0.3(x):
  • display number of trains that still need replacement with respect to selected template
  • cloning of templates from trains in main gui or create gui
  • fixed: When at the same time two trains where in the same depot and the second one was due for template replacement, it would take apart the other train inside the depot (if option 'use depot' was set). I didn't realize before that in a train which is not 'stopped_in_depot', its wagons are still considered 'stopped_in_depot'.
v0.4(x):
  • feature: replace all vehicle types among templates (a.k.a autoreplace among templates)
  • gui: display extensive vehicle information for templates, e.g. cargo capacities, consist strength (kN, PS, ...)
  • keep refit when cloning templates from trains
  • transfer cargo to new train after template replacement
  • sort groups list alphabetically in tmpl rpl main gui
  • fixed: problems with wrong value for the selected group and template (don't remember the exact occasion, but my done-list says I fixed something there :) )
  • version b - fixed: fixed a crash on template creation :/
  • version c - fixed: using a template with 'use refit' option set to *off* was producing insane refit behaviour in some cases
v0.5
  • move the current version (v.0.4c) to newest trunk
  • move to git
  • 0.5a: 2 hotfixes by DC-1
  • 0.5b:
    • regenerated project files to contain the updated source file names
    • merged with trunk 27171
v0.7, v0.701
  • merged with trunk r27742
  • updated for new sprite system in openttd
  • added bugfixes + some features implemented for tbtr in the mini patchpack, with kind permission from coherently_olive
---------- PLAN ----------
--------------------------------------------------------------------------------------------------------------------------------
---------- Downloads ---------------------------------------------------------------------------------------------------


Attachments:
File comment: Screenshot of the most recent version
screenshot_0.4.png [222.51 KiB]
Downloaded 3 times


Last edited by ffpp on Sun Feb 05, 2017 8:42 pm, edited 81 times in total.
Top
   
PostPosted: Fri Mar 16, 2012 9:34 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6559
Location: The Netherlands
You sir, made my day. From what I gather from the tin, this is absolutely brilliant! I'll look into the tin later this weekend.

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
   
PostPosted: Fri Mar 16, 2012 11:00 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 02, 2005 11:05 am
Posts: 15415
Skype: XeryusTC
Location: localhost
This might win my patch of the year award. It improves auto replacement so much, like how it should be I think. Too bad I don't have a compiler set up so I can't test it :(

_________________
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image


Top
   
PostPosted: Fri Mar 16, 2012 12:17 pm 
Offline
Engineer
Engineer
User avatar

Joined: Fri Jan 29, 2010 12:56 pm
Posts: 116
thanks both!

@XeryusTC: what platform are you playing on ?
I did the development on linux but it should be feasable to install some form of visual studio on windows too and upload a binary build. Only Mac-compatible builds I cannot provide.
Also, I would need to find a place where to but those builds. As my PC is not running 24/7 and has no static ip, it's not such a good idea to use it as a web server.


Top
   
PostPosted: Fri Mar 16, 2012 1:28 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 25, 2009 4:42 pm
Posts: 2362
Location: Location, Location
ask the nice chaps at #openttdcoop for a nice hg repo ;-)

_________________
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra


Top
   
PostPosted: Fri Mar 16, 2012 4:44 pm 
Offline
Tycoon
Tycoon

Joined: Sun Dec 16, 2007 10:24 pm
Posts: 1607
Location: Idaho, USA
Whoah, this looks amazingly useful! If a compiled binary emerges, I will definitely give this a spin. 8)

_________________
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

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


Top
   
PostPosted: Fri Mar 16, 2012 5:11 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Tue Apr 25, 2006 10:22 am
Posts: 261
Location: Bucharest
failed to compile

here is the build log
http://justpaste.it/t75

_________________
ImageImage


Top
   
PostPosted: Fri Mar 16, 2012 5:41 pm 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 6908
need to run projects/generate.vbs to include the new files from source.list into the vcproject-files

no idea about the strgen warnings, though.

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Fri Mar 16, 2012 8:20 pm 
Offline
Engineer
Engineer

Joined: Sat Aug 06, 2011 3:51 pm
Posts: 107
Location: Spain
Amazing! :bow:
BTW, it also makes easier to control how long trains are. When I wanted to make trains longer after replacing a waggon type for a shorter one (or when making stations longer), I had to do it train by train.

About the problem when an autoreplacement is set. In my opinion, it makes no sense to use the autoreplacement function if a template is defined. So, if you have a group where a template is defined, only apply template (and autorenew if needed), and not autoreplacement. If a vehicle has no template defined, then apply the local/global autoreplacement rules.


Top
   
PostPosted: Fri Mar 16, 2012 8:45 pm 
Offline
Engineer
Engineer
User avatar

Joined: Fri Jan 29, 2010 12:56 pm
Posts: 116
thanks, your suggestion about both replacement functions together sounds definitely reasonable so I included it into the first post.

@Eddi: I'm not sure about those strgen warnings either. I think I got them since porting the patch to r24xxx. I didn't touch the language files other than english.txt.


Top
   
PostPosted: Fri Mar 16, 2012 8:53 pm 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 6908
i might want to "autoreplace" amongst the templates. i.e. all templates using engine "A" now use enginge "B", i probably wouldn't want to do that on a per-template basis

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Fri Mar 16, 2012 9:50 pm 
Offline
Engineer
Engineer
User avatar

Joined: Fri Jan 29, 2010 12:56 pm
Posts: 116
I put it in the list.

I'm currently thinking about how to integrate it without putting responsibility on the user to create sane template consists. Because those are very lightweight objects and the usual heavy checks that are done on real train composition are not applicable to them.

The other thing is that along with your idea there should be some kind of safety mechanism so that a player will not accidently mess up half his templates with a single click.


Top
   
PostPosted: Sat Mar 17, 2012 12:30 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4529
Location: /home/sweden
Looks promising.

If noone beats me to it, I'll make a windows binary tomorrow given there is no compile errors. If you get to the point that you get a respority set up and builds using the compile farm, I'll gladly add your project to OTTDAU (a program for players on Windows to keep OpenTTD up to date).

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sat Mar 17, 2012 1:05 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 02, 2005 11:05 am
Posts: 15415
Skype: XeryusTC
Location: localhost
ffpp wrote:
thanks both!

@XeryusTC: what platform are you playing on ?
I did the development on linux but it should be feasable to install some form of visual studio on windows too and upload a binary build. Only Mac-compatible builds I cannot provide.
Also, I would need to find a place where to but those builds. As my PC is not running 24/7 and has no static ip, it's not such a good idea to use it as a web server.

I am on Windows. Setting up a compiler should be trivial but I just haven't done so yet as I have not really done any programming lately.

_________________
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image


Top
   
PostPosted: Sat Mar 17, 2012 10:46 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4529
Location: /home/sweden
In order to make project generation work in Windows the following fixes to source.list are required:
Attachment:
sources_fix.patch [638 Bytes]
Downloaded 100 times

Note that you need a space after the '#' in a comment or the generate.vbs script will fail. Also you were missing some .h files of your patch.


When compiling (using Visual Studio 2008), I got these errors (plus the ones related to translations):
Code:
5>..srcsaveloadaaa_template_veh_sl.cpp(92) : error C2015: too many characters in constant
5>..srcsaveloadaaa_template_replacement_sl.cpp(34) : error C2015: too many characters in constant
5>error_gui.cpp
5>..srcaaa_template_gui_main.cpp(168) : error C2229: class 'TemplateReplaceWindow' has an illegal zero-sized array


There are a few warnings too. Attached you find the complete build log.
Attachment:
build_log.txt [88.34 KiB]
Downloaded 91 times

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sat Mar 17, 2012 11:21 am 
Offline
Engineer
Engineer
User avatar

Joined: Fri Jan 29, 2010 12:56 pm
Posts: 116
Thanks Zuu!
I didn't get around to test the build on windows, yet.

I was about to upload a newer version of the patch myself when I saw your post, so I incorporated your fixes to the sources.list.

Regarding the warnings: there are actually a lot of them, and most - hopefully all - just due to unused old code.
I will clean this up next, but probably not before next week so there is some time to throw some more suggestions or complaints my way :)

The next two important things to add would then be to make the default behaviour about auto-selling old vehicles and reusing idle vehicles optional. It's not so much work in principal but I'm still thinking about the nicest way to integrate these things into the gui. Then one will be able to define the replacement behaviour on a per-template basis.


Top
   
PostPosted: Mon Mar 19, 2012 12:22 pm 
Offline
Engineer
Engineer
User avatar

Joined: Fri Jan 29, 2010 12:56 pm
Posts: 116
Funny.
I just found a quite old suggestion thread that was dealing with exactly the same idea as my patch.
The first photoshopped screenshot even looks like very similar to my implementation.
I swear, it didn't steal any ideas ! ^^
Here is the link:
http://www.tt-forums.net/viewtopic.php?f=32&t=51508&hilit=template

Does anyone remember this thread ? At least FooBar has been posting in it ;)


Last edited by ffpp on Thu Mar 22, 2012 6:25 pm, edited 1 time in total.

Top
   
PostPosted: Mon Mar 19, 2012 2:45 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6559
Location: The Netherlands
Yes, I remember that thread. That's why you made my day previously :P
Your implementation is even more than I would expect from a patch like this, so well done.

Unfortunately I haven't been able to compile yet. MSVC10 is giving me weird errors on a file that you haven't even modified. I didn't find the time yet to build a clean version of the same revision to see if that works. Will have to try again later to see what's up with that. If the clean build works and the patched doesn't I'll make sure to post the details.

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
   
PostPosted: Mon Mar 19, 2012 3:57 pm 
Offline
Director
Director
User avatar

Joined: Sun Jul 13, 2003 12:47 pm
Posts: 615
Location: Alphen aan den Rijn
Yep, of course I remember that threat, I can't wait till your patch is included in the main branch.


Top
   
PostPosted: Mon Mar 19, 2012 5:04 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6559
Location: The Netherlands
Tried building again, after trowing out my local source copy and checking out a new one. Clean OpenTTD worked. After applying the 0.1b patch I get this warning:
Quote:
7>d:ttdopenttdtrunk.hgsrcvehicle.cpp(814): warning C4800: 'OrderDepotActionFlags' : forcing value to bool 'true' or 'false' (performance warning)


And more worryingly these errors:
Quote:
7>Link:
7> Creating library D:TTDOpenTTDtrunk.hgprojects..objsWin32Debugopenttd.lib and object D:TTDOpenTTDtrunk.hgprojects..objsWin32Debugopenttd.exp
7>vehicle.obj : error LNK2019: unresolved external symbol "struct TemplateReplacement * __fastcall GetTemplateReplacementByGroupID(unsigned short)" (?GetTemplateReplacementByGroupID@@YIPAUTemplateReplacement@@G@Z) referenced in function "void __fastcall VehicleEnteredDepotThisTick(struct Vehicle *)" (?VehicleEnteredDepotThisTick@@YIXPAUVehicle@@@Z)
7>vehicle.obj : error LNK2019: unresolved external symbol "class CommandCost __fastcall CmdTemplateReplaceVehicle(struct Train *,bool,enum DoCommandFlag)" (?CmdTemplateReplaceVehicle@@YI?AVCommandCost@@PAUTrain@@_NW4DoCommandFlag@@@Z) referenced in function "void __fastcall CallVehicleTicks(void)" (?CallVehicleTicks@@YIXXZ)
7>vehicle.obj : error LNK2019: unresolved external symbol "class CommandCost __fastcall TestBuyAllTemplateVehiclesInChain(struct Train *)" (?TestBuyAllTemplateVehiclesInChain@@YI?AVCommandCost@@PAUTrain@@@Z) referenced in function "void __fastcall CallVehicleTicks(void)" (?CallVehicleTicks@@YIXXZ)
7>group_gui.obj : error LNK2019: unresolved external symbol "void __fastcall ShowTemplateReplaceWindow(unsigned short,unsigned int,struct VehicleListIdentifier,class GUIList<struct Vehicle const *,char const *> *,unsigned char,int)" (?ShowTemplateReplaceWindow@@YIXGIUVehicleListIdentifier@@PAV?$GUIList@PBUVehicle@@PBD@@EH@Z) referenced in function "public: virtual void __thiscall VehicleGroupWindow::OnDropdownSelect(int,int)" (?OnDropdownSelect@VehicleGroupWindow@@UAEXHH@Z)
7>group_cmd.obj : error LNK2019: unresolved external symbol "short __fastcall deleteIllegalTemplateReplacements(unsigned short)" (?deleteIllegalTemplateReplacements@@YIFG@Z) referenced in function "class CommandCost __fastcall CmdDeleteGroup(unsigned int,enum DoCommandFlag,unsigned int,unsigned int,char const *)" (?CmdDeleteGroup@@YI?AVCommandCost@@IW4DoCommandFlag@@IIPBD@Z)
7>afterload.obj : error LNK2019: unresolved external symbol "void __fastcall AfterLoadTemplateVehicles(void)" (?AfterLoadTemplateVehicles@@YIXXZ) referenced in function "bool __fastcall AfterLoadGame(void)" (?AfterLoadGame@@YI_NXZ)
7>saveload.obj : error LNK2001: unresolved external symbol "struct ChunkHandler const * const _template_vehicle_chunk_handlers" (?_template_vehicle_chunk_handlers@@3QBUChunkHandler@@B)
7>saveload.obj : error LNK2001: unresolved external symbol "struct ChunkHandler const * const _template_replacement_chunk_handlers" (?_template_replacement_chunk_handlers@@3QBUChunkHandler@@B)
7>saveload.obj : error LNK2001: unresolved external symbol "struct Pool<struct TemplateVehicle,unsigned short,512,65536,1,0,1> _template_pool" (?_template_pool@@3U?$Pool@UTemplateVehicle@@G$0CAA@$0BAAAA@$00$0A@$00@@A)
7>D:TTDOpenTTDtrunk.hgprojects..objsWin32Debugopenttd.exe : fatal error LNK1120: 9 unresolved externals
7>
7>Build FAILED.

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 119 posts ]  Go to page 1 2 3 4 5 6 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.