- a few bugfixes related to coverity scan

This commit is contained in:
SoftCoder 2014-12-15 19:44:26 -08:00
parent 9392aa0fca
commit 8210485a42
9 changed files with 17 additions and 9 deletions

@ -1 +1 @@
Subproject commit b1c0f0cc18cdd2311b581b44e7ae161317438c93 Subproject commit 19119ebb9c7c91d364c8d413194e476aa815000b

View File

@ -1224,7 +1224,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
if(ai->outputAIBehaviourToConsole()) printf("produceSpecific aiInterface->reqsOk(ct) = [%d] Testing AI RULE Name[%s]\n",aiInterface->reqsOk(ct), this->getName().c_str()); if(ai->outputAIBehaviourToConsole()) printf("produceSpecific aiInterface->reqsOk(ct) = [%d] Testing AI RULE Name[%s]\n",aiInterface->reqsOk(ct), this->getName().c_str());
if(aiInterface->reqsOk(ct)){ if(aiInterface->reqsOk(ct)){
defCt= ct; //defCt= ct;
producers.push_back(i); producers.push_back(i);
producersDefaultCommandType[i].push_back(ct); producersDefaultCommandType[i].push_back(ct);
} }
@ -1779,7 +1779,7 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt) {
if(aiInterface->reqsOk(bct)) { if(aiInterface->reqsOk(bct)) {
builders.push_back(i); builders.push_back(i);
buildersDefaultCommandType[i].push_back(bct); buildersDefaultCommandType[i].push_back(bct);
defBct= bct; //defBct= bct;
} }
} }
} }

View File

@ -876,7 +876,10 @@ void GraphicScrollBar::setVisibleStart(int vs){
if(visibleStart<0) { if(visibleStart<0) {
visibleStart=0; visibleStart=0;
} }
float partSize=(float)getLength()/(float)elementCount; float partSize = 0.f;
if(elementCount > 0) {
partSize = (float)getLength()/(float)elementCount;
}
visibleCompPosStart=visibleStart*partSize; visibleCompPosStart=visibleStart*partSize;
visibleCompPosEnd=visibleStart*partSize+visibleSize*partSize; visibleCompPosEnd=visibleStart*partSize+visibleSize*partSize;
if(visibleCompPosEnd>getLength()) { if(visibleCompPosEnd>getLength()) {

View File

@ -316,6 +316,11 @@ Game::Game(Program *program, const GameSettings *gameSettings,bool masterserverM
this->masterserverMode = masterserverMode; this->masterserverMode = masterserverMode;
videoPlayer = NULL; videoPlayer = NULL;
playingStaticVideo = false; playingStaticVideo = false;
highlightCellTexture = NULL;
playerIndexDisconnect=0;
updateFpsAvgTest=0;
renderFpsAvgTest=0;
cameraDragAllowed=false;
if(this->masterserverMode == true) { if(this->masterserverMode == true) {
printf("Starting a new game...\n"); printf("Starting a new game...\n");

View File

@ -49,7 +49,7 @@ void Display::calculateUpDimensions(int index) {
maxUpIndex=index; maxUpIndex=index;
if(maxUpIndex+1>upCellSideCount*upCellSideCount){ if(maxUpIndex+1>upCellSideCount*upCellSideCount){
upCellSideCount=upCellSideCount+1; upCellSideCount=upCellSideCount+1;
upImageSize=imageSize*cellSideCount/upCellSideCount+0.9f; upImageSize = static_cast<float>(imageSize) * static_cast<float>(cellSideCount) / static_cast<float>(upCellSideCount) + 0.9f;
} }
} }
} }

View File

@ -1595,7 +1595,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
} }
if(canGrabSlot == true) { if(canGrabSlot == true) {
if(i < mapInfo.players && grabSlotButton[i].mouseClick(x, y)) { if(clientInterface != NULL && i < mapInfo.players && grabSlotButton[i].mouseClick(x, y)) {
//printf("Send slot switch request for slot = %d, myCurrentIndex = %d\n",i,myCurrentIndex); //printf("Send slot switch request for slot = %d, myCurrentIndex = %d\n",i,myCurrentIndex);
soundRenderer.playFx(coreData.getClickSoundB()); soundRenderer.playFx(coreData.getClickSoundB());

View File

@ -681,7 +681,7 @@ Model *SkillType::getAnimation(float animProgress, const Unit *unit,
for(unsigned int i = 0; i < animationAttributes.size(); ++i) { for(unsigned int i = 0; i < animationAttributes.size(); ++i) {
const AnimationAttributes &attributes = animationAttributes[i]; const AnimationAttributes &attributes = animationAttributes[i];
if(attributes.fromHp == 0 && attributes.toHp == 0) { if(attributes.fromHp == 0 && attributes.toHp == 0) {
modelIndex = i; //modelIndex = i;
foundSpecificAnimation = true; foundSpecificAnimation = true;
filteredAnimations.push_back(i); filteredAnimations.push_back(i);
//printf("SELECTING Model index = %d [%s] model attributes [%d to %d] for unit [%s - %d] with HP = %d\n",i,animations[modelIndex]->getFileName().c_str(),attributes.fromHp,attributes.toHp,unit->getType()->getName().c_str(),unit->getId(),unit->getHp()); //printf("SELECTING Model index = %d [%s] model attributes [%d to %d] for unit [%s - %d] with HP = %d\n",i,animations[modelIndex]->getFileName().c_str(),attributes.fromHp,attributes.toHp,unit->getType()->getName().c_str(),unit->getId(),unit->getHp());

View File

@ -477,7 +477,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
objNumber = ::Shared::PlatformByteOrder::fromCommonEndian(objNumber); objNumber = ::Shared::PlatformByteOrder::fromCommonEndian(objNumber);
SurfaceCell *sc= getSurfaceCell(toSurfCoords(Vec2i(i, j))); SurfaceCell *sc= getSurfaceCell(toSurfCoords(Vec2i(i, j)));
if(objNumber == 0) { if(objNumber <= 0) {
sc->setObject(NULL); sc->setObject(NULL);
} }
else if(objNumber <= Tileset::objCount) { else if(objNumber <= Tileset::objCount) {

View File

@ -164,7 +164,7 @@ int ftpStat(const char* path, ftpPathInfo_S *info)
pw = getpwuid(fileInfo.st_uid); pw = getpwuid(fileInfo.st_uid);
if(pw) if(pw)
strncpy(info->user, pw->pw_name, sizeof(info->user)); strncpy(info->user, pw->pw_name, sizeof(info->user)-1);
else else
snprintf(info->user, 20,"%04d", fileInfo.st_uid); snprintf(info->user, 20,"%04d", fileInfo.st_uid);