-1

I have a TiledMap where I want to store the .tmx-File on a Server. When a Player is connecting he should recieve the .tmx file as a "Class"/"Ressource"(?) and then load the Map with the .tmx file.

My Problem is, in which Object can i store the .tmx file to send it over and then load the Map?

E.g.:

On Server:

InputStream is = TiledMap.class.getResourceAsStream("map.tmx");

Then a player connects, he recieve this Object via my Kryo Engine and load the Map:

TiledMap map = new TmxMapLoader().load(>>THE OBJECT RECIEVED<<);

Hope that someone can help, thanks in advance :)

Liquidz
  • 283
  • 1
  • 4
  • 11
  • Nope nope nope. Firstly sending a tiled map object via kryonet is not going to be easy. Secondly this is a bad approach. Rather you should store all maps on client and then send map name from the server to client and then client can load the map. – Sneh Aug 23 '16 at 14:04
  • yeah sure, but when i store the .tmx file within the Client everyone can edit the Map. I only want to send the .tmx File, not the Images! The raw .tmx file is not so big. – Liquidz Aug 23 '16 at 15:09
  • 1
    Well if you are worried about file being edited, then store hash of your map file on server and then every time client is about to load a new map, send the server a hash of the map stored on the client. If they match you know there was no editing, if they don't then they edited the map. :) – Sneh Aug 23 '16 at 15:10

1 Answers1

1

I think you are overcomplicating this. I get that you don't want the players to be able to cheat by having modified maps. But if the assets are still on the client, the player can just modify those. So you have to check if the assets files are unmodified. If you are checking if one file is modified on the client, then checking two files is trivial.

You make a hash of the client map, send it to the server and check if the hash is identical to the hash on the server. This is the way you should go. Not sending an instance of an object to the client.

This post should help you get Getting a File's MD5 Checksum in Java

Community
  • 1
  • 1
Jim
  • 995
  • 2
  • 11
  • 28