aboutsummaryrefslogtreecommitdiff
path: root/extensions/smdatapack.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2015-08-17 22:40:33 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2015-08-17 22:40:33 +0800
commit03a307b58ddc6244d3fad8d77d7f0bac0a24e05d (patch)
treec578005d3c66ccc53ed454e63403c30f72230924 /extensions/smdatapack.cpp
parentbfe4f5ac512493bd9a359a06875288fbfaea6ff8 (diff)
downloadbullet-lab-remix-03a307b58ddc6244d3fad8d77d7f0bac0a24e05d.tar.xz
Fix crashes in smAnmFile.
Do not crash if a non-exist file is requested in a DTP file. Fix several stupid typos. Fix missing smEntity3D constructor. Fix line spacing in smTTFont.
Diffstat (limited to 'extensions/smdatapack.cpp')
-rw-r--r--extensions/smdatapack.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/extensions/smdatapack.cpp b/extensions/smdatapack.cpp
index 78082bb..2e77324 100644
--- a/extensions/smdatapack.cpp
+++ b/extensions/smdatapack.cpp
@@ -36,7 +36,7 @@ bool smDtpFileR::openDtp(const char* path)
m[std::string(f.path)]=f;
}
}
-bool smDtpFileR::openDtpFromMemory(char* ptr,DWORD size)
+bool smDtpFileR::openDtpFromMemory(const char* ptr,DWORD size)
{
enmemory=true;msize=size;
if(!ptr||size<4)return false;
@@ -84,6 +84,7 @@ char* smDtpFileR::getPrevFile(const char* path)
char* smDtpFileR::getFilePtr(const char* path)
{
std::string fns(path);
+ if(m.find(fns)==m.end()){printf("error: file not found in the archive.\n");return NULL;}
if(m.at(fns).data)return m.at(fns).data;
else
{
@@ -112,6 +113,7 @@ char* smDtpFileR::getFilePtr(const char* path)
void smDtpFileR::releaseFilePtr(const char* path)
{
std::string fns(path);
+ if(m.find(fns)==m.end()){printf("error: file not found in the archive.\n");return;}
if(m[fns].data)
{
delete[] m[fns].data;
@@ -119,7 +121,7 @@ void smDtpFileR::releaseFilePtr(const char* path)
}
}
DWORD smDtpFileR::getFileSize(const char* path)
-{return m[std::string(path)].size;}
+{if(m.find(std::string(path))==m.end()){printf("error: file not found in the archive.\n");return 0;}return m[std::string(path)].size;}
smDtpFileW::smDtpFileW(){fcnt=0;}
bool smDtpFileW::addFile(const char* path,const char* realpath)