I know this is more about development for the server and my client has fully working textures, but this is just bugging me. It seems azone handles the 0x30 fragment perfectly although the undocumented nature makes it difficult to figure out.
According to Windcatcher's WLD documentation which I have been updating, it is implied that the reference for reference fragments directly follow the header. Take the documentation of 0x30.
Quote:
0x30 — Texture — REFERENCE
Reference points to a 0x05 Texture Bitmap Info Reference fragment.
Fields
Flags : DWORD
Bit 1........ Typically 1. If set to 1, then the Pair field exists.
Params1 : DWORD
Bit 0........ Apparently must be 1 if the texture isn’t transparent.
Bit 1........ Set to 1 if the texture is masked (e.g. tree leaves).
Bit 2........ Set to 1 if the texture is semi-transparent but not masked.
Bit 3........ Set to 1 if the texture is masked and semi-transparent.
Bit 4........ Set to 1 if the texture is masked but not semi-transparent.
Bit 31...... Apparently must be 1 if the texture isn’t transparent.
To make a fully transparent texture, set Params1 to 0.
Params2 : DWORD
Typically contains 0x004E4E4E, but I’ve also seen 0xB2B2B2. Could this be an RGB reflectivity value?
Params3[0] : FLOAT
Typically contains 0. Its purpose is unknown.
Params3[1] : FLOAT
Typically contains 0 for transparent textures and 0.75 for all others. Its purpose is unknown.
Pair : DATAPAIR
Only exists if Bit 1 of Flags is set. Typically contains 0 in both fields. Its purpose is unknown.
|
--------------------------------
Now it seems that it would be the first item but if I am understanding correctly, the 0x05 reference appears to be the last item.
Can anyone confirm this or explain what the heck this code from azone is doing in relation to this fragment.
Code:
FRAGMENT_FUNC(Data30) {
Texture *temp;
int params;
params = *((long *) (buf + 4));
if(!params || !*((long *) (buf + 20))) {
*obj = (void *) malloc(sizeof(Texture));
temp = (Texture *) *obj;
temp->count = 1;
temp->filenames = (char **) malloc(sizeof(char *));
temp->filenames[0] = "collide.dds";
temp->flags = (int *) malloc(sizeof(int));
temp->flags[0] = 0;
}
else {
if(!*((long *) buf))
*obj = wld->frags[*((long *) (buf + 28)) - 1]->frag;
else
*obj = wld->frags[*((long *) (buf + 20)) - 1]->frag;
((Texture *) *obj)->params = params;
}
#ifdef FRAG_DEBUG
printf("Data30: %p %p\n", obj, *obj);
#endif
return 0;
}
I assume it is simply grabbing the parameters and not handling them but the advancement of the pointer by 4 bytes (which should account for the reference) is throwing me off. I have decoded it to my own coding method (still sloppy as I am unclear about what it all does).
Code:
// If parameters were 0 (should indicate an invible poly)? and then OR and the it checks to see if the next 20 byte cast is 0 as well?
if(!params || !*((long *) (temp_p + 20)))
{
// I am pretty sure that this refers to a texture that is supposed to be invisible
// It could be applied to geometry like barriers that are not supposed to be seen
textures[current_tex30].fragRef = frag_num;
textures[current_tex30].textureRef = NULL;
}
else
{
// Again, not sure what this if statement is checking for. To see if the memory is zero again?
if(!*((long *) temp_p))
{
errorLog.writeError("0x30 - Got to this weird area. Not sure what it is for!");
}
else
{
// The texture reference itself
reference = *((long *) (temp_p + 20)) - 1;
}
}
Can any EQEmu devs or knowledgeable people comment on what I may be missing here?
Thank you.
Also, a teaser: