Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

When the map is relatively small, it takes a few milliseconds to save it, so it's generally ok. But with other, much much bigger maps, it could take several seconds, which is both annoying and hangs the game's networking, and overall leads to many problems.

Threading kind of is the answer, but it creates another problem — while map is being saved, all changes user makes are also being saved, after the save button was pressed (so if the user decides to blow up the map right after pressing Save button, he might be unaware of that it might be saved). So this either calls for user-map interaction block until map saves, or something else entirely.

share|improve this question
3  
Copying big RAM areas should be way faster than writing big files. So first copy your data structures, then save. This of course requires that your data is at one central point. –  Mr. Beast Jul 29 '12 at 8:40
2  
You hardly ever want to save to whole map during a game, because most of it is static, it does not change. What you want to save is the dynamic game-state, like current player checkpoint, the inventory or enemy positions and evolution in an RTS and so on, but not the actual map. –  Maik Semder Jul 29 '12 at 8:44
    
@MaikSemder in this case map changes, and very often. –  user1306322 Jul 29 '12 at 9:21
    
@Mr.Beast How did I not think if it! This is the solution. –  user1306322 Jul 29 '12 at 9:24
    
@user1306322 what exactly changes? –  Maik Semder Jul 29 '12 at 9:49
show 1 more comment

1 Answer

up vote 0 down vote accepted

When it takes a lot of time to save a map, and it can't be divided into chunks, one way to do it is to copy the map into a new instance of map class and save that instead of the live map.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.