Need help with map storage

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Need help with map storage

Post by OldRod »

I am working on a multiplayer browser strategy/empire-building game

I have a 10x10 world grid. Each grid square is then divided into a 10x10 region grid, so there are 10K regions total in the game that could potentially be accessed. Now, not all of the regions will be available for players to build on (there will be dungeons, land obstacles, resource nodes, etc. on some).

How is the best way to store this data using PHP/MySQL?
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Need help with map storage

Post by a_bertrand »

It pretty much depends what is the content of each of those 10K "cell". Explain what you will put inside those cells and we can then try to help youl
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Need help with map storage

Post by OldRod »

It will be one of a list of things:

Player settlement
Boss encounter
Dungeon
Empty Cell
Map obstacle (mountain, water, etc.)

The idea is the player will click on the grid square and interact with what is there through another screen.

I'm debating whether it would be best to just keep a table of the X/Y position and content of each occupied cell (which could get quite long as the game progresses), or some kind of byte-array that could be stored all in one record (not sure how to do this)
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Need help with map storage

Post by a_bertrand »

If you run for something like NEaB, I took the road of RLE (Run Length Encoded) maps:

if you have 10 roads one after the other: you will find something like 10xRoad instead of Road;Road;Road.... That takes a lot less space. However it requires a bit more efforts to store / restore the maps.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Need help with map storage

Post by OldRod »

OK, I've been giving this some thought.

I have 100 world regions. Within each of these regions is 100 sectors. Would it be possible to represent the contents of each of those sectors as an array of 100 numbers (1=open, 2=mountainous, 3 = player settlement, etc.)? Then I would have a world table and for each of the 100 regions I would serialize the array for the sector data in that region and store it, along with the X/Y identifier of that region. Would that work?

I've never used serialize/unserialize. In a multiplayer environment where the map could be changing, will that cause any problems?
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Need help with map storage

Post by hallsofvallhalla »

look at my forsaken sanctum web game videos and open source. It uses what you are looking for and is capable of millions of locations.
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Need help with map storage

Post by OldRod »

hallsofvallhalla wrote:look at my forsaken sanctum web game videos and open source. It uses what you are looking for and is capable of millions of locations.
Thanks :)
User avatar
Sharlenwar
Posts: 523
Joined: Mon May 28, 2012 7:14 pm

Re: Need help with map storage

Post by Sharlenwar »

hallsofvallhalla wrote:look at my forsaken sanctum web game videos and open source. It uses what you are looking for and is capable of millions of locations.
*goes to look!!!*
Deep within the Void of Quasion, a creation.

**My Corner of the Web**
***NEW***GrindFest - My own PHP/MySQL game!
Sharlenwar's Adventures
Torn-City - Massively multiplayer online text based RPG
Post Reply

Return to “Beginner Help and Support”