Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Jun 28, 2017 5:11 am

All times are UTC




Post new topic  Reply to topic  [ 281 posts ]  Go to page 1 2 3 4 515 Next
Author Message
PostPosted: Tue Jan 10, 2006 2:28 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
My nightly server now has an autopilot running the console. It pauses the game when there are no players, and it greets all connecting players with my email address and the URL of the server's house rules. There are no modifications made to OpenTTD - my server runs an unmodified, released build.

This autopilot is written in Expect. In future, it will also be able to page me (as a committed, caring server admin) from within the game by email. It will be able to take messages for other players (once I get that code working) and will pass those messages on when the specified player next joins.

There will hopefully very soon be a modified one for the #OpenTTDCoop sandbox server which will kick and disband anybody connecting as a non-spectator other than in company 1.

If any other server admins have Expect and would like this initial version of the autopilot script, please get in touch.

All players are welcome to join my nightly server (which varies between UK Renewal Set and vanilla Arctic depending on my mood and the mood of players) to see the new autopilot in action.

Windows users can use this product after patching their copy of openttd.exe with this zipped patch utility by glx (attached to page 4 of this thread).

Edit: Added version 2.0.4 to this post


Attachments:
File comment: Version 1.3
autopilot.txt [6.35 KiB]
Downloaded 1862 times
File comment: Version 2.0.4

Security update, works with RC4

autopilot-2.0.4.zip [33.2 KiB]
Downloaded 1176 times

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Last edited by Brianetta on Thu Jan 18, 2007 9:32 pm, edited 15 times in total.
Top
   
 Post subject:
PostPosted: Tue Jan 10, 2006 8:33 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Jul 19, 2005 11:33 am
Posts: 86
Location: Inbetween here and there
Sounds good, Where do i get the UK renewal set from?

_________________
Image
Image
Image


Top
   
 Post subject:
PostPosted: Tue Jan 10, 2006 11:15 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
This forum, somewhere. The nightly isn't running the UKRS right this minute, although it will be for the next game.

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Top
   
 Post subject:
PostPosted: Tue Jan 10, 2006 11:27 am 
Offline
Moderator
Moderator
User avatar

Joined: Sat Apr 02, 2005 7:01 am
Posts: 3651
Location: Sydney NSW Antipodea
specificaly the ttdpatch graphics forum


Top
   
 Post subject:
PostPosted: Thu Jan 12, 2006 11:16 pm 
Offline
Engineer
Engineer

Joined: Fri Jul 04, 2003 4:06 pm
Posts: 11
Location: Norway
Could you release the source for this script? It would be neat to have, I'm getting tired of going to bed at night in year 1990 to wake up in year 3000 next day.


Top
   
 Post subject:
PostPosted: Thu Jan 12, 2006 11:37 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
I'm thinking about it. I want to get the internals presentable and some bugs ironed out first. If I release it I'll probably GPL it because I'm nice like that.

It's a bit fernickety at the moment. It often misses reading join or quite messages, meaning it loses count of the number of clients (which can make it pause when somebody's still there, or stay running when everybody's gone). I've added a command to reset the client count manually, but it's a bit of a naff solution.

I can get it to never miss anything ever by completely ignoring the console user. Unfortunately, this would mean that all server admin must be done by rcon.

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Top
   
 Post subject:
PostPosted: Fri Jan 13, 2006 3:21 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
OK, I'm going to release it. The code isn't commented (except a couple of variables at the top) so unless your TCL is good you're going to have to live with that if you want to modify it.

This is released under the GNU General Public License and as such comes with no warranty. If your game runs all night with nobody on it, or you manage to lose a saved game you really liked, or it goes mental and locks up a server to which you have no physical access, all you are entitled to is my sympathy.

Right, you need Expect. This is a TCL extension and can be found here: http://sourceforge.net/projects/expect

It works on Linux. I don't think I did anything platform specific, but you never know - it might also work on Windows or Mac or whatever.

Before you run it, change the motd variables at the start (or be embarrassed when somebody joins your server later). You can change the config file it uses here, or you can set the path to a valid openttd.cfg file in your OTTD_CONFIG environment variable - handy for multiple servers. You can also give a preferred net_frame_freq here. The script hopes that it (and you) are in the installed OpenTTD directory.

The script takes an optional parameter, which loads a saved game of the name "game.sav" from saves/. It can also take an additional optional parameter to load some other game.

./autopilot
./autopilot load
./autopilot load "save/Fundingford Transport.sav"

Windows people will need to either rename autopilot so that it has the extension that Expect expects, or they will need to run it like this:

expect autopilot
expect autopilot load
expect autopilot load "save/Fundingford Transport.sav"

Once you're running, the console might seem laggy. This is because it pays attention to the game for four seconds, then it pays attention to you for four seconds, then the game, etc. It doesn't miss stuff, though.

You have extra commands. The help command is extended, and if you type "save" without giving a filename it saves to game.sav in your save folder (which is the default for loading as mentioned above). Please note that the autopilot cannot be controlled by rcon! You need access to the dedicated console itself to use it. rcon will work as normal for all server functions.

The autopilot will greet people who join the game. It will unpause the server for them, and it will pause the game when they all leave. Once people have all left and the server is paused, it will save the game to save/game.sav, taking advantage of the fact that there's nobody to delay.

As people join and leave the game, autopilot will tell you how many people it thinks are connected. If this turns out to be wrong (autopilot has been known to miss the odd join or leave from time to time) then correct it from the console with the 'count' command, eg. 'count 2' will tell autopilot that there are two people connected, regardless of what it thought.

If anybody types "show autopilot version" into the in-game chat, it'll tell everybody the version. The console gives 'version' and 'license' commands, which pertain only to autopilot (although OpenTTD does use the same license, this is coincidental).

Finally, any commands you type into the console that autopilot doesn't recognise, it will relay to the game server.

If anybody has any questions, ask here. Despite what I said about there being no warranty, I'm happy to help out with modifications, etc.

Remember, autopilot is a wrapper. It is agnostic about the version of OpenTTD that it is being run on. As long as the console looks pretty much the same, it will work on any version.

(attachment moved to first post)

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Last edited by Brianetta on Tue Jan 17, 2006 12:25 am, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Fri Jan 13, 2006 9:45 pm 
Offline
Engineer
Engineer

Joined: Fri Jul 04, 2003 4:06 pm
Posts: 11
Location: Norway
Nice! It seems to work quite good.
Thank you very, very much! :D


Top
   
 Post subject:
PostPosted: Fri Jan 13, 2006 10:32 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
You're quite welcome. (:

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Top
   
 Post subject:
PostPosted: Sat Jan 14, 2006 4:42 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Sat Sep 24, 2005 1:52 pm
Posts: 160
Location: Denmark
can it be made avalible for us normal persons. :)


Top
   
 Post subject:
PostPosted: Sat Jan 14, 2006 5:14 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
RMJ wrote:
can it be made avalible for us normal persons. :)

Can you be a little more specific? What do you mean by normal, and why isn't autopilot available to said people?

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Top
   
 Post subject:
PostPosted: Sat Jan 14, 2006 5:58 pm 
Offline
Engineer
Engineer

Joined: Fri Jul 04, 2003 4:06 pm
Posts: 11
Location: Norway
If he assumes "normal persons" is windows users he has got it all wrong :wink:


Top
   
 Post subject:
PostPosted: Sat Jan 14, 2006 6:02 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
There's no real reason why the autopilot shouldn't run on Windows, as long as Expect is installed. Expect is freely available.

If RMJ is hoping for some sort of clickable installer and a Windows executable, he's heading for disappointment. Expect scripts run in Expect, the same as Java classes run in a JVM.

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Top
   
 Post subject:
PostPosted: Sun Jan 15, 2006 1:18 pm 
Offline
Engineer
Engineer

Joined: Sat Jan 14, 2006 5:49 pm
Posts: 7
Hi,

I tried to start autopilot, it works, but after a while I get these errors:

Quote:
expect: spawn id exp8 not open
while executing
"expect -nobrace -re {
\*\*\* .* has joined the game} {
exp_send "unpause\n"
set output $expect_out(0,string)
set output_sp ..."
invoked from within
"expect {
-re "\n\\\*\\\*\\\* .* has joined the game" {
exp_send "unpause\n"
set output $expect_out(0,string)
set outp..."
("while" body line 2)
invoked from within
"while true {
expect {
-re "\n\\\*\\\*\\\* .* has joined the game" {
exp_send "unpause\n"
set output $expect_out(0,string)
..."
(file "./autopilot" line 72)


//UPDATE!!

I restarted the server and the error is gone...

But another question. Now my Server's calling "Unnamed Server".
Does anybody know the path to the config-file after a Debian-installation?





Greets
ljungi


Top
   
 Post subject:
PostPosted: Sun Jan 15, 2006 2:06 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
SO everybody knows, the error message "expect: spawn id X not open" means that the dedicated server quit. You'll see this at any assertion failure and any time a player executes rcon exit.

I might make a future version handle this more cleanly (and perhaps restart the server with the last save or something). Depends whether people think it's necessary.

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Top
   
 Post subject:
PostPosted: Sun Jan 15, 2006 3:08 pm 
Offline
Engineer
Engineer

Joined: Sat Jan 14, 2006 5:49 pm
Posts: 7
Hi,

I've got again a Problem...
The autopilot worked... But now he don't anymore!


Quote:
dbg: [NET][UDP] Advertising to master server
'net_frame_freq' changed to: 2
Game paused.
*** ljungi hat das Spiel betreten


So I joined the game but he doesn't unpause...
When I leave, he doesn't pause.

Thats strange, cause it already worked!
I only restarted the server...

the command to start it was

screen ./autopilot load '/root/.openttd/save/ml.sav'


Top
   
 Post subject:
PostPosted: Sun Jan 15, 2006 3:33 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
Aha - it's a language problem. Unfortunately, autopilot doesn't speak German!

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Top
   
 Post subject:
PostPosted: Sun Jan 15, 2006 10:58 pm 
Offline
Engineer
Engineer

Joined: Fri Jul 04, 2003 4:06 pm
Posts: 11
Location: Norway
It does not speak norwegian either, but it takes you 10 seconds to make it speak it. Just locate "has joined the game" and replace it with your language.


Top
   
 Post subject:
PostPosted: Sun Jan 15, 2006 11:01 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
Don't forget the "has left the game" bit too - or it'll lose count really quickly. (:

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


Top
   
 Post subject:
PostPosted: Mon Jan 16, 2006 11:59 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 15, 2003 10:00 pm
Posts: 2566
Location: Jarrow, UK
Updated to 1.2 (attached to original post in thread).

It's longer now, but it has an additional feature - it can use the output of the "clients" command to re-count the number of connected clients, on demand (use "recount clients"). It also has a small bug fix - clients with a space in their name are greeted by their whole name, not just the first word.

I found that the autopilot most often lost count when the server got something wrong and all the clients desynced at once. The lines went by too fast for the autopilot, and it ended up with a higher cliuent count than reality. Now, if it sees somebody leave due to a desync, it will instigate a recount.

Also, players can cause a recount on demand by saying "recount clients" into the chat. This is in addition to their being able to see the autopilot version with "show autopilot version".

_________________
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 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.