The online racing simulator
Searching in All forums
(239 results)
Anarchi-H
S3 licensed
Not quite sure I get what you mean, but if you are planning what I think you are planning, then it's very similar to PPF.

You could include just one of the providers and it would in turn require the base provider, but apart from that it could be used stand alone. I think that is what you are planning isn't it?

The only difference I see is that in PPF the fetcher resides in an inherited base provider class where as yours resides alone.

...unless you were going for the procedural approach and by 'requiring' the files they executed automatically. Still, similar approach, different implementation.
Anarchi-H
S3 licensed
Quote from filur :I think there's one or more .ini settings for socket timeouts, but i can see why you'd use PEAR stuffies. I'd probably be a PEAR user myself if the contents weren't distributed thru and / or relied on PEAR.

There is indeed but I wanted it to be compatible with shared hosts.
I'm far from a PEAR user. They just happened to be on hand when I did the prelims.
Anarchi-H
S3 licensed
Quote from filur :I've looked at PPF twice i think, but as i can't stand PEAR i've never tried it.

Sounds good, although watch out for speed issues on the charts if you are creating objects for each record. My initial solution was entirely OO but I found it to be much slower than arrays for the dataset with so many objects, even on PHP5. (Unless the charts output has changed; it's been a while since I tested)

PPF will run under PHP4 (>4.2.0 I think, although maybe 4.3), and fair point about PEAR. It's pretty crap but is only used for HTTP_Request (because fopen can't do timeouts and I couldn't be arsed to write my own HTTP client) and Cache_lite for the file cache.

Files that require PEAR are (IIRC) ppf/caches/lfsworldfilecache.php && ppf/providers/lfsw/baseprovider.php ... possibly some hackish variable poking and stuff in the sub-providers.
It would be pretty easy to port it to other libs since there aren't that many references made to PEAR specifics.

Yeah, anyway, point wasn't in the architecture; that was just provided so that you might be able to find the stuff you want. You can rip it apart and mangle it about as much as suits you, or just use a single line of code if it is useful.

I forgot to mention, ignore the license. I'm essentially opening this up for a free for all so no credit or anything silly is required.
Anarchi-H
S3 licensed
Your design ideas are very similar to how PPF is architectured but I no longer have time to update it since taking a full time PHP developer position.
Rather than going to waste, perhaps it can be of some use to you, even if you don't use the code directly.

PPF is architectured like this ...
  • Tailored Interfaces
    Simple implementation specific interfaces for an end programmer to use that will provide an easy way to 'do it all' without compromising the core code. (Only the SimpleInterface is implemented at present which provides a very similar API to LFSWorldSDK)
  • Generic Interface
    This handles all requests to the 'providers' (explained below). It takes care of default params, caching, handling the request etc. It is completely isolated from a specific provider so that if multiple sources for LFSWorld data pop up in the future then only a new provider needs to be written.
  • Providers
    The base provider handles the HTTP request, decompression and error checking. The sub-providers take care of the parsing and (like in your ideas) are each in their own file.
  • CacheProviders
    Cache providers provide different means of caching. There is currently a file based cacher and an sql based cacher (only works with hosts atm because the other providers need pre-insert and post-select callbacks writing for them.
  • Lookups
    The lookups provide a means of translation between common formats that LFSWorld uses, and that someone using PPF might need. i.e. convert XFG->XF Gti or 000 -> Blackwood GP
  • Utils
    These are small bits of code that perform useful functions. For example, there is an extremely optimized Colour and Charset parser with output callbacks so that only a callback needs to be written for a new kind of output. (CSS & HTML ones exist already)
    Other functions include ones to decompress LFSWorld data, check for LFSWorld errors and make LFSJoin/Join2LFS compatible links.
A quick overview of how these fit together looks like this...
User creates TailoredInterface (which extends GenericInterface)
User calls a 'do it all' method on the TailoredInterface
TailoredInterface creates provider instance
TailoredInterface creates cache provider instance
TailoredInterface does pre-request magic
TailoredInterface calls GenericInterface to make a data request and passes provider & cache objects to GenericInterface
GenericInterface checks with provider that all params are set
GenericInterface checks with cache to see if a valid entry exists
Assuming no cache entry, GenericInterface calls provider to get data
Provider makes request to LFSWorld
Provider decompresses data and checks for errors
Provider returns data to Generic Interface
Generic interface passes returned data to cacher
Cacher stores data
Generic Interface returns data to TailoredInterface
TailoredInterface does post-request magic (display and such)
The End

If any of that interests you, feel free to pm me for further explanation.
If not then maybe someone else might find use it.
Anarchi-H
S3 licensed
Quote from Dygear :It's not like your saving that much money. We're talking like .0004 pence here per query.

Depends on the size of the query, but I wasn't complaining, just enquiring. You would have to get a huge amount of visitors for this to impact you in a majorly negative way and even then that could be negated just by increasing the client side cache time.
Anarchi-H
S3 licensed
Quote from filur :While i do agree on mixing code with presentation, i would suggest pretty much anything to avoid passing the object around as a global variable.

I guess by misuse of inheritance you're saying inheritance is in this case completely unecessary, if so i would basically agree. ...

Not quite; if I were to aggregate an instance of LFSWorld to MyLFSWorld it would look like this;


<?php 
php
class MyLFSWorld
{
    var 
$LFSWorld null;
    function 
MyLFSWorld($idk)
    {
        
$this->LFSWorld =& new LFSWorldSDK($idk);
    }
}
?>

I'm not sure where you got the idea of global from
The definition of an aggregation is when one object belongs to another, and this owned object will be created and destroyed with/by the owning object.
As you can see, it is a minor departure from inheritance, but an important one because you no longer have to worry about namespace clashes between the base lib and the "extended" functionality, and (with PHP5) you don't have to worry about them accidentally accessing a protected var. (Not that this applies here )

Quote from filur :I would expect Scawen to say "until i fix the black screen bug, don't start LFS in fullscreen" (might've been windowed).

Fair play, but I bet it would be high on his list
Anarchi-H
S3 licensed
Quote from filur :What makes it bad design?

Misuse of inheritance and in the specific example, mixing (business) logic with presentation. A quote from the great wiki itself in the 'Common Mistakes' section.
Quote from Wikipedia :Object-oriented programming
Overuse of inheritance when composition or aggregation may be more appropriate. It has been suggested that training materials over-emphasizes inheritance, perhaps because it is easier to illustrate than the alternatives.

In this case, aggregation would be more appropriate if you are going to extend it with OO.
I understand it is difficult to to explain the concept of a class to new coders, let alone the difference between ways of extending them but education is key and in this case it is showing new coders the wrong way to do it.

The code doesn't work in that configuration for a reason. It may not be your fault, it may be a PHP bug, but regardless it is your responsibility as the developers to find it, and even more so if you can replicate it!
You wouldn't expect Scawen to say "It just doesnt work, here is what you'll have to do instead".

Sorry for the lecture, but you did ask
Last edited by Anarchi-H, .
Anarchi-H
S3 licensed
Quote from Dygear :

<?php 
$teams 
$LFSWorld->get_teams();
echo 
"<p>Starting teams list</p>\n";
foreach (
$teams as $this_team) {
    echo 
"-----------------------------------------\n";
    echo 
"Team: {$this_team['team']} ({$this_team['tag']}) \n\n";
    echo 
"Members: {$this_team['nr_members']} \n";
    echo 
"Website: {$this_team['url']} \n\n";
}
echo 
"<p>Finished teams list</p>\n";
?>

Seems that when you place it inside a function like that, it simply will not work. I'm running 5.2.0 on my test box (and production box) and the issue remains. I would simpley extend the lfsworld class with your own functions.

Your code to decompress c=1 doesn't work (on my box at least), and is a bit nasty anyway.
This works just as well...


<?php 
return gzinflate(substr($str10));
?>

I can't replicate the error you and MikeB are talking about so I can't offer any solutions. However, scope should not matter. It doesn't matter if you are in calling from a function or a global scope, the code should still behave the same. (For reference I'm running Apache 2.0.59 w/ PHP5.2.0)

Extending LFSWorldSDK in that manner is very bad design form and could just be a work around to a more serious issue.
Premium Stat clarification
Anarchi-H
S3 licensed
Imagine I made these requests to a single LFSWorld pubstat action....
Req Timestamp Premium stat
--------------------------------
1 14:52:00 false
2 14:52:01 true
3 14:52:10 true

Where premium stat = true, ps=1 is specified, otherwise it is not.

I know I should not be charged for request 1, and I know I should be charged for request 2 .... but what about request 3?

Premise being, I could get request 3 for free if I don't specify ps=1, but what happens when I do specify ps=1? Will LFSWorld take in to account the last request time for this provider and determine whether I should be charged for it or will it charge me regardless just because ps=1 is there?
Anarchi-H
S3 licensed
Eheh, I think you underestimate the integration & modification that would require. You are not talking about an admin interface there; you are talking about an entirely embedded scripting API.
Anarchi-H
S3 licensed
-----------
?action=pst
-----------
(online statistics of one racer)

requires: &racer=<racer>
optional: -
returns: distance in metres
...
last_activity_time(*) (Unix timestamp)
current / last track(*)
current / last car(*)

(*) At time of writing this document, these values are not yet available for everybody - they will be collected over time (someone has to race online at least once).

What are the values for racers that have not yet had data collected?
Anarchi-H
S3 licensed
Forgive me for being blunt but isn't your code over complicated?
Why put the names in a string only to explode them?

If you don't need the comma delimited list, a tiny alteration to filurs code would be more efficient...


<?php 
while($row mysql_fetch_array($res)){ 
  
$TeamMembers[] = $row['nick']; 
  
$InGameName[] = $row['nome']; 
}
?>

And even if you do need the comma delimited lists, imploding the array would be a better way to achieve it because implode is quicker than explode and you won't need to remove the trailing comma.


<?php 
$nicks 
implode(','$TeamMembers);
$nomes implode(','$TeamMembers);
?>

Anarchi-H
S3 licensed
I bought some Sennheiser HD25s last year and they are amazing for their sheer clarity, isolation & build quality. However, they have absolutely no sound stage whatsoever since they are monitors.

My advice is that if you are looking for a pair to give you directional feedback then avoid monitor headphones since they are designed to let you hear exactly which ear the sound is coming from, not which direction. All 3d effects are totally lost, at least with the HD25s.
Anarchi-H
S3 licensed
heh, cool unless you happen to get it and not realise... especially if you have a printer with expensive ink.
Anarchi-H
S3 licensed
I'd say there is actually a fair chance that higher res versions do exist. Most digital artists I'm aware of (when it comes to textures and digital paintings etc) work on massive canvases, then shrink the file later.

The whole reason is that it is much harder to add fine details to small textures than it is to add them to a large one and shrink it.
Also, scaling stuff down looks inifintely better than scaling it up.
Anarchi-H
S3 licensed
True... never considered anything that restricted before, but then PHP wouldn't be able to update a file either, hence making a file or sqlite based cache totally impossible on such a restrictive setup.

Unless of course you mangled up some kind of system to have read only directories, but writable files. Still, alot of work, for what?

I know if my host was that restrictive I'd have chucked them a long time ago :-p
Anarchi-H
S3 licensed
Quote from the_angry_angel :Sounds like the inappropriately named php "safe mode" is to blame. When this is in effect, unless you "own" the file / directory, php won't read it. [un]fortunately theres no way (without code hacking) to remove restrict individual functions.

If this is the case, simply set the cache folder to writable by PHP, and have PHP create the cache file (which I should imagine it does anyway), then it will be owned by PHP and therefore stat-able by php.... unless the server config is totally backwards of course
I had that problem with my first version of the server search which was hosted on f2s.

I can't say I've ever come across a server that has had filemtime put on the blacklist, but I guess that could be possible too.
Anarchi-H
S3 licensed
Quote from Dygear :Flat file is the best way if you ask me. That is how I do it at least. I infact have two flat files, one file has the seconds past unix epoch in it my system read that file and and askes if it is 300 seconds past last update. 300 seconds is equal to 5 minutes. if it is, then it sets the variable $file to the lfsworld URL that I would like to get the information from. If is is not past 300 seconds then $file points to the cache. It then reads the file ( or the information from LFSWorld ) and places that information into another generic variable called $data. The data is then parsed by my parse_ssv function. SSV is Space Separated Value. It returns an array and is ready for use.

Why use two files when you could just use filemtime on the cache file? illepall

If it is a simple display of details then flat file should suffice, but if you want to start comparing stuff you are better off investing time in making it an sql cache because it will save you writing your own comparison engine in your language of choice.
Anarchi-H
S3 licensed
Quote from P2M-Unixseb :Hello world,
i would be verry interested in having the abilitie to retrieve the online pb of several users in just one query instead on severals one,
IE : http://www.lfsworld.net/pubsta ... &action=pb&racer=[usr1,usr2,usr3......]

Do you think this is possible ?

No. It's been asked before. However, you can pay for the premium service and get multiple pbs without the tarpit affecting you. It's best to do it in a script which doesn't render data to an end user though else they'll be faced with an apparently slow loading page.
Anarchi-H
S3 licensed
21 years ... where the hell did they all go.
Take one glance at me though and you'd think I was only 14 (Approximate average guess at age ranging from 12 to 18, one per customer, no purchase necessary)
Last edited by Anarchi-H, .
Anarchi-H
S3 licensed
Hehe, been there, done that DarkTimes. It is nigh on impossible to make code that is everything to every project for everyone... It just isn't going to happen.

The best you can do is keep it modular so that as little code has to be re-written as possible to facilitate the specific extra features any site needs. If it looks like it might be useful to another site, bung it in the repository with everything else.

That way the only bit you have to re-write (most of the time) is the 'glue' that sticks all of your random code lumps together in to some intelligible (or not sometimes) API.

As for my editor... I usually have no less than 8 or 9 gVim windows open, a couple or three Firefoxes and photoshop, and when I'm debugging CSS about 8 other versions of various browsers. Oh, and not forgetting at least one winamp
Anarchi-H
S3 licensed
Quote from steve30x :This cost me 2,842.76 USD

How long ago?!

For $1750 you could get a worthy X2 machine, $1600 if you exclude the sexy case. Drop the X2 to a 3700 like suggested and without the case it becomes sub $1500.

It's an AMD 3800 X2, 1gig of Corsair TwinX 3200, Asus AN8, an XFX 256Mb 7900GT XXX (1650/560), 300Gb storage, 480w Enermax PSU, Creative X-Fi & a 16x DVDRW. The sexy case would be a CoolerMaster WaveMaster.

TBH though, If you want AMD, I'd save a few more pennies and wait for AM2 to avoid having to go through a major upgrade again when you upgrade the next time. It's not like your present machine is that slow.
Anarchi-H
S3 licensed
The thing that makes that card so expensive is the 64mb of xram that is supposed to improve performance by reducing CPU load by the sound side of things. From what I've seen it works, but unless the rest of you machine is the muts nuts already, you'd be better off going for a slightly less pricey one and putting the money you save towards your next upgrade.

Do you really need the remote and live drive? If not, the X-Fi Xtreme Music would be a much better choice at half the cost. Better still, if you arent concerned about the latest EAX effects and some fancy features, you could go for an Audigy and save even more.

The biggest advantages of a dedicated sound card is the SNR and the performance. If you use sensitive speakers / headphones, all the interference from the computer will drive you nuts. Around 100db SNR is only just audible on really sensitive equipment.
The performance gains aren't really that noticable on most machines. Only a few FPS here and there but it depends on the motherboard.
Anarchi-H
S3 licensed
The colour coded sectors are cool, but asides from that, how is it different?
Anarchi-H
S3 licensed
Just to clarify, I said nothing of my opinion of the legality of anything here. I couldn't care less as to the legal status of weed, but IMO all public smoking of anything should be banned. That way, if you want to kill yourself with tobacco / weed / whatever, that is your call. At least you won't be inflicting it on others involuntarily.

As for "knowing" that cannabis is not a gateway drug; as someone said, you are truly naive if you believe that you KNOW that.
I can personally name 7 people off the top of my head that have started on weed and gone on to harder stuff versus 4 that have just stuck with weed.

Just because your social group hasn't gone on to harder stuff, doesn't mean everyone is like that.
FGED GREDG RDFGDR GSFDG