Daily Lucky Numbers:
8
9
13
35
36
48

Problem Saving Score - Clumsy Bird

Started by phum, January 14, 2023, 09:55:52 AM

Previous topic - Next topic

phum

I started a new topic because I think this is a larger issue my with config than just the one game - Clumsy Bird.  I see this error in the console when trying to save a game in Clumsy Bird:

gameoversave.js:3
    Uncaught TypeError: Cannot read properties of null (reading 'innerHTML')
    at saveGameSmf (gameoversave.js:3:61)
    at d.onResetEvent (clumsy-min.js:1:11000)
    at d.reset (melonJS-min.js:16:10724)
    at Object.f (melonJS-min.js:16:11650)

Interestingly, Pac Man does not seem to have any issues saving scores. 
Any ideas? 

I did confirm that it created an .htaccess file in the Games directory (code below):

#<!-- Apache File Created by SMF Arcade 2.6.9.4 -->
<IfModule mod_headers.c>
    <FilesMatch ".(html)$">
        Header always set X-Frame-Options SAMEORIGIN
    </FilesMatch>
</IfModule>
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} arcade_score.php
    RewriteRule ./* ../arcade/arcade_score.php?act=arcade&scoreprep=prepscore
    RewriteCond %{REQUEST_URI} highscore=1
    RewriteRule ./* ../arcade/arcade_score.php?scoreprep=1&gameid=45&highscore=1
    RewriteCond %{QUERY_STRING} ^act=Arcade&do=(.*)$
    RewriteRule ./* ../index.php?act=Arcade&do=newscore
</IfModule>
<IfModule mod_security.c>
    <FilesMatch ".(zip|tar|rar|gz)$">
        SecFilterEngine Off
        SecFilterScanPOST Off
    </FilesMatch>
</IfModule>
<Files ^(*.jpeg|*.jpg|*.png|*.gif|*.tiff|*.bmp|*.php|*.html)>
    Order Deny,Allow
    Deny from all
    Allow from localhost
</Files>
AddCharset UTF-8 .php
AddCharset UTF-8 .html
AddCharset UTF-8 .htm
AddCharset UTF-8 .js
RemoveHandler .php3 .phtml .cgi .fcgi .pl .fpl .shtml

phum

Ok.  So I seemed to have fixed the save game for Clumsy Bird on my site (maybe it is only a Clumsy Bird issue???)  Here is what I did: commented out the first line of code in saveGameSmf() that tries to grab the 'savegamescore' field.  I don't see this field existing in any code anywhere in Clumsy Bird, and it seems to be getting passed in as a parameter.  So is this a bug?

function saveGameSmf(newhighscore)
{
//var newhighscore = document.getElementById('savegamescore').innerHTML;
var gameSmfFullscreen = document.getElementById("gameSmfFullscreen") != undefined ? document.getElementById("gameSmfFullscreen").value : 0;
if (parseInt(gameSmfFullscreen) == 1)
...

phum

Quote from: phum on January 14, 2023, 12:15:07 PMOk.  So I seemed to have fixed the save game for Clumsy Bird on my site (maybe it is only a Clumsy Bird issue???)  Here is what I did: commented out the first line of code in saveGameSmf() that tries to grab the 'savegamescore' field.  I don't see this field existing in any code anywhere in Clumsy Bird, and it seems to be getting passed in as a parameter.  So is this a bug?

function saveGameSmf(newhighscore)
{
//var newhighscore = document.getElementById('savegamescore').innerHTML;
var gameSmfFullscreen = document.getElementById("gameSmfFullscreen") != undefined ? document.getElementById("gameSmfFullscreen").value : 0;
if (parseInt(gameSmfFullscreen) == 1)
...

Thought I would mention this bug seems to exist in several of the games that are part of the game pack downloads.  I have found it in at least Clumsy Bird, Digger, and Hextris.

Chen Zhen


Those were the original games released for SMF Arcade when I first introduced HTML5/JavaScript game support.
I don't think IBP (Invision) Arcade or other common forum Arcade platforms had HTML5 game support at that time (I could be wrong).
When IBP Arcade came out with support I came up with a different save sub-routine that works for both & for various forum directory scenarios. The save routine in the Arcade support board stickies will likely work properly if you know how to apply it.

I'll have a look at those older games in the first HTML5 gamepack & update their save codes.
Thanks for the report.