- memory leak and a few other minor bug fixes as discovered by coverity scan.

This commit is contained in:
SoftCoder
2014-11-30 15:30:02 -08:00
parent 829f23db4e
commit 5e292e931c
3 changed files with 24 additions and 13 deletions

View File

@@ -1033,8 +1033,11 @@ void ScriptManager::shakeCamera(int shakeIntensity, int shakeDuration, bool came
if (cameraDistanceAffected) { if (cameraDistanceAffected) {
Unit *unit = world->findUnitById(unitId); Unit *unit = world->findUnitById(unitId);
if(unit) {
gameCamera->shake(shakeDuration, shakeIntensity,cameraDistanceAffected, unit->getCurrMidHeightVector()); gameCamera->shake(shakeDuration, shakeIntensity,cameraDistanceAffected, unit->getCurrMidHeightVector());
} else { }
}
else {
gameCamera->shake(shakeDuration, shakeIntensity,cameraDistanceAffected, Vec3f(0.f,0.f,0.f)); gameCamera->shake(shakeDuration, shakeIntensity,cameraDistanceAffected, Vec3f(0.f,0.f,0.f));
} }
} }
@@ -1542,7 +1545,12 @@ int ScriptManager::getUnitFaction(int unitId) {
const string ScriptManager::getUnitName(int unitId) { const string ScriptManager::getUnitName(int unitId) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
return world->findUnitById(unitId)->getType()->getName(false); string result = "";
Unit *unit = world->findUnitById(unitId);
if(unit) {
result = world->findUnitById(unitId)->getType()->getName(false);
}
return result;
} }
const string ScriptManager::getUnitDisplayName(int unitId) { const string ScriptManager::getUnitDisplayName(int unitId) {

View File

@@ -968,6 +968,9 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
delete projectileType; delete projectileType;
} }
} }
else {
delete projectileType;
}
//proj sounds //proj sounds
const XmlNode *soundNode= projectileNode->getChild("sound"); const XmlNode *soundNode= projectileNode->getChild("sound");
if(soundNode->getAttribute("enabled")->getBoolValue()){ if(soundNode->getAttribute("enabled")->getBoolValue()){

View File

@@ -2676,10 +2676,10 @@ int UPNP_Tools::upnp_init(void *param) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"No UPnP devices found.\n"); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"No UPnP devices found.\n");
if(ServerSocket::cancelUpnpdiscoverThread == true) { if(ServerSocket::cancelUpnpdiscoverThread == true) {
if(devlist != NULL) { //if(devlist != NULL) {
freeUPNPDevlist(devlist); // freeUPNPDevlist(devlist);
} //}
devlist = NULL; //devlist = NULL;
return result; return result;
} }