FIRE-9819; llstrider was incompatible with the binary havok blob, leading to crashes.

Nicky 2013-04-20 02:53:50 +02:00
parent 201541f407
commit 568dfd86d5
1 changed files with 27 additions and 17 deletions

View File

@ -37,13 +37,36 @@ template <class Object> class LLStrider
};
U32 mSkip;
public:
LLStrider() { mObjectp = NULL; mSkip = sizeof(Object); mBufferEnd = 0; }
~LLStrider() { }
const LLStrider<Object>& operator = (Object *first) { mObjectp = first; mBufferEnd = 0; return *this;}
void setStride (S32 skipBytes) { mSkip = (skipBytes ? skipBytes : sizeof(Object));}
void skip(const U32 index) { mBytep += mSkip*index;}
U32 getSkip() const { return mSkip; }
#ifndef OPENSIM // <FS:ND> protect against buffer overflows, but only for non HAvok builds. Otherwise changing the object size plays really foul when used in the binary Havok blob
LLStrider() { mObjectp = NULL; mSkip = sizeof(Object); }
const LLStrider<Object>& operator = (Object *first) { mObjectp = first; return *this;}
LLStrider<Object> operator+(const S32& index)
{
LLStrider<Object> ret;
ret.mBytep = mBytep + mSkip*index;
ret.mSkip = mSkip;
return ret;
}
Object* get() { return mObjectp; }
Object* operator->() { return mObjectp; }
Object& operator *() { return *mObjectp; }
Object* operator ++(int) { Object* old = mObjectp; mBytep += mSkip; return old; }
Object* operator +=(int i) { mBytep += mSkip*i; return mObjectp; }
Object& operator[](U32 index) { return *(Object*)(mBytep + (mSkip * index)); }
#else
LLStrider() { mObjectp = NULL; mSkip = sizeof(Object); mBufferEnd = 0; }
const LLStrider<Object>& operator = (Object *first) { mObjectp = first; mBufferEnd = 0; return *this;}
LLStrider<Object> operator+(const S32& index)
{
LLStrider<Object> ret;
@ -54,19 +77,6 @@ public:
return ret;
}
void skip(const U32 index) { mBytep += mSkip*index;}
U32 getSkip() const { return mSkip; }
// <FS:ND> protect against buffer overflows
// Object* get() { return mObjectp; }
// Object* operator->() { return mObjectp; }
// Object& operator *() { return *mObjectp; }
// Object* operator ++(int) { Object* old = mObjectp; mBytep += mSkip; return old; }
// Object* operator +=(int i) { mBytep += mSkip*i; return mObjectp; }
// Object& operator[](U32 index) { return *(Object*)(mBytep + (mSkip * index)); }
Object* get()
{
if( !assertValid( mBytep ) )
@ -144,7 +154,7 @@ private:
#endif
Object mDummy;
// <FS:ND>
#endif
};
#endif // LL_LLSTRIDER_H