Semiautomatic Renew

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Semiautomatic Renew

Post by ChrisHuebsch »

Hi,

recently I posted an article, where I explained my Idea of a semiautomatic renew. I implemented it partially for trains (not yet for street-vehicles, ships or airplains).

How it works at user side:

Holding crtl and pressing GotoDepot in a TrainView pops up a new Window, similar to the build-train window. But this time only engines are shown. Clicking "refit" sends the train to the nearest depot. Reaching it, the train automagically gets a new engine of the selected type and continues it schedule (it does not stop!).

During its journey it shows an (*)-Mark in front of "train is heading for depot" in the TrainView. To stop the train from getting a new engine, just press again "GotoDepot" and the train resumes its normal schedule.


How it works inside:

There is a new attribute of the vehicle struct (automatic_replace). It is set to the number of the vehicle-type. If a train reaches a depot with this variable set to something different than 0, the engine is sold and a new one is bought. After that, the train is unstopped.

Bugs:

I am nut sure, if i did understand the numerous list completely. Furthermore sometimes I got the very strange situation, that there was a new engine of the ai-player in my depot! Perhaps the two commands, which sell and re-buy an engine should not be used that way?

If there is not enugh mony to buy a new engine, the game crashes. Perhaps the engine should not be sold, when there is not enough money to buy the new one. But I do not know, how to do that.

I attach a patch. I would be glad, if someone could test it and send me some comments. [Update: Use the patch at the end of this page!]

(And yes, I know. The vehicle-array is being reworked, and the patch will not be included in the current release ;-) but perhaps in a future one someday?)
Last edited by ChrisHuebsch on 06 Jul 2004 16:46, edited 1 time in total.
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

what if the train is multiheaded?
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

As I use the normal "sell-engine" command, multiheaded trains are no problem. I do not manipulate data structures myself, I use the regular commands of train_cmd.c.

(Multihead means in this case one engine at start, the other at the end)

When using multiple engines at a train, only the first one is replaced. I am not sure, if multiple engines are used very often and if the extra-engines are used to count the livetime of a train.

Chris
Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Post by Moriarty »

I believe multiple engines are used a lot. They provide necessary power increases.
I know i use them, though that doesn't mean everyone else does. But it's quite likely they do.
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

Moriarty wrote:I believe multiple engines are used a lot. They provide necessary power increases.
do you need to renew them, when the main-engine gets old?
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

ChrisHuebsch wrote:
Moriarty wrote:I believe multiple engines are used a lot. They provide necessary power increases.
do you need to renew them, when the main-engine gets old?
It is the same engine, just with a front-end and a back-end. If for example an ICE train gets old, you cannot just replace the front engine and expect it to work correctly.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

Darkvater wrote:
ChrisHuebsch wrote:
Moriarty wrote:I believe multiple engines are used a lot. They provide necessary power increases.
do you need to renew them, when the main-engine gets old?
It is the same engine, just with a front-end and a back-end. If for example an ICE train gets old, you cannot just replace the front engine and expect it to work correctly.
Is it? I am writing about multiple (2,3 even more) engines in one train. Perhaps 3 Ginzu 'A4' to get 3600 hp instead of only 1200 hp.

Multihead-Engines e.g. Manley-Morel are replaced correctly with my patch. But if the train has 3 ginzus, only the first is replaced.

Again. I do not modify the vehicle-list directly, but i let the CMD_SELL_RAIL_WAGON and CMD_BUILD_RAIL_VEHICLE do the job.

Sell_Rail_Wagon sells multihead-engines correctly.

Chris
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

ChrisHuebsch wrote:Is it? I am writing about multiple (2,3 even more) engines in one train. Perhaps 3 Ginzu 'A4' to get 3600 hp instead of only 1200 hp.
Oh, like that :). You have to keep in mind that if you renew only the first engine of a multi-headed engine with a newer, faster one, the train will only get more HP, not go faster. The train will go as fast as the slowest engine. So either leave it up to the user the be smart (which usually they are not ;) ), or replace all engines.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

Darkvater wrote:Oh, like that :). You have to keep in mind that if you renew only the first engine of a multi-headed engine with a newer, faster one, the train will only get more HP, not go faster. The train will go as fast as the slowest engine. So either leave it up to the user the be smart (which usually they are not ;) ), or replace all engines.
Mhh. Doing this, requires a new Command. It might be possible with the Commands currently available, but would require a lot of them. I think this wouldn't work very reliable.

But the current double-command-call doesn't work reliable either.

Tomorrow is sunday, I'll try something.
Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Post by Moriarty »

Darkvater: What happens if all 3 ginzu A4's in the trainset get old, and you only replace the first engine (with another A4).
Would it effect reliability having 2 old ones behind it?
This is the sort of oversight that programmers manage (i know i do it a fair bit on my web-game :) ).
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

Moriarty wrote:Darkvater: What happens if all 3 ginzu A4's in the trainset get old, and you only replace the first engine (with another A4).
hehe. good question.

what if one just sells the first engine, will the age of the second engine count?

do all engines of a train age, and what if the second, third, ... engine gets too old?
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

ChrisHuebsch wrote:Tomorrow is sunday, I'll try something.
I tried. But not successfull.

It is possible, but requieres a lot of work. The problems are multiple engines, reliability and flawless network integration.

To the last point: The games of network-players need to be in sync. So the data needs to be transferred via commands.

Reliability cannot be reached with executing multiple commands. It seems that sometimes som things go wrong and all arrays are mixed up.

Multiple engines are a good reason not to use sell- and buy-commands. Although it seems really attractive to use those two commands, because they do a lot of rather complex things, there needs to be a lot of programming around them to handle all the strange train-types.

Implementing the exchange of the engines manually is not simple. It requires a lot of knowledge of data-structures, I do not have.

Sorry folks, I do not have enough time for that.

(Btw. there wasn't a single comment like "hey, good idea" or "yes, good direction, but needs some work there or there". So I think there is no real interest in this functionality.)
User avatar
lucaspiller
Tycoon
Tycoon
Posts: 1228
Joined: 18 Apr 2004 20:27

Post by lucaspiller »

Well I am interested now I have something to see! :D

Isn't it possible to just check each piece of a train to see if it is an engine and replace it if there is a newer one? I don't know how the multiheaded trains work though so I am not sure whether they do actually behave as engines. There must be something in an array somewhere or other to say whether the piece is an engine or not though.
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

I never even tried adding such funtionality because I'm a man of manual labour :D

But (and I might be saying things too simply, cause I haven't had a look at the code), why would it be so hard?

You can sell the engine, then rebuy it, or another one, keeping all orders, etc. All you have to be careful about are multi-headed (3 ginzu's) engines. Because when you buy an engine, it is not automatically linked with the other train. All you have to fix is that, and I think you are done.

Leave it up to the user to not be stupid enough and want exotic stuff. Just replace the 3 ginzu's with 3 new engines. Of course if there is not enough money for the operation, which can already be seen from the tryout-loop, you can give back an error message.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

New Try

Post by ChrisHuebsch »

Hi,

ok. the pain was getting to bad (almost 80 trains in a game and it seems that they get older faster then i can replace them).

I tried Semiautomatic Renew again.

At first only for trains, because that seems to be the hardest part. An - folks - it works.

At user side, you will get a new window, wenn you ctrl-click on the "goto-depot"-button or a train-entry in the train-list.

In this window, you can select the new type of engine, the train gets. _all_ engines of the train are replaced by the new type.

There is a small bug: If a train has multiple (2 or more) multi-head-engines (one, that has an engine at the start and one at the end), replacing them doesnt work correctly. But trains with only one multi-head-engine are handled fine.

For the developers: I use the unused p2-param of gotodepotcommand to tell all network-parties that the train needs to get a new engine. Uppon reaching the depot, i replace the engine manually! (updating the old vehicle-info or deleting/creating the second part of the multi-head-engines).

Ok. Comments? (Please friendly ones or I keep the patch for ships and road-vehicles for myself :lol: )


Chris
Attachments
SemiAutomaticRenew2.patch
patch against 864, only english language
(13.49 KiB) Downloaded 293 times
User avatar
PDsiRF
Engineer
Engineer
Posts: 73
Joined: 28 May 2004 13:35

Post by PDsiRF »

how about a simple "use this model" (each for normal, monorail, and maglev) fancy hippy thing somewhere (new train window wich opens from train menu button, like industry list?) wich one could turn off / on?
it wasnt me..
User avatar
AlienDNA
Engineer
Engineer
Posts: 97
Joined: 12 Apr 2004 08:53
Location: Leiden, Netherlands

Post by AlienDNA »

Would it be hard to merge a dream like this patch in svn, and make it an experimental feature through the patch gui?

This is what all of us have been waiting for! The annihilation of the last menial labor-task in OTTD! And it would get many, many testers, because there must be many more like me, hitting refresh continuously around 20:00 to get the new nightly! :wink:
User avatar
mdhowe
Route Supervisor
Route Supervisor
Posts: 446
Joined: 09 Jul 2004 07:12
Location: Hobart, Australia

Post by mdhowe »

Excellent idea!! This is (was) one of my least favourite tasks in openttd. Keep up the good work. :D
"Set fashion, not follow. Spit vitriol, not swallow" - Marilyn Manson
tecxx
Engineer
Engineer
Posts: 106
Joined: 23 Jun 2003 19:31
Location: Tirol/Austria
Contact:

Post by tecxx »

[quote="ChrisHuebsch(Btw. there wasn't a single comment like "hey, good idea" or "yes, good direction, but needs some work there or there". So I think there is no real interest in this functionality.)[/quote]

omg, your idea is one of the best ideas i've heard so far. PLEASE finish your fine work!!! i'd love to see this in the game, it's far better than completely automatic renewal.
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

tecxx wrote:omg, your idea is one of the best ideas i've heard so far. PLEASE finish your fine work!!! i'd love to see this in the game, it's far better than completely automatic renewal.
Your wish is an order for me ;-)

It is done.

Have a look at the SemiAutomaticRenew-Patch at SF.net

http://sourceforge.net/tracker/index.ph ... tid=636367


Chris
Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 21 guests