Carl Worth writes:
> Perhaps someone would like to look closely at the wad parsing code
> with an eye out for unportable code?
Like unpacking structures from a file by defining the structure then
swapping bytes if necessary. Gag, cough, spit. Not only is it
stupidly written, it's completely unnecessary. Instead of doing this:
patch->originx = SHORT(mpatch->originx);
patch->originy = SHORT(mpatch->originy);
patch->patch = patchlookup[SHORT(mpatch->patch)];
where mpatch is a pointer to an mappatch_t, they should be unpacking
it using code like this, where mpatch is an unsigned char *:
patch0>originx = mpatch[0] + mpatch[1]*256;
patch0>originy = mpatch[2] + mpatch[3]*256;
patch->patch = patchlookup[mpatch[4] + mpatch[5]*256];
Repeat after me: do not write structures to files. Do not read
structures from files. Serialize them into a stream of bytes *then*
read or write.
//
// Texture definition.
// Each texture is composed of one or more patches,
// with patches being lumps stored in the WAD.
// The lumps are referenced by number, and patched
// into the rectangular texture space using origin
// and possibly other attributes.
//
typedef struct
{
short originx;
short originy;
short patch;
short stepdir; // unused in Doom but might be used in Phase 2 Boom
short colormap; // unused in Doom but might be used in Phase 2 Boom
} mappatch_t __attribute__((packed));
-- -russ nelson <sig.a.t.russnelson.com> http://russnelson.com | A hate crime makes Crynwr sells support for free software | PGPok | it illegal to think certain 521 Pleasant Valley Rd. | +1 315 268 1925 voice | thoughts. The crime is Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | itself already a crime.Received on Fri Sep 22 06:16:52 2000
This archive was generated by hypermail 2.1.8 : Tue May 04 2004 - 09:43:42 EDT