Author Topic: Map Data Handling  (Read 1951 times)

0 Members and 1 Guest are viewing this topic.

Offline Mickey Kudlo

Map Data Handling
« on: October 31, 2018, 01:27:02 pm »
Past versions send map data as you move. You move to the left, the server sends the left edge of the map data(surface, items, players, monsters, etc), then the client displays the move.
So, you can end up getting the same data over and over, increasing bandwidth (and latency?) but it deals with a dynamic world well.

Since V7 is also intended for mobile, I decided to deal with map data differently. It sends a large portion (50x50) at a time to the client and sends updates as they happen.
So it a lot of data at first but should be minimal as the player moves around. The server sends more 50x50 sections as you hit edges. This is for large maps. Smaller ones, like a 100x100 dungeon would send all at once, when you first enter it.

This also gives the client more responsibility and faster reaction. It will start moving right away then send the request to the server. The client knows basic blocking items, etc.

I want to say most/all online games, that use static maps (which is probably most/all), have copies of world maps already. So, I am kinda using that model.

Not sure how it will all work out but will see!
You may have conquered my worlds, but I destroyed them!

Offline Powerfox

Re: Map Data Handling
« Reply #1 on: November 03, 2018, 02:48:06 pm »
This is pretty much the standard for games with large changing worlds anyway.  Minecraft for example, when you join a multiplayer server you receive data for ~500,000 blocks at once and it unloads/loads ~200,000 blocks or so at a time as needed to keep it seamless.   For a 2D game the impact of this should be negligible if the data is stored properly and isn't all being rendered.

Only thing I noticed from giving V7 a whiz was that it the game seems to hang for a good few seconds when receiving new chunks so could probably do with this being handled asynchronously.

Offline Greatest

  • Hero Member
  • *****
  • Posts: 1330
  • Attack: 161
    Defense: 91
    Attack Member
  • Karma: 9
  • Gender: Male
  • I'm better than you!
    • View Profile

  • Total Badges: 38
    Badges: (View All)
    Linux User Mobile User Tenth year Anniversary
Re: Map Data Handling
« Reply #2 on: November 06, 2018, 01:32:48 am »
my only concern with this:
since you're not going to see next 50 area til you're in it/near it, when you're near a map edge before it loads and you're within attack range of monsters in that area can they still kill you?

I know you only have rats for now, but long term I'm sure there will be ranged attack units and magic, and getting ganked by monsters that haven't loaded on your client yet sounds worse than possibly having a bit of lag...

why does Fox keep cancelling good shows?

Offline Powerfox

Re: Map Data Handling
« Reply #3 on: November 06, 2018, 03:55:54 am »
my only concern with this:
since you're not going to see next 50 area til you're in it/near it, when you're near a map edge before it loads and you're within attack range of monsters in that area can they still kill you?

I know you only have rats for now, but long term I'm sure there will be ranged attack units and magic, and getting ganked by monsters that haven't loaded on your client yet sounds worse than possibly having a bit of lag...



You don't hit a black wall when then load the next area, once you get within a certain distance of the edge it starts loading in the next area ready to go, it should feel seamless to the player.

Offline Greatest

  • Hero Member
  • *****
  • Posts: 1330
  • Attack: 161
    Defense: 91
    Attack Member
  • Karma: 9
  • Gender: Male
  • I'm better than you!
    • View Profile

  • Total Badges: 38
    Badges: (View All)
    Linux User Mobile User Tenth year Anniversary
Re: Map Data Handling
« Reply #4 on: November 06, 2018, 07:14:09 am »
You don't hit a black wall when then load the next area, once you get within a certain distance of the edge it starts loading in the next area ready to go, it should feel seamless to the player.
So it a lot of data at first but should be minimal as the player moves around. The server sends more 50x50 sections as you hit edges. This is for large maps. Smaller ones, like a 100x100 dungeon would send all at once, when you first enter it.
your way of thinking is similar to how it is now, which works fine.  Mickey said new stuff when you hit the edges.  say that edge is considered 5 tiles, and the monsters have an attack range of 8, they can hit you from up to 3 tiles into the next 50 section while that section hasn't loaded in the client...atleast potentially, which is why I have concerns with it.
why does Fox keep cancelling good shows?

Offline Powerfox

Re: Map Data Handling
« Reply #5 on: November 06, 2018, 07:20:50 am »
You don't hit a black wall when then load the next area, once you get within a certain distance of the edge it starts loading in the next area ready to go, it should feel seamless to the player.
So it a lot of data at first but should be minimal as the player moves around. The server sends more 50x50 sections as you hit edges. This is for large maps. Smaller ones, like a 100x100 dungeon would send all at once, when you first enter it.
your way of thinking is similar to how it is now, which works fine.  Mickey said new stuff when you hit the edges.  say that edge is considered 5 tiles, and the monsters have an attack range of 8, they can hit you from up to 3 tiles into the next 50 section while that section hasn't loaded in the client...atleast potentially, which is why I have concerns with it.

I think it's just bad phrasing, if you play the V7 client now you can see it print to the chat when its loading new 50x50 areas and its always off screen, it would be nonsensical to wait until the player can see the edge before loading more versus just doing it a bit further away.

Offline Mickey Kudlo

Re: Map Data Handling
« Reply #6 on: November 07, 2018, 10:42:37 am »
It loads the 50x50 when it is 50 away, so you will never see black/null unless you at edge of a map.

Yes, I need to asynchronously load data. Instead of 50x50 at a time, maybe 50x1 sent every .05 seconds, so no lag is apparent.

Greatest, yes, map data loading is an issue, sort of, for combat risks cuz you are stuck getting data, vulnerable to attack. Loading a smaller amount at a time will solve this but when entering dungeon maps, I plan to first remove player from old map, send whole dungeon map, then add player to new map. This would also apply to going up/down on the main map. Then nothing can attack until the client is ready.

And one things planned, maybe, would be like telescopes, so you can look far out, that why I choose 50.

And thanks all for testing. I have seen about 14+ players made.
You may have conquered my worlds, but I destroyed them!

Offline Squizzle

Re: Map Data Handling
« Reply #7 on: December 10, 2018, 03:07:17 pm »
I don't understand how the map data streaming is so much of a hiccup in framerate.

Considering you use integers (or short 16 bit integers?) for tile ids, and assuming in 50 tiles (for the telescope) their are 5 objects on each tile...
Code: [Select]
; Assuming Android and C# (although Java has the same value type bit sizes)
32bit int = 4 bytes
16bit int = 2 bytes
; 1 tile id + 5 object ids
1 tile of 32bit ids = 24 bytes x 50 tiles = 1,200 bytes (or 9.6 kilobits)
1 tile of 16bit ids = 12 bytes x 50 tiles = 600 bytes (or 4.8 kilobits)
; For comparison, Dialup was 40-50 kilobits/s.
I know tile map data is not the only data getting sent but what would cause that noticeable hiccup because it can't be due to the amount of data sent and stored and then drawn could it?

Offline Mickey Kudlo

Re: Map Data Handling
« Reply #8 on: December 12, 2018, 07:19:41 am »
The current version is sending 50x50 all at once.
So, 2500 + (24 X Number_of_Units), example 2500 + 24 X 2500 = 62500 bytes.
That would be for like a jungle that has tons of plants. The surface tiles are easy/fast. It the units that mess it up.
And then times that by 3 since you ususally get into range of 3 new 50x50 sectors when ever you hit a border.

I already fixed it for the next version though and it now sends 50x1 at a time, with a delay. It a lot smoother, so will see how it goes.

I do keep thinking about maybe breaking the big map up into smaller ones, like 100x100, and connect them, like most RPGs do. Then when you enter it, send all the data. When dungeons come, it will be doing that since they will be from size 10 up to 100+.
You may have conquered my worlds, but I destroyed them!

 

Related Topics

  Subject / Started by Replies Last post
5 Replies
2171 Views
Last post May 15, 2015, 05:08:17 pm
by uderghad