webinterface for changing the openttd.cfg

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Post Reply
Progman
Engineer
Engineer
Posts: 76
Joined: 15 Jul 2006 12:55
Contact:

webinterface for changing the openttd.cfg

Post by Progman »

I have written a php-script which can be used to change some configurations about the openttd.cfg file. This can be used by server admins which often changes some settings. It allowes you to change the following options:
  • Base difficult settings (the custom one)
  • Base game options (town names, climate)
  • Some patch-settings which often get changed between new games
  • NewGRFs
The list of patch-settings to edit is hardcoded to a few settings like mapsize and vehicle limit. Imho these are the most used patch settings to edit. If you personally need other patch settings add them.

This script will not control a server in some way like start and stop it nor send it any rcon commands to the server. It isn't also used to change the whole openttd.cfg file with all possible settings. As you can activate/deactive newgrfs it doesn't do any filesystem operation to manage them like move, delete, upload and stuff. It just changed the openttd.cfg file.

Installation:
Just put it in a directory which can be reached by a browser. As it doesn't have some login-functionality you should add a login via .htaccess or other techniques. At the beginning of the php-file is the setting for the openttd-path. Change it to your actually openttd-installation, the directory which contains the openttd binary.
As this script read and write the openttd.cfg file and read the newgrfs list in the data/ directory the webserver must be allowed to do so. This means it must be got file-read-access (+r) and read + search access for the directory (+rx) to operate. You should backup the openttd.cfg file before testing it.

Please write some feedback about the script.
Attachments
index.php.txt
(22.62 KiB) Downloaded 6561 times
config1.png
config1.png (51.86 KiB) Viewed 41838 times
wickedgenius
Engineer
Engineer
Posts: 71
Joined: 06 Sep 2007 16:36
Location: Peterborough, United Kingdom

Re: webinterface for changing the openttd.cfg

Post by wickedgenius »

Hey,

This seems a little pointless because (as far as I'm aware) changing the config file while the game is running will not affect the running server.

I think the only useful application for a webinterface is if the server has been shutdown so that the config can be changed or if you could create one using a client side programming language (java, javascript) so that general users could use it to configure their file (I'm unsure if there are many apps out there to do this already).

I might be wrong about the server needing to be stopped though so please correct me if needed.

Just an added thing this would require that the game serer would also have a webserver with php module on the same pc which I don't think is all that likely.
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Re: webinterface for changing the openttd.cfg

Post by XeryusTC »

It is useful for when you restart the server and you want to change some settings, as happens almost every time we reset the #openttdcoop servers.
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
Progman
Engineer
Engineer
Posts: 76
Joined: 15 Jul 2006 12:55
Contact:

Re: webinterface for changing the openttd.cfg

Post by Progman »

It comes from an idea for the openttdcoop servers as new games start at about every week. So they edit the config-file by hand and start a new game. But changing the config-file by hand can be annoying as you normaly must look up about the diff_custom setting and must be carefully looked at the newgrfs paths. So this script helps you to change these settings. As you said. If the openttd-server doesn't run on a server without a webserver this script is you mentioned useless ;)
wickedgenius
Engineer
Engineer
Posts: 71
Joined: 06 Sep 2007 16:36
Location: Peterborough, United Kingdom

Re: webinterface for changing the openttd.cfg

Post by wickedgenius »

Hey,

I don't know about the routines that the people running these servers use, I presumed that the server was just run continualy and that it was left and when a new game was made it would be done as a normal offline game. I also thought that there were many gui programs for editing the config which have much the same look (I'm surprised if there aren't any like this as I could do one myself in VB within a couple of hours (it takes me a while to remember VB)).

But yes fair enough for people like openttdcoop I will agree that it can be put to goo use.
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: webinterface for changing the openttd.cfg

Post by Ammler »

I would use this script also for running a local game, because its much more comfortable then the NewGRF GUI of ottd self.

Here is a little patch of a small bug, with reloading grfsettings, which have parameters...

Code: Select all

$ diff -u original_progman.php publicserver.php
--- original_progman.php        2007-09-20 16:52:33.000000000 +0000
+++ publicserver.php    2007-10-15 23:15:24.000000000 +0000
@@ -185,7 +185,7 @@
                             $to_add .= $grf."\n";
                         } else {
                             // with parameter, save them
-                            $to_add .= $grf." ".$param."\n";
+                            $to_add .= $grf." = ".$param."\n";
                         }
                     }
                     $to_add = trim($to_add);

(Edited with proper diff, thanks do DaleStan and Frosch)

Greets
Ammler
Last edited by Ammler on 17 Oct 2007 15:13, edited 2 times in total.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: webinterface for changing the openttd.cfg

Post by DaleStan »

Normal diffs are surpassed in evilness only by ed scripts. Always generate unified or context diffs.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: webinterface for changing the openttd.cfg

Post by Ammler »

Hi

Yes, we still use that web interface and moved it now to our SVN Repo: http://svn.openttdcoop.org/tools/webconfig/

Participations are welcome. ;-)


Greets
Ammler
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: Bing [Bot] and 33 guests