Commit 40abacae authored by hybrid's avatar hybrid

Cleaned the my3d loader to avoid corrupted char arrays.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@754 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 020eae4f
......@@ -12,7 +12,7 @@
//----------------------------------------------------------------------
//**********************************************************************
// some usefull functions
// some useful functions
//**********************************************************************
#ifndef __C_MY3D_HELPER_H_INCLUDED__
......@@ -24,106 +24,6 @@ namespace irr
namespace core
{
//---------------------------------------------------------------------
inline f32 fmax(f32 v1, f32 v2)
{ return (v1>v2)?v1:v2;
}
//----------------------------------------------------------------------------
template <class T>
s32 strlen(T* str)
{ int len = 0;
while(true)
{ if (*(str+len)==0)
break;
len++;
}
return len;
}
//----------------------------------------------------------------------------
template <class T>
T* strcpy (T* src, T* dst)
{ if (src&&dst)
{ s32 len = strlen(src);
for (s32 i=0; i<len+1; i++)
dst[i] = src[i];
return dst;
}
return NULL;
}
//----------------------------------------------------------------------------
template <class T>
T* strcpy (T* src, T* dst, s32 startPos, s32 endPos)
{ if (src&&dst)
{ s32 len = strlen(src);
s32 charIndex=0;
for (s32 i=startPos; i<=endPos && endPos<len; i++)
{ dst[charIndex] = src[i];
charIndex++;
}
dst[charIndex]=0;
return dst;
}
return NULL;
}
//----------------------------------------------------------------------------
template <class T>
s32 findLast(T* Str, c8 ch)
{
s32 lenSrc = strlen(Str);
s32 n=lenSrc-1;
s32 lastCharInStringPos = -1;
while(true)
{ if (Str[n] == ch)
{ lastCharInStringPos = n;
break;
}
if (n==0) break;
n--;
}
return lastCharInStringPos;
}
//----------------------------------------------------------------------------
template <class T>
s32 findLastDelimiter(T* Str)
{
s32 lenSrc = strlen(Str);
s32 n=lenSrc-1;
s32 lastDelimiterInStringPos = -1;
while(true)
{ if (Str[n] == '\\' || Str[n] == '/')
{ lastDelimiterInStringPos = n;
break;
}
if (n==0) break;
n--;
}
return lastDelimiterInStringPos;
}
//----------------------------------------------------------------------------
template <class T>
T* extractFilePath(T* sourceStr, T* buffer, s32 bufSize)
{
s32 lastDelimiterInStringPos = findLastDelimiter(sourceStr);
if (lastDelimiterInStringPos>=0 && lastDelimiterInStringPos<bufSize)
strcpy(sourceStr, buffer, 0, lastDelimiterInStringPos);
return buffer;
}
//----------------------------------------------------------------------------
template <class T>
T* extractFileName(T* sourceStr, T* buffer, s32 bufSize)
{ s32 lastDelimiterInStringPos = findLastDelimiter(sourceStr);
s32 lenSrc = strlen(sourceStr);
if (lastDelimiterInStringPos>=-1 && (lenSrc-lastDelimiterInStringPos)<bufSize)
strcpy(sourceStr, buffer, lastDelimiterInStringPos+1, lenSrc-1);
return buffer;
}
//-----------------RLE stuff-----------------------------------------
int rle_encode (
......
This diff is collapsed.
......@@ -204,20 +204,23 @@ namespace scene
//! work best with your new terrain size.
virtual bool overrideLODDistance( s32 LOD, f64 newDistance );
//! Scales the base texture, similar to makePlanarTextureMapping
virtual void scaleTexture(f32 scale = 1.0f, f32 scale2=0.0f );
//! Scales the two textures
virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f);
//! Returns type of the scene node
virtual ESCENE_NODE_TYPE getType() const { return ESNT_TERRAIN; }
virtual ESCENE_NODE_TYPE getType() const {return ESNT_TERRAIN;}
//! Writes attributes of the scene node.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0);
virtual void serializeAttributes(io::IAttributes* out,
io::SAttributeReadWriteOptions* options=0);
//! Reads attributes of the scene node.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
virtual void deserializeAttributes(io::IAttributes* in,
io::SAttributeReadWriteOptions* options=0);
//! Creates a clone of this scene node and its children.
virtual ISceneNode* clone(ISceneNode* newParent, ISceneManager* newManager);
virtual ISceneNode* clone(ISceneNode* newParent,
ISceneManager* newManager);
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment