From 2e0b12061b932009818bcb7d373ae481728ec927 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Mon, 17 Aug 2015 23:44:38 +0800 Subject: Bug fixes (again). Further more fixes for smAnmFile. There could be more bugs... Fix Z Buffer blackening the whole screen in 2D mode. --- extensions/smanim.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'extensions') 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') { -- cgit v1.2.3