• Advertisement

Archived

This topic is now archived and is closed to further replies.

RLE Loading Problems

This topic is 5555 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im working on a level editor, and the maps are stroed as text files, and I use RLE (runetime-length encoding) to compress them. This works fine, but im having a lot of trouble trying to think up how to make the loading algorithm work. The problem in my mind is that once i find the repetions of the tiles and run through another for loop to set the tiles ID, X, Y, and Z positions, im not sure how this would affect my regular loop, and how I would calculate the Y and Z positions, given the Hight Width and Depth of the map. If anyone has example code or the algo in pseudo-code I would be grateful!

Share this post


Link to post
Share on other sites
Advertisement
Why not just uncompress it into a temporary structure and then load it in using your original algorithm for un-compressed files? Seems a lot simpler than trying to do it all in one.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites
Im afraid i dont understand what you mean. In my mind, the program would loop through the structure and save it using RLE, and then whenever i want to load the map i decompress it using the decompression algo. Im not sure i grasp what you mean about temporary structures?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
decompress the whole file into a string. use string streams and pretend like its a file.

Share this post


Link to post
Share on other sites
Whats the advantage of decompressing the whole thing to a string then filling in the CMap class as opposed to doing it directly from the file to the temp vars which i use to fill in the class? Should i show some code to show what exactly I mean?

Share this post


Link to post
Share on other sites
The advantage is that it''s simpler! You''re having trouble combining decompression with initialisation of your structures, so the simplest way is to split that into two stages. That way you don''t need to worry about how the two loops interact or anything like that.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites
GOt it Working!! Finally! I did your suggestion and noticed that while i splitted the algo in 2 i made a mistake with both the saving and loading code. Everything works perfectly now, thanks!

Share this post


Link to post
Share on other sites

  • Advertisement