I'm on a mac ppc.
In CL_ActorMouseTrace (in cl_actor.c) there is an endianess problem (search "FIXME: The next three lines are not endian safe" comment.)
After the CM_TestLineDM(pA, pB, pC) call, pC[2] is 0 when the bug occurs.
As far as I understand the code, I think that CM_TestLineDM is OK, but in TestLineDist_r, in the following code:
if (node & (1 << 31)) {
r = node & ~(1 << 31);
if (r)
VectorCopy(start, tr_end);
return r; /* leaf node */
}
--> "if(r)" is never true when the bug occurs. This may be caused by a bad initialization of nodes.
Have a look to CMod_LoadNodes, I think that:
VectorAdd(in->mins, shift, out->mins);
VectorAdd(in->maxs, shift, out->maxs);
must be replaced by:
out->mins[0]=LittleFloat(in->mins[0])+shift[0];
out->mins[1]=LittleFloat(in->mins[1])+shift[1];
out->mins[2]=LittleFloat(in->mins[2])+shift[2];
out->maxs[0]=LittleFloat(in->maxs[0])+shift[0];
out->maxs[1]=LittleFloat(in->maxs[1])+shift[1];
out->maxs[2]=LittleFloat(in->maxs[2])+shift[2];
I'm not sure if 'shift' should be swapped too, and if the test
if (in->planenum == -1)
should be
if (LittleLong(in->planenum) == -1)
I think that all "in->" variables should be swapped, shouldn't they?
I haven't the time to test further, and I'm not sure what I said is right, please have a look. Hope this helps.
BTW: shouldn't "byte.c" be defined with #define statements set by ./config?
I mean: isn't it time-consuming to call ***NoSwap functions (that do nothing) on little endian machines?
Seen in Apple's OSByteOrder.h:
#if defined(__BIG_ENDIAN__)
#define OSSwapHostToLittleInt16(x) OSSwapInt16(x)
#else
#define OSSwapHostToLittleInt16(x) ((uint16_t)(x))
#endif