Sign in to follow this  
Wibbs

[C#] Detecting changes to files in folders on two machines

Recommended Posts

Hey all,

The game I am writing uses a client/server architecture, and I would like to add a check that the server initiates to see if some key files on the client's machine are what they should be. I would appreciate any pointers as to the most efficient way of doing this - at present I have managed to arrange the data so that all files within a couple of folders need checking, and I was also wondering if there is a more efficient way of doing this rather than checking each file individually.

Thanks in advance,

Wibbs

Share this post


Link to post
Share on other sites
The typical method would be to hash the contents of each critical file and compare hashes between the server and client; this avoids the need to do any hefty transfers of data for the actual comparison. It may slightly increase load times, but I'm not sure offhand of a good way to avoid that.

Share this post


Link to post
Share on other sites
Thanks,

That's the conclusion I'd come to, but wanted to check whether there was a way the contents of a folder could be treated as a single entity rather than having to hash each file seperately.

Wibbs

Share this post


Link to post
Share on other sites
Well, for network efficiency you could just send the hash of the concatenation of the different file hashes. Whether this is useful depends on the number of files involved. I don't believe there is a way to avoid reading the files though.

One idea might be to pack all these critical files in a compressed archive. That way you get faster reads, less data and less chance the player will interfere with the files.

Also don't depend on this for anti-cheating, it is easy to modify the executable to send the correct hashes, or even to change the data on the wire. It can only work as a consistency check, e.g. that both players have the same version of a map or a mod.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this