Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Using Networking to Send Clients A Map, they then have to load it.  (Read 4142 times)
0 Members and 1 Guest are viewing this topic.
Offline KetraCoder

Junior Newbie


Exp: 2 years



« Posted 2014-11-30 04:49:24 »

Hi,

So there is a server and clients.

Client connects to server >
Server sends client a map <
Client loads map >

I need someone to point me in the correct direction, I am not using an libraries such as LibGDX, I've programmed my engine using Javas basics (Canvas, game loop, object handler...)

Here are the things I'm worried about:
- The player can crack the program and change the loaded map given by the server. How do I circumvent this from happening?

- What format of the data will the map sent back to the client be? (i.e. it wouldn't make sense to send back a text file)

Thanks!
Offline nerb
« Reply #1 - Posted 2014-11-30 07:03:03 »


- The player can crack the program and change the loaded map given by the server. How do I circumvent this from happening?


What are the consequences if this happens? I.e. Does it give potential for cheating? Any data sent to the client is out of your hands, but if you are expecting a response back based on potentially compromised data, then perhaps you need to verify it server-side somehow? Alternatively, if the consequences aren't major, then don't worry about it.
Offline Emmsii
« Reply #2 - Posted 2014-12-01 17:13:42 »

What I would do is, depending on how big your map is, split it into small chunks. Send chunk packets with the map data to the client for the user to load back together. That way you won't send one big array, just lots of small little arrays.

You could store your map as a 2d array of byte for tile ids.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline KetraCoder

Junior Newbie


Exp: 2 years



« Reply #3 - Posted 2014-12-02 11:36:22 »

Thanks for your responses, I've just got to say a little bit more  Cheesy


- The player can crack the program and change the loaded map given by the server. How do I circumvent this from happening?



What are the consequences if this happens? I.e. Does it give potential for cheating? Any data sent to the client is out of your hands, but if you are expecting a response back based on potentially compromised data, then perhaps you need to verify it server-side somehow? Alternatively, if the consequences aren't major, then don't worry about it.

You got me thinking better now, it seems the hacker could change their screen but it wouldn't modify anything server side because if the hacker sent something, the server needs to validate it.

What I would do is, depending on how big your map is, split it into small chunks. Send chunk packets with the map data to the client for the user to load back together. That way you won't send one big array, just lots of small little arrays.

You could store your map as a 2d array of byte for tile ids.

Great idea, chunks! I've seen the 2d array thing been done storing the map. The thing is with the 2d array, I have to specify how many elements there will be. I know I might overshoot it, so it feels a bit weird to use a 2d array. Do you know of any other alternatives to a 2d array when it comes to storing maps?

Offline Emmsii
« Reply #4 - Posted 2014-12-02 16:49:56 »

What do you mean, you might overshoot it? How are you handling your map at the moment? Normally you want to define how big your map is, even if you are randomly generating it. If you aren't going for a set map size and want to do something more like Minecraft, then make a new chunk every 16x16 tiles (16 if thats how big your chunk is).

For me I find a 2d array works best.

1  
2  
//This is a 64x64 map.
byte[][] tileIds = new byte[64][64]


  • Each element stores a tile id
  • When the game renders a portion of the map, it calls getTile(x, y).render()
  • getTile(int x, int y) returns a static Tile object that defines the tile look and properties
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1569 views)
2018-06-10 19:43:48

EgonOlsen (1541 views)
2018-06-10 19:43:44

EgonOlsen (1141 views)
2018-06-10 19:43:20

DesertCoockie (1568 views)
2018-05-13 18:23:11

nelsongames (1172 views)
2018-04-24 18:15:36

nelsongames (1549 views)
2018-04-24 18:14:32

ivj94 (2306 views)
2018-03-24 14:47:39

ivj94 (1515 views)
2018-03-24 14:46:31

ivj94 (2602 views)
2018-03-24 14:43:53

Solater (879 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!