[patch] Leasing
Moderator: OpenTTD Developers
[patch] Leasing
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
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
-
- leasing.patch
- Leasing patch
- (33.3 KiB) Downloaded 416 times
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: [patch] Leasing
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
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:
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.
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: Select all
- v->value = value.GetCost();
+ v->value = e->GetCost();
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: Select all
+ bool leased;
+ Money leased_for;
+ Money current_lease;
+ Money monthly_lease;
+ Date leased_until;
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
Re: [patch] Leasing
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.
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
-
- leasing.patch
- v2
- (33.69 KiB) Downloaded 332 times
Re: [patch] Leasing
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.
I hope that makes sense.
Re: [patch] Leasing
that's usually what a bank loan is intended to do, although that works totally wrong in openttd.
Re: [patch] Leasing
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.
It's just one possible way of utilizing this.
Re: [patch] Leasing
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.
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.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
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.
- Vaulter
- Traffic Manager
- Posts: 185
- Joined: 21 Dec 2004 05:35
- Skype: andrey-zaharov
- Location: St. Petersburg, Russia
- Contact:
Re: [patch] Leasing
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
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

Re: [patch] Leasing
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.
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?
Re: [patch] Leasing
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
- Vaulter
- Traffic Manager
- Posts: 185
- Joined: 21 Dec 2004 05:35
- Skype: andrey-zaharov
- Location: St. Petersburg, Russia
- Contact:
Re: [patch] Leasing
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.
- 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
-
- leasing.patch.t103.7z
- tags/1.0.3
- (7.72 KiB) Downloaded 267 times
Re: [patch] Leasing
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.
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 352 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.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
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.
update patch
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
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

- Attachments
-
- leasing_v3_r24084.diff
- (33.68 KiB) Downloaded 301 times
Who is online
Users browsing this forum: Amazon [Bot] and 12 guests