Sign in to follow this  

Quake 3 BSP - The Entity String ?!

This topic is 4544 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

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
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

This topic is 4544 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.

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