Jump to content
  • Advertisement
Sign in to follow this  
Wibbs

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

This topic is 2919 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!