Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Jan 16, 2019 11:19 am

All times are UTC




Post new topic  Reply to topic  [ 14 posts ] 
Author Message
 Post subject: [patch] Leasing
PostPosted: Sun Jul 25, 2010 8:31 am 
Offline
Engineer
Engineer

Joined: Sun Jul 25, 2010 6:58 am
Posts: 2
Hi I've got a patch here that lets you lease vehicles instead of buying them. The lease settings are under vehicles in adv settings, and you can set the lease term and the total interest on the value of the vehicle. There's a new button on the build vehicle screen to lease the vehicle, and new lines in the finances window for leasing.

Patch against r20210 or git clone git://github.com/jemmyw/openttd.git and change to the leasing branch. Not sure why, but you might need to patch -p1 instead of p0.

Not sure what should happen at the end of the lease term, at the moment the vehicle will become unleased and you own it, I think you should have to buy it at the current value or lease a new one. Suggestions welcome!

I haven't played a proper game with this yet, so the idea just might not work, but I thought it'd be a useful feature for when you're starting out.

Cheers,
Jeremy


Attachments:
File comment: Leasing patch
leasing.patch [33.3 KiB]
Downloaded 203 times
Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Sun Jul 25, 2010 8:58 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9102
Location: Sol d
So in terms of gameplay, this basically gives you the vehicle for free on the condition of increased running costs? Then this is something which - in principle - can be implemented using newgrfs alone.

Concerning your coding style: watch out that OpenTTD uses tabs for indentation, not spaces; you do that consistently wrong.

Also you have a number of occurances of
Code:
-      v->value = value.GetCost();
+      v->value = e->GetCost();

I propose to either keep the lines or make this its own coding style patch.

Conceptually I'd boil down this patch a little and not introduce four new variables for each vehicle as it uses quite a bit of memory for things usually not needed:
Code:
+  bool leased;
+  Money leased_for;
+  Money current_lease;
+  Money monthly_lease;
+  Date  leased_until;

It'd most probably suffice to introduce the 'leased' flag and have a global (per company) variable which gives the lifetime of the lease contracts. Then vehicles can be leased for that time over which their usual purchase price plus an additional lease fee are payed off. Purchase price and date are know, everything else can thus be calculated without introducing extra variables. The lease fee might be a certain percentage of the usual purchase price, either a separate setting or even maybe coupled to the inflation rate.

_________________
Image
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


Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Sun Jul 25, 2010 10:03 am 
Offline
Engineer
Engineer

Joined: Sun Jul 25, 2010 6:58 am
Posts: 2
Thanks, I've fixed all of the tabs in the file, and removed leased_until because it's not even used. I'll try and reduce the other variables too.

Gameplay wise I wanted to have the option to lease or buy, the idea being that when you would lease at the beginning of the game on high profit links.

The reason for changing the value lines is that in each build function v->value is assigned e->GetCost() via value.GetCost(), but because the lease makes the value 0 I had to remove this indirection.


Attachments:
File comment: v2
leasing.patch [33.69 KiB]
Downloaded 117 times
Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Sun Jul 25, 2010 10:35 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Sep 16, 2005 12:23 pm
Posts: 1517
Skype: the_gremnon
Location: /home
Perhaps this could be used in times of short cash? That is, you lease it for less than the full price, and pay in installments, with interest - effectively paying a little extra overall, to get it a little sooner.

I hope that makes sense.


Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Sun Jul 25, 2010 11:26 am 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 7260
that's usually what a bank loan is intended to do, although that works totally wrong in openttd.

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


Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Sun Jul 25, 2010 11:52 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Sep 16, 2005 12:23 pm
Posts: 1517
Skype: the_gremnon
Location: /home
True, but there are times, often at the start of a game, when you run even a maxed loan out (I know I do) and could really use just one more vehicle.
It's just one possible way of utilizing this.


Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Tue Aug 03, 2010 10:40 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Oct 04, 2008 11:05 pm
Posts: 2650
Location: Lost in spaces
Hello jemmyw,

You may want to use STD_CONVAR instead of SDT_VAR in table/settings.h, that way vanilla savegames can be loaded with your patch.

_________________
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.


Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Thu Aug 05, 2010 12:27 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Tue Dec 21, 2004 5:35 am
Posts: 185
Skype: andrey-zaharov
Location: St. Petersburg, Russia
Good idea.
But there is a problem with save/load:
Start new game, lease a lot of vehicles, check finances - a lot of leasing monthly payments, save game.
Load game, check finances - you have 0 (zero) leasing monthly payments, sell all vehicles.
PROFIT :)

_________________
OpenTTD Hard Game Pack


Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Sat Aug 07, 2010 5:09 pm 
Offline
Chairman
Chairman
User avatar

Joined: Sat May 12, 2007 1:09 am
Posts: 882
Location: Northeastern USA
I like the idea of being able to use my capital (bank loans) to build infrastructure, and if necessary lease vehicles.

Definitely when the lease is up you should have to either buy the vehicle at the current value or it disappears (sold for $0.)
Leasing also makes sense when there are no really reliable vehicles available. Lease them, then dump them when a reliable vehicle is available for purchase.

_________________
Who is John Galt?


Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Sat Aug 07, 2010 5:18 pm 
Offline
Chief Executive
Chief Executive
User avatar

Joined: Tue Aug 11, 2009 4:10 pm
Posts: 670
Location: The Nederlands
quote from myself from chill's patchpack:

Dante123 wrote:
one downside from that leasing patch is when you use the button "clone ..." to clone a boat/train it is default leasing and not buying.
dont know if this is normal behavior for that patch or only in this patchpack, therefore i posted here and not in the leasing topic

_________________
-->DWE GRF set<--
DWE Screenshot Thread


Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Sat Aug 07, 2010 8:03 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Tue Dec 21, 2004 5:35 am
Posts: 185
Skype: andrey-zaharov
Location: St. Petersburg, Russia
here is leasing patch with some changes:
- saves vehicle leasing state. It fixes scheme "lease-save game-load game-sell".
- clone. Now when you clone bought vehicle - it buys . Clone leased - it leases.


Attachments:
File comment: tags/1.0.3
leasing.patch.t103.7z [7.72 KiB]
Downloaded 112 times

_________________
OpenTTD Hard Game Pack
Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Sat Aug 07, 2010 9:34 pm 
Offline
Chief Executive
Chief Executive
User avatar

Joined: Tue Aug 11, 2009 4:10 pm
Posts: 670
Location: The Nederlands
nice one! thanx

_________________
-->DWE GRF set<--
DWE Screenshot Thread


Top
   
 Post subject: Re: [patch] Leasing
PostPosted: Mon Aug 09, 2010 3:57 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Oct 04, 2008 11:05 pm
Posts: 2650
Location: Lost in spaces
Here's a little update to this patch.
It is called v3 because Vaulter's version is a backport to the 1.0.3 branch but it includes the fixes and improvements made.

changed:
----------
- Bump to trunk
- Only use STRING1 in english.txt. All other languages use STRING.
- Use CONDVAR in table/settings.h
- Enum instead of define in saveload.h
- Adjusted saveload.cpp for allowing new chunks to be saved.
- Coding style


Some suggestions to improve the patch:
----------------------------------------------
- Show if a vehicle is bought/leased and remaining lease term in the vehicle details gui.
- Allow sorting on bought/leased in the company's vehicles gui. Also have a visual indication there if a vehicle is bought or leased.
- Show number of bought/leased vehicles in general company's gui.


Attachments:
leasing_v3_r20424.diff [37.78 KiB]
Downloaded 134 times

_________________
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Top
   
 Post subject: update patch
PostPosted: Mon Apr 09, 2012 7:48 pm 
Offline
Engineer
Engineer

Joined: Tue Apr 03, 2012 12:34 pm
Posts: 37
Location: Russia, Moscow
Hello all.
Some years ago I try to play with this patch and it was looks good for me. Now I try to learn some c++ basics and feel that I can do things.
I'm update this leasing patch to last trunk. This can seem easy but trunk is getting much transformed since last revision of this patch and some logic about vehicle buing/selling has changed.
And I do some short tet that all works but need to take tests longer because of strong changes in game vehicle logic.

With all regards to creator :roll:


Attachments:
leasing_v3_r24084.diff [33.68 KiB]
Downloaded 118 times
Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: JGR and 6 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-2019 phpBB Limited

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