Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Midp 2.0 Game reloaded

Options
  • 19-04-2004 2:56pm
    #1
    Registered Users Posts: 6,306 ✭✭✭


    http://csserver.ucd.ie/~s01bf007/php/index.php

    The link is the same the code is practically the same I changed some stuff like !== is now != and i hardcoded the directory and now the http://www.gelon.net/ wap emulator shows a link to the game but it doesn't seem to download:confused:. So if anyone could test it using a phone browser or could give me a reason as to why it wont download when you click on the link, I'd be thankful!!.


Comments

  • Registered Users Posts: 6,306 ✭✭✭OfflerCrocGod


    Oh and by the way the reason it gave all those errors is it seems the $listdir variable included the index.php in the directory name.....and obviously index.php is not a dir, so it spewed out errors for ages.


  • Registered Users Posts: 6,306 ✭✭✭OfflerCrocGod


    Further modifications to the code have resulted in a succesful download of the jar file!(I just deleted a useless ?id=; or at least I'm guessing it's useless) using the wap emulator browser I get presented with the file with a big PK at the begining, so I'm guessing I have achived nothing:D; the file is still downloading as a zip oh well it was worth a try. Oh and if The Cor ever reads this and is curious as to why it was giving those errors it might have to do with dirname() it appears to have changed with different versions. Anyway I tried:rolleyes:.


  • Registered Users Posts: 6,306 ✭✭✭OfflerCrocGod


    I'm not so sure it's downloading as a zip anymore the PK seems to have disappered:confused:.


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    try putting the JAD file in and see if that works.


  • Registered Users Posts: 1,785 ✭✭✭Farls


    sorry i haven't posted back sooner, first time at a computer with a net connection since saturday.

    A lecturer i know at college that deals with java and knows his J2ME will hopefully look at my code for me tomorrow and figure out what excactly is going on, I'll try downloading that file to the phone (left it at home) later on and see what happens.

    I'll modify the code and see if it might be a problem on my side of things. I had a weekend away from the project there though, was doing some unix scripting so i'm back on the ball now and rearing to go. Hopefully i'll have something sorted out tomorrow evening.

    But i'm starting to think its a problem with something other than the site now.

    Croc your playin a stormer

    Farlz


  • Advertisement
  • Registered Users Posts: 6,306 ✭✭✭OfflerCrocGod


    Well Farls what Hobbes said gave me an idea so I decided to see if I could get your code working on Nokia's Series 90 emulator. Unfortunately I can't seem to - I have a few other games I got from the web working on it, I've tried modifing your file structure putting everything into one jar file and making my own jad file. I've changed the Jar-URL in the jad file and anything else I could think of but it always crashes saying ALERT: NoClassDefFoundError: GameMIDlet. At first I though it was because I had the wrong structure in the jad file but I got it to display one of your .png's in the emulator window.....so I really can't figure why it wont start. I'd love to get it working cause I plan to make a few small phone apps during the summer.

    My sis downloaded the jar using her phone and it came up showing PK:rolleyes: , so it still gets the MIME type zip. Anyway I have exams in 6 days so I can't really do any self-teaching yet:D. If you use the Nokia emulator please show me your jad file , it may help me, otherwise I'm fresh out of ideas :confused:. By the way I hope you dont just run your main class when you test your code and that you actually use the jad file with an emulator; I dont really know how testing works for you but I'm supposing that using the jad file would be the closest thing to actually using your program on a phone. If that made no sense at all disregard:p, cause I'm mainly guessing.


  • Registered Users Posts: 1,785 ✭✭✭Farls


    strange that.

    The emulator i use is the sun wireless toolkit v2.0_01. I think you hit the nail on the head with my .jad file being wrong. I've changed it around and i'll email you an early version of the game that works, you'll not get the exception class not found anymore i've got rid of that.

    I'll email you the full application as it is, if you have the wireless toolkit you can drop it into the apps folder and run it. but the .jar and .jad files are in the bin folder.

    You have exams coming up so its cool if you don't got time

    cheers

    Farlz

    [edit] u don't have your email posted up so i'll pm you mine and sure email me if you want the code [/edit]


  • Registered Users Posts: 6,306 ✭✭✭OfflerCrocGod


    Na it's cool Farls; I'll let you get on with your work I got the Wireless Toolkit last night just to see if I could get it to work using it still no luck. I'm cramming now for the exams so I've given up on it. When I have some time during the summer though I intend to make my own little game(using the website FAQ and guides in the other thread) hopefully I'll get it working :D.


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    If you want send it to me (jar/jad - source only if it is your willing to share), and I'll give it a bash when I get home.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    I’ll accept that the ‘!==’ was a bug, I have a version of the same script elsewhere and it doesn’t have that bug there, so ‘tis a bit odd.

    The ‘index.php’ is an item in the directory listing; nonetheless, it would not cause the error you described as apart from anything else it’s caught in the following line:
    [PHP]
    if ($file != ".." && $file != "." && $file != "index.php") {
    [/PHP]
    My guess is that the most likely your problem came from a lack privileges on the server to read the contents of the directory.

    Hard coding the URL defeats the purpose of the script, as a direct link will rely on the installed MIME types on the server - BTW, that JAR file is sending out a default text/html content-type. The original script would check for an id parameter and treat this as the name of the file which it would open up with the FSO and output as a binary stream with the correct HTTP headers.

    Otherwise a much simpler script to use for your specific JAR would be:
    [PHP]
    <?php
    $fp = fopen ("MenuScreen.jar", "rb");
    $JarFile = fread($fp, filesize($id));
    fclose ($fp);
    header("Content-Type: application/java-archive");
    header("Content-Disposition: inline");
    header("Content-Length: ".strlen($JarFile));
    echo $JarFile;
    ?>
    [/PHP]
    Of course, if as I’ve surmised, you lack privileges on the server to read the contents of the directory, the script will not work under any circumstances.

    Finally, not all phones care about the Content-Type, most do, some don’t. The Nokia 7650 doesn’t, for example.


  • Advertisement
  • Registered Users Posts: 6,306 ✭✭✭OfflerCrocGod


    Originally posted by The Corinthian
    The ‘index.php’ is an item in the directory listing; nonetheless, it would not cause the error you described as apart from anything else it’s caught in the following line:
    [PHP]
    if ($file != ".." && $file != "." && $file != "index.php") {
    [/PHP]
    Sorry I wasn't clear - i really should have posted the error; what it complains about is that blah/blah/s01bf007/php/index.php is not a valid directory, which it isn't. From what I remember of your script you used dirname() to translate the file name to a directory path; that's were it went pear shape - it seems the translation did not work out and the file index.php was still attached to the directory string when it was inputed to @opendir(string dir name) - resulting in errors and failure. That's my take on it (guess:)). Hobbes I've PM'ed Farls my e-mail addy I'll be hosting the files - I'll try that new PHP script that The Corinthian put up.
    Originally posted by The Corinthian
    Of course, if as I’ve surmised, you lack privileges on the server to read the contents of the directory, the script will not work under any circumstances.
    If I make the dir totally free (777) and the files within also 777 should that tale care of the reading - or does it all depend on the permissions that PHP is granted on the server?.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Originally posted by OfflerCrocGod
    Sorry I wasn't clear - i really should have posted the error; what it complains about is that blah/blah/s01bf007/php/index.php is not a valid directory, which it isn't. From what I remember of your script you used dirname() to translate the file name to a directory path; that's were it went pear shape - it seems the translation did not work out and the file index.php was still attached to the directory string when it was inputed to @opendir(string dir name) - resulting in errors and failure. That's my take on it (guess:)).
    No, dirname() will only return the directory name, even if $_SERVER["PATH_TRANSLATED"] originally returned the filename also. As such when @opendir() is applied to it, only the directory path is present. I suspect that’s why I used dirname() to begin with – to parse out the filename.
    If I make the dir totally free (777) and the files within also 777 should that tale care of the reading - or does it all depend on the permissions that PHP is granted on the server?.
    PHP needs the permissions granted to it.


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    Tested your game (cute :) ). It works fine.

    I haven't been able to test it on a device yet, but from a quick look at the JAD settings you have specified Mobile Access when you shouldn't need it?

    It could be the device is set to disable/disallow midlets that want access to the outside world. Just a quick guess.


  • Registered Users Posts: 1,785 ✭✭✭Farls


    hmmmm thats something that i haven't thought about at all. I'll check the phone out tomorrow, possibly something in the settings on it. I'm not quite sure about it cuz it's not my own. Its a Sagem my v-65 btw

    I have the gameplay going a lot better now hobbes. You actually finish the game and do fastest times, etc.

    Just figuring out the RMS now on it so to save the fastest times

    Farlz


Advertisement