Planky Posted February 15, 2005 Hi Csabo, I originally sent this as a pm, but I don't think you've received it... Anyhow, I am creating a script editor for Legacy in Delphi - which is no problem, however I am hitting a snag when it comes to extracting the script from any map in a wad (well, extracting anything for that matter). I am not exactly sure where to start. I assume I should load a wad with TMemoryStream and seek to the fs lump (I've only ever worked with text files or other peoples components to read different formats), are you able to explain the process I should go through to get data I need? Cheers, Planky 0 Share this post Link to post
RTC_Marine Posted February 16, 2005 I wouldn't suggest using TMemoryStream (you can guess what happens when you open a wad file with it, unless you have a reasonable amount of memory to load a wad file into) I suggest using TFileStream instead. Also, you may want to check out this wrapper for wad files I wrote a while back: http://russell.slipgate.org/files/waded.zip <- its incomplete in areas and I suggest making backups of your wads before using it. 0 Share this post Link to post
Planky Posted February 16, 2005 Yes, I attempted to load a 10 megabyte wad file with it and it proceeded to lock the application for a good five minutes :D Ok, so I use TFileStream. But how to I locate the area I need? 0 Share this post Link to post
Csabo Posted February 16, 2005 Well now that you pointed out that I have a PM I got it. (I'd like to note quietly that I find the current PM system on DoomWorld somewhat lame. The PM's are not displayed prominently enough.) This is how XWE handles the text lumps. We need to know the size and position of the lump. - The file is opened and we seek to the lump's position - We start a loop that runs 'lump-length' times - Read one byte. If it's a 10 or 13, the current line is added to the textbox. Otherwise the character is added to the current line. That's pretty much it. The drawback ofcourse is that the textbox may not be able to handle all the text, however, XWE supports the CodeMax 2.0 control. If the user has that, a CodeMax textbox is used, which can pretty much handle unlimited data and has all the syntax highlighting features etc. 0 Share this post Link to post
Bloodshedder Posted February 16, 2005 In the user options section of your user control panel, you can tell the forum software to send you an e-mail when you get a new private message (may not work), or pop up a message box if you have a new private message (won't work without JavaScript). 0 Share this post Link to post
Planky Posted February 16, 2005 Csabo said:Well now that you pointed out that I have a PM I got it. (I'd like to note quietly that I find the current PM system on DoomWorld somewhat lame. The PM's are not displayed prominently enough.) I had a feeling that was the case, so that s why I created this topic :) Two questions: 1, What is the position of said lump (or rather how do I find out) 2, How do I find out the size (using sizeof?). I am new to using filestreams, so forgive me if my questions are n00bish. Cheers. 0 Share this post Link to post
Bloodshedder Posted February 16, 2005 OK, I just hacked in a new feature to the forum software. If you have any unread PMs, it displays a little message in the upper right hand corner of the main forum page, under "View New Posts". 0 Share this post Link to post
Csabo Posted February 16, 2005 Planky, the WAD format is pretty simple. On position 8 you have a 32 bit value that points you to the "lump directory" within the file. The lump directory has entries like this: 32-bit int: lump position 32-bit int: lump size 8 byte char: lump name That's it, hope it helps. BloodShedder, that's good work. However, I only have the XWE forum bookmarked. I'm happy when I can find the time to pop in and read the posts... So it would be nice to have it displayed all the time (or at least on every forum). Or this could be an option. 0 Share this post Link to post
Planky Posted February 19, 2005 Are you able to post an example? Whenever I attempt to get the value from the position, it just returns 0. 0 Share this post Link to post
exl Posted February 20, 2005 Just give up Planky, thou shalt never prevail! 0 Share this post Link to post
Planky Posted February 21, 2005 Not only shall I prevail, I shall cast your program of WOE into a pit of fire! *ahem* 0 Share this post Link to post
Csabo Posted February 23, 2005 Just debug your code, you should see if all the values you are reading are correct. Anyway, something like this should work: AssignFile ( f, 'filename.wad' ); Reset ( f, 1 ); Seek ( f, 8 ); BlockRead ( f, intPosition, 4 ); Seek ( f, intPosition + intEntry * 16 ); BlockRead ( f, intPosition, 4 ); BlockRead ( f, intLength, 4 ); You should have the position and length of entry number 'iEntry' (0 based) in the respective variables. 16 is the length of the directory entry, as I mentioned it my previous post. Of course you'd want to verify that the file is infact a WAD file (has IWAD or PWAD signature), and that the value on pos 8 is within the file, etc. 0 Share this post Link to post
RTC_Marine Posted February 23, 2005 I couldn't get blockread/write to work with data 2mb+ in size, do you have some sort of trick for that Csabo? 0 Share this post Link to post
Csabo Posted February 23, 2005 I don't think I ever tried to BlockRead that much in one shot, but you could obviously read in 1MB chunks in sequence for example. 0 Share this post Link to post