OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3.2)

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

Moderator: OpenTTD Developers

dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by dihedral »

you have not installed php5 properly!

you are either missing something like
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
or
AddType application/x-httpd-php .php

if, in your apache2 config folder in /etc
might be /etc/httpd or /etc/apache2 or /etc/apache
run grep -r php *
that should show the lines above, if they have a # at the beginning of the line, they are commented out, remove the #
or add the lines as needed for that distribution of linux
maartena
Route Supervisor
Route Supervisor
Posts: 470
Joined: 11 Jul 2003 04:53
Location: California, U.S.A.

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by maartena »

dihedral, thanks for your help.

I uninstalled php5 and re-installed php5 from scratch, as well as pear.

When I run grep -r php * like above, it generates the following output:

defiant:/etc/apache2 # grep -r php *
conf.d/php5.conf:<IfModule mod_php5.c>
conf.d/php5.conf: AddHandler application/x-httpd-php .php4
conf.d/php5.conf: AddHandler application/x-httpd-php .php5
conf.d/php5.conf: AddHandler application/x-httpd-php .php
conf.d/php5.conf: AddHandler application/x-httpd-php-source .php4s
conf.d/php5.conf: AddHandler application/x-httpd-php-source .php5s
conf.d/php5.conf: AddHandler application/x-httpd-php-source .phps
conf.d/php5.conf: DirectoryIndex index.php4
conf.d/php5.conf: DirectoryIndex index.php5
conf.d/php5.conf: DirectoryIndex index.php
httpd.conf:# | |-- mod_php4.conf . . . . . . . . . . (example) conf that comes with apache2-mod_php4
httpd.conf:AddType application/x-httpd-php .php .phtml
httpd.conf:AddType application/x-httpd-php-source .phps
mime.types:application/x-php php php3 php4
sysconfig.d/loadmodule.conf:LoadModule php5_module /usr/lib/apache2/mod_php5.so
vhosts.d/vhost-ssl.template: <Files ~ "\.(cgi|shtml|phtml|php3?)$">
vhosts.d/vhost.template: # Include /etc/apache2/conf.d/mod_php4.conf

- as far as I can see the only line that is commented out has to do with php4.

There is no libphp5.so on my system, instead there is a mod_php5.so which appears to do the same as the libphp5.so file, and it is being loaded.

I used to have kubuntu installed, now I have OpenSUSE 10.3 (fresh format).

I'll give it some more tries, but so far I haven't had the best of luck.
Guess what! I got a fever! And the only prescription...... is MORE COWBELL!
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by dihedral »

no offence, but quite frankly - this is trouble you are having with apache2 and php5 on a openSUSE distribution of linux. it is not an issue with OpenTTDLib. once you get that far, i am happy to help - but right now, i do ask you to refer to the openSUSE wiki and/or one or more of http://www.linuxquestions.org, http://www.google.com/linux, http://www.php.net, http://httpd.apache.org or any other website related to the issue you are experiancing.

once you get php and apache working i am happy to contintue the trobelshooting.

compare it to: you phoning microsoft because thunderbird is unable to contact the mail server due to a router misconfiguration!

i hope you can understand and accept this step of mine.
maartena
Route Supervisor
Route Supervisor
Posts: 470
Joined: 11 Jul 2003 04:53
Location: California, U.S.A.

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by maartena »

Not a problem at all, was just wondering whether your linux knowledge was strong enough to help me out that's all. :P

I have decided anyways I am not liking OpenSUSE all that much to begin with, and I had absolutely no problem getting PHP5 and Apache2 to work in Kubuntu, so i have decided to install Kubuntu 7.10 again on my server.

I'll let you know my progress. :)
Guess what! I got a fever! And the only prescription...... is MORE COWBELL!
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by dihedral »

maartena wrote:Not a problem at all, was just wondering whether your linux knowledge was strong enough to help me out that's all.
my linux knowledge is 'strong' enough to help you - i just refuse to, because 1. it's not related to my piece of software and 2. i dont do other peoples work - i.e. if people show they have put some effort into it themselves i am happy to help - but then please post it in a forum/thread relevant to the issue
maartena
Route Supervisor
Route Supervisor
Posts: 470
Joined: 11 Jul 2003 04:53
Location: California, U.S.A.

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by maartena »

I'm back ;)

Got everything on the linux side working now.

Example.php works marvelously and returns me info on 1 server.

I edited example2.php into index.php with my servers on it, and am getting this error:

Server: localhost:3979 Error # 40 Message: cannot read from: cache.xml
to report this issue please search for 'ERROR_DEBUG' the html source for ths page!

so.... i checked the source, and it told me to E-MAIL a large set of code to you, and a link to the e-mail address. I did this as requested, so you should have e-mail :P

I'll see if there is anything I missed as well.

Maarten
Guess what! I got a fever! And the only prescription...... is MORE COWBELL!
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by dihedral »

looks to me like you are 1. unable to read a very clear error message:
cannot read from cache.xml
which states just that!!
2. you are unable to read the supplied documentation

Do you really think i spend hours of my free time to write documentation as clear as that so some [*] fellow can come along and claim my software has a bug where actually YOU failed to setup the cache file correctly?

READ THE DAMN DOCS!

http://openttdlib.dihedral.de/docs/Open ... e.pkg.html

EDIT:
[*]: offensive wording removed due to forum rules violation :-) - thank you for pointing that out athanasios
though when thinking about it, i am actually not sure if 'some dumb, silly fellow' can be offensive to any one specific person, as i am not addressing 'one' person, but more describing a handful of people.
maartena
Route Supervisor
Route Supervisor
Posts: 470
Joined: 11 Jul 2003 04:53
Location: California, U.S.A.

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by maartena »

Okay, no need to get pissy with me.

I actually DID read the documentation beforehand, but still could not get it to work. I gave the whole world writing rights to that folder at one point but it still would not work. I actually had to start from scratch, delete the entire folder, and extract openttdlib again etc to get it to work, and it finally did.

I read your documentation just perfectly fine. But I can see there is absolutely no room in your narrow minded view for someone who has just mediocre knowledge in the the world of Linux.

Yes I spend a lot of time reading manuals and documentation.
Yes I spent time reading yours.
Yes your comments are just plain rude and unneeded.
Guess what! I got a fever! And the only prescription...... is MORE COWBELL!
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by athanasios »

It's time for a beer! :D
Attachments
pregnant_beer_chick.jpg
pregnant_beer_chick.jpg (42.62 KiB) Viewed 6068 times
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by DaleStan »

maartena wrote:I gave the whole world writing rights to that folder
Let me give you a hint: There's a world of difference between "cannot read file" and "cannot write file".
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
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by dihedral »

maartena wrote: Okay, no need to get pissy with me.
i very seldom get really 'pissy'... and if i do - i tend to have a reason... i am no where near 'really pissy' right now!
maartena wrote: I actually DID read the documentation beforehand, but still could not get it to work.
reading alone gets you not far - reading and acting upon the read does the trick - or posting a question regarding a part of the docs that is not clear or needs further details!
maartena wrote: I gave the whole world writing rights to that folder at one point but it still would not work.
OpenTTDLib Documentation wrote: the file cache.xml needs to be located in the directory of your OpenTTDlib copy (i.e. directory where example2.php is located)
i beleive you have that just fine... as it's in that location in the released archives
OpenTTDLib Documentation wrote: If the webserver does not have read and write access, OpenTTDLib will fail with an exception
funny that - i mention the fact that it will have an exception :-)
if you are using any debian based system, the webserver user is www-data, and the webserver goup is www-data too. chown and chmod is your friend in that case.
maartena wrote: I actually had to start from scratch, delete the entire folder, and extract openttdlib again etc to get it to work, and it finally did.
OpenTTDLib Documentation wrote: If cache.xml is not present, OpenTTDLib will try to create it - giving write access to the webserver on that directory and removing cache.xml can be helpful when troubelshooting.
:-)

maartena wrote: I read your documentation just perfectly fine. But I can see there is absolutely no room in your narrow minded view for someone who has just mediocre knowledge in the the world of Linux.
yes - blame me - the "narrow minded" one - i must surly be at fault for any problems you may experiance.
NEWSFLASH: dihedral is not responsible for your "mediocre" linux knowledge, and is also not responsible for you being unable to direct your questions to an appropriate crowed.
maartena wrote: mediocre knowledge in the the world of Linux
thank you for underlineing what i assumed anyway. but as you clearly know this of yourself, perhaps start pocking man pages and other docs on "the linux world" which will inform you how one changes ownership and permissions of owner, group, all (and can actually explain the difference between read and write and execute and stickey, etc)
maartena wrote: Yes I spend a lot of time reading manuals and documentation.
Yes I spent time reading yours.
Yes your comments are just plain rude and unneeded.
i find it pretty rude that you are 'bombarding me' with problems unrelated to my lib! that you are trying to tickle my pride with questioning my linux skills to get some extra help and that you seemingly incabable (please not the polite 'seemingly' - as this is leaving room for me to be at error) of directing questions to the correct forums/threads.

this thread is for OpenTTDLib and OpenTTDLib only! it is not a 'linux howto' it is not a 'php howto' or anything else!
'cannot read cache.xml' in fact may seem as a failure on my side - but is described in the docs.
OpenTTDLib Documentation wrote: OpenTTDLib's caching support makes use of the SimpleXML object, available as of PHP 5.1.3 - If you disable the caching functionality, however, you will be able to use an earlier version of PHP5, refer to the Settings documentation, specifically the section on OpenTTDLib::OPTION_CACHE_NEWGRF.
but one thing i thank you for: you have given me reason to add a page in the docs, describing possible error messages, and which ones may be submitted as bug reports and which ones are totally uninteresting, as they are no bug or issue that arrise from my code.

i will ask the moderators to remove any further posts i find inapropriate in this thread. if need be, i shall ask them to close it, any further info will then be available on the OpenTTDLib website (http://openttdlib.dihedral.de)

so now - let us continue and drop the previous quarrels - please only post issues that are 'directly' related to my software and are not described in the documentation. if you should have troubble, let me know 'what you have done sofar' and 'what in the docs you do not understand'.
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7595
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by Born Acorn »

athanasios wrote:It's time for a beer! :D
Stop that. It's pure spam. If you don't like the way a thread is going, contact a moderator. Don't try to derail the thread any further in the hope that the discussion will right itself. Do not do it again or there will be warnings.
Image
xboxoutlaw
Engineer
Engineer
Posts: 3
Joined: 11 Jan 2006 20:20

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by xboxoutlaw »

How do I get example2.php to display a Dollar sign instead of the Euro?
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by dihedral »

xboxoutlaw wrote:How do I get example2.php to display a Dollar sign instead of the Euro?
example2.php uses pear's HTML_Template_Sigma templating class. templates are located in the ./template folder. edit the file OpenTTDLib.example.tpl.html

search for &euro; and replace with $ (lines 293, 294, 295)

if you however need to change to another currency that in fact has a different currency conversion calculation in openttd (i.e. pounds) you will also have to edit example2.php, search that file for
bcmul( $player->company_value, 2 ) (lines 84, 85, 86)
xboxoutlaw
Engineer
Engineer
Posts: 3
Joined: 11 Jan 2006 20:20

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by xboxoutlaw »

Thats funny because I did change those 3 lines but it did not work. It was not until I read what you posted that I realized when I edited that file, I saved it to my hosted site not my local site which is what I am using for this. LOL! Thank you very much for the quick reply. I hate myself for not catching that.
User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3)

Post by pavel1269 »

1) How can i found that server is offline? I am using this atm:

Code: Select all

try {
	$openttd -> queryServer($host, $port);
	$server_info	= $openttd->getInfo();
	$connected = true;
}
catch(OpenTTDLibException $e) {
	$connected = false;
}
But its maybye wrong.

2) Otherwise when server is offline its giving me:
Warning: Invalid argument supplied for foreach() in D:\Work\Www\ottd\includes\OpenTTDLib.php on line 1455
At least, i need to kill that warning :wink:
Any ideas?
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3.1)

Post by dihedral »

updated to support OpenTTD as of r13713, there was a UDP packet change ;-)

find downloads in first post of this thread, or at http://pub.dihedral.de/OpenTTDLib/
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3.2)

Post by dihedral »

New release: 0.3.2
- reflects changes made in OpenTTD r16175
- and some other updates.

download from first post or http://www.ohloh.net/p/openttdlib

enjoy
okdewit
Engineer
Engineer
Posts: 54
Joined: 30 Sep 2007 21:55

Re: OpenTTDLib - fetch live game data (UPDATE - VERSION 0.3.2)

Post by okdewit »

Sorry for bumping an old thread, but is anyone still running this library succesfully?

I get errors when using 0.3.2 and the demopage on the downloadsite also gives PHP errors. There is a folder called dev which runs a working version of the library, but I cant download it since its not zipped and the webserver returns php files as html code when I execute wget on the dev folder.

Any help / links / working versions appreciated!
Image
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 15 guests