Sign in to follow this  
dacredens

Quake 3 BSP - The Entity String ?!

Recommended Posts

dacredens    128
Hi, ive been playing around with q3 bsps and ive found the need for reading in the entity string and using the data that it contains, however im not to sure of the best way to do this. Iv made a few attempts at reading it in as larger blocks and then extracting out the entries etc into pointers but everything seems to get messy and my code is quite pathetic to be honest. im not to good with strings so if anyone knows of a good demo or article which maybe of some help id really appreciate it! :) thanks

Share this post


Link to post
Share on other sites
Max_Payne    757
It should be rather simple. The quake map files are split into "chunks", whose structure you should know. Once you have the location of the entity chunk, which might simply be a bit block of text, all you need to know is its size.

You can then do an fseek() to get to the location of the entity chunk (presumably the beggining of the string), allocate a memory block the size of the string + 1 (for the null terminator character), and perform an fread() call to read as many characters as the length of the string into your newly allocated buffer. Binary files and text files are the same, in terms of memory. Its just that you don't have buffered/formatted text reading functions for binary files, and so you have to read the string "manually".

You then have the entity string... And you can do whatever you want on it, including possibly splitting it into a vector of strings corresponding to each line of the text for easier parsing. From what I have seen, the quake entity code is rather simple. I believe its actually the same as in the uncompiled dot-map files.

Good luck marine ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this