Archvile
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Special Interest > XWE > Extracting Lumps
 
Author
All times are GMT. The time now is 13:01. Post New Thread    Post A Reply
Planky
Senior Member


Posts: 1191
Registered: 12-02


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

Last edited by Planky on 02-16-05 at 01:15

Old Post 02-15-05 23:48 #
Planky is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
RTC_Marine
Junior Member


Posts: 544
Registered: 06-01


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.

Old Post 02-16-05 00:29 #
RTC_Marine is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Planky
Senior Member


Posts: 1191
Registered: 12-02


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?

Old Post 02-16-05 01:14 #
Planky is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Csabo
Moderator


Posts: 541
Registered: 02-02


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.

Old Post 02-16-05 01:41 #
Csabo is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Bloodshedder
Spellchecker


Posts: 5514
Registered: 03-02


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

Old Post 02-16-05 01:50 #
Bloodshedder is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Planky
Senior Member


Posts: 1191
Registered: 12-02



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.

Old Post 02-16-05 01:53 #
Planky is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Bloodshedder
Spellchecker


Posts: 5514
Registered: 03-02


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

Old Post 02-16-05 02:28 #
Bloodshedder is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Csabo
Moderator


Posts: 541
Registered: 02-02


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.

Old Post 02-16-05 03:45 #
Csabo is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Planky
Senior Member


Posts: 1191
Registered: 12-02


Are you able to post an example?

Whenever I attempt to get the value from the position, it just returns 0.

Old Post 02-19-05 02:52 #
Planky is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
exl
Personal Test Dummy


Posts: 579
Registered: 05-02


Just give up Planky, thou shalt never prevail!

Old Post 02-20-05 22:14 #
exl is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Planky
Senior Member


Posts: 1191
Registered: 12-02


Not only shall I prevail, I shall cast your program of WOE into a pit of fire!

*ahem*

Old Post 02-21-05 00:49 #
Planky is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Csabo
Moderator


Posts: 541
Registered: 02-02


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.

Old Post 02-23-05 00:56 #
Csabo is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
RTC_Marine
Junior Member


Posts: 544
Registered: 06-01


I couldn't get blockread/write to work with data 2mb+ in size, do you have some sort of trick for that Csabo?

Old Post 02-23-05 02:39 #
RTC_Marine is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Csabo
Moderator


Posts: 541
Registered: 02-02


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.

Old Post 02-23-05 14:09 #
Csabo is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 13:01. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Special Interest > XWE > Extracting Lumps

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.