aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2015-08-17 23:44:38 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2015-08-17 23:44:38 +0800
commit2e0b12061b932009818bcb7d373ae481728ec927 (patch)
tree95256db245f266ac0f8538f4fda84320e7221a87
parent03a307b58ddc6244d3fad8d77d7f0bac0a24e05d (diff)
downloadbullet-lab-remix-2e0b12061b932009818bcb7d373ae481728ec927.tar.xz
Bug fixes (again).
Further more fixes for smAnmFile. There could be more bugs... Fix Z Buffer blackening the whole screen in 2D mode.
-rw-r--r--extensions/smanim.cpp16
-rw-r--r--smelt/sdl/gfx_sdl.cpp3
2 files changed, 10 insertions, 9 deletions
diff --git a/extensions/smanim.cpp b/extensions/smanim.cpp
index 6d09032..d57292b 100644
--- a/extensions/smanim.cpp
+++ b/extensions/smanim.cpp
@@ -22,9 +22,9 @@ void smAnmFile::parseMeta(const char* meta,DWORD size)
while(cp-meta<=size)
{
int cc=0;
- for(;*(cp+cc)!='\n';++cc);
+ for(;*(cp+cc)!='\n'&&(cp+cc-meta<=size);++cc);
char line[65];
- strncpy(line,cp,cc);line[cc-1]='\0';
+ strncpy(line,cp,cc+1);line[cc]='\0';
cp+=cc+1;++lc;
if(inAnim&&line[0]!='F'&&line[0]!='E'){METAWARN("Only instruction F is allowed between A and E.");continue;}
if(line[0]=='E')
@@ -75,13 +75,12 @@ void smAnmFile::parseMeta(const char* meta,DWORD size)
{
smTexInfo t;
int cn=0;while(line[cn+2]!=',')++cn;
- t.name=new char[cn];strncpy(t.name,line+2,cn);
- t.name[cn-1]='\0';
- int cn2=0;while(line[cn+3+cn2]!=',')++cn2;++cn2;
- t.path=new char[cn2];strncpy(t.path,line+3+cn,cn2);
- t.path[cn2-1]='\0';
+ t.name=new char[cn+1];strncpy(t.name,line+2,cn+1);
+ t.name[cn]='\0';
+ int cn2=0;while(line[cn+3+cn2]!=',')++cn2;
+ t.path=new char[cn2+1];strncpy(t.path,line+3+cn,cn2+1);
+ t.path[cn2]='\0';
sscanf(line+4+cn+cn2,"%f,%f,%f,%f",&t.rect.x,&t.rect.y,&t.rect.w,&t.rect.h);
- tm[std::string(t.name)]=t;
if(xm.find(std::string(t.path))!=xm.end())
t.tex=xm[std::string(t.path)];
else
@@ -92,6 +91,7 @@ void smAnmFile::parseMeta(const char* meta,DWORD size)
=sm->smTextureLoadFromMemory(texct,texsz);
anm.releaseFilePtr(t.path);
}
+ tm[std::string(t.name)]=t;
}
if(line[0]=='I')
{
diff --git a/smelt/sdl/gfx_sdl.cpp b/smelt/sdl/gfx_sdl.cpp
index 3fd3b46..c0e9305 100644
--- a/smelt/sdl/gfx_sdl.cpp
+++ b/smelt/sdl/gfx_sdl.cpp
@@ -101,7 +101,8 @@ void SMELT_IMPL::smClrscr(DWORD color)
GLfloat g=(GLfloat)(GETG(color))/255.f;
GLfloat b=(GLfloat)(GETB(color))/255.f;
pOpenGLDevice->glClearColor(r,g,b,a);
- if(zbufenabled||tdmode)pOpenGLDevice->glClearDepth(1);
+ if(tdmode)pOpenGLDevice->glClearDepth(1);
+ else if(zbufenabled)pOpenGLDevice->glClearDepth(0);
pOpenGLDevice->glClear(GL_COLOR_BUFFER_BIT|((zbufenabled||tdmode)?GL_DEPTH_BUFFER_BIT:0));
}
void SMELT_IMPL::sm3DCamera6f2v(float *pos,float *rot)