Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Force Download (https://forums.graalonline.com/forums/showthread.php?t=134257277)

oo_jazz_oo 12-13-2009 03:17 AM

Force Download
 
I want a function to force a download of a file on the player.

When players edit an image file, it can screw up a lot of things...
An example, if on player worlds that use staff blocks (but don't set the shape to block), all you have to do is delete the file, or edit it, and like magic...its gone.

There should be a way to force a file download, so the image is re-downloaded, and no problems occur.

If this could be added in an update, or even the next version, It would be very much appreciated. (Or even anything similar to this)

WhiteDragon 12-13-2009 03:29 AM

It shouldn't be terribly hard to implement something that checksums the file on the server, and compares it to the checksum on the client each time the file gets buffered into memory.

But, you should really just setshape on something that important.

fowlplay4 12-13-2009 03:30 AM

I use an array of common images, and isimgpixeltransparent to catch people who modify them :)

cbk1994 12-13-2009 04:23 AM

You shouldn't be using staff blocks for anything important, it's way too easy to "hack" over them.

oo_jazz_oo 12-13-2009 05:05 AM

The staff block was just an example. XD

I was just requesting this feature, and couldnt think of another example on the spot. -.-

oo_jazz_oo 12-14-2009 04:50 AM

Sorry for double post, but I found this while searching for scripts.

HTML Code:

fileupdate(str) - returns boolean - requests the download or reloading of a file
But, I can't get this to work...even if it does work.
I tried just the image file, with the folder path, relative to levels folder, etc. But I just can't get it to work...

Any help?

fowlplay4 12-14-2009 05:06 AM

fileupdate is kind of useless nowadays, it was more so back when you did File I/O via Scripts and the files didn't appear in the File Browser until you did /refreshfilelist.

I don't think there's a command to actually force a re-download on the client-side. You can do this though on the server-side to have everyone re-download it.

PHP Code:

function onCreated() {
  
forceReDownload("levels/images/block.png");
}

function 
forceReDownload(file) {
  
temp.img.loadstring(file);
  
temp.img.savestring(file, 0);
} 


cbk1994 12-14-2009 06:05 AM

The way I imagine it's best to do is to have a list of file sizes of common images, and if they're off from the server's file size, disconnect the player. Use a "base" type update package to download the images on login.

Just a theory, though :p.
Quote:

Originally Posted by fowlplay4 (Post 1544238)
I don't think there's a command to actually force a re-download on the client-side. You can do this though on the server-side to have everyone re-download it.

I never thought of doing that, nice :).

coreys 12-14-2009 09:15 AM

Quote:

Originally Posted by cbk1994 (Post 1544243)
The way I imagine it's best to do is to have a list of file sizes of common images, and if they're off from the server's file size, disconnect the player. Use a "base" type update package to download the images on login.

That's over complicating it, what WhiteDragon said is more than good enough :O

cbk1994 12-14-2009 11:06 PM

Quote:

Originally Posted by coreys (Post 1544258)
That's over complicating it, what WhiteDragon said is more than good enough :O

I assume you mean the setshape? A checksum would almost certainly be more complicated.

I agree, a setshape is the best way to make sure objects block regardless of the image; I was just trying to answer the question of the best way to force download an image :).

WhiteDragon 12-15-2009 12:37 AM

I meant easy for Stefan, not for a GS2 developer.

As far as I know, there is no hook for when something gets buffered into memory, so that'd actually be impossible.


The file rewriting thing is cool, although, the reason it works is probably because it changes the "file changed time", so I wonder if there is a better way than actually rewriting the whole thing (which could cause big problems if the file is large).

cbk1994 12-15-2009 01:04 AM

Quote:

Originally Posted by WhiteDragon (Post 1544357)
I meant easy for Stefan, not for a GS2 developer.

As far as I know, there is no hook for when something gets buffered into memory, so that'd actually be impossible.


The file rewriting thing is cool, although, the reason it works is probably because it changes the "file changed time", so I wonder if there is a better way than actually rewriting the whole thing (which could cause big problems if the file is large).

I wonder if movefile would work? I doubt it since it shouldn't change the time, but it might trigger some kind of file updated event, and it's worth a shot.

PHP Code:

movefile("levels/graphics/doors/mydoor.png", "levels/graphics/doors/mydoor.png"); 


Admins 12-15-2009 05:03 AM

You can configure gupd files to use checksum check instead of file modification time comparison. It's better to not use it for a lot of files because checksum check means it needs to read the whole file.


All times are GMT +2. The time now is 10:57 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.