mirror of https://github.com/axmolengine/axmol.git
Update AssetsManager.cpp
fix: crash when default constructor params packageUrl, versionFileUrl,.. is NULL fix: percent
This commit is contained in:
parent
e99b99cc79
commit
8212b1398f
|
@ -85,10 +85,10 @@ struct ProgressMessage
|
||||||
// Implementation of AssetsManager
|
// Implementation of AssetsManager
|
||||||
|
|
||||||
AssetsManager::AssetsManager(const char* packageUrl/* =nullptr */, const char* versionFileUrl/* =nullptr */, const char* storagePath/* =nullptr */)
|
AssetsManager::AssetsManager(const char* packageUrl/* =nullptr */, const char* versionFileUrl/* =nullptr */, const char* storagePath/* =nullptr */)
|
||||||
: _storagePath(storagePath)
|
: _storagePath(storagePath ? storagePath : "")
|
||||||
, _version("")
|
, _version("")
|
||||||
, _packageUrl(packageUrl)
|
, _packageUrl(packageUrl ? packageUrl : "")
|
||||||
, _versionFileUrl(versionFileUrl)
|
, _versionFileUrl(versionFileUrl ? versionFileUrl : "")
|
||||||
, _downloadedVersion("")
|
, _downloadedVersion("")
|
||||||
, _curl(nullptr)
|
, _curl(nullptr)
|
||||||
, _connectionTimeout(0)
|
, _connectionTimeout(0)
|
||||||
|
@ -180,8 +180,7 @@ bool AssetsManager::checkUpdate()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string recordedVersion = UserDefault::getInstance()->getStringForKey(keyOfVersion().c_str());
|
if (getVersion() == _version)
|
||||||
if (recordedVersion == _version)
|
|
||||||
{
|
{
|
||||||
Director::getInstance()->getScheduler()->performFunctionInCocosThread([&, this]{
|
Director::getInstance()->getScheduler()->performFunctionInCocosThread([&, this]{
|
||||||
if (this->_delegate)
|
if (this->_delegate)
|
||||||
|
@ -496,7 +495,10 @@ static size_t downLoadPackage(void *ptr, size_t size, size_t nmemb, void *userda
|
||||||
int assetsManagerProgressFunc(void *ptr, double totalToDownload, double nowDownloaded, double totalToUpLoad, double nowUpLoaded)
|
int assetsManagerProgressFunc(void *ptr, double totalToDownload, double nowDownloaded, double totalToUpLoad, double nowUpLoaded)
|
||||||
{
|
{
|
||||||
static int percent = 0;
|
static int percent = 0;
|
||||||
int tmp = (int)(nowDownloaded / totalToDownload * 100);
|
int tmp = 0;
|
||||||
|
if (totalToDownload > 0) {
|
||||||
|
tmp = (int)(nowDownloaded / totalToDownload * 100);
|
||||||
|
}
|
||||||
|
|
||||||
if (percent != tmp)
|
if (percent != tmp)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue