1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

corrected text in vcmibuilder, corrected errors and warnings from cppcheck

This commit is contained in:
KroArtem 2014-11-16 20:48:29 +03:00
parent 885b495cf4
commit e73c60740c
10 changed files with 21 additions and 18 deletions

View File

@ -678,7 +678,7 @@ void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, u
//print info about life drain //print info about life drain
char textBuf[1000]; char textBuf[1000];
sprintf(textBuf, CGI->generaltexth->allTexts[361 + textOff].c_str(), attacker->getCreature()->nameSing.c_str(), snprintf(textBuf, 1000, CGI->generaltexth->allTexts[361 + textOff].c_str(), attacker->getCreature()->nameSing.c_str(),
healedStacks[0].second, defender->getCreature()->namePl.c_str()); healedStacks[0].second, defender->getCreature()->namePl.c_str());
battleInt->console->addText(textBuf); battleInt->console->addText(textBuf);
} }

View File

@ -832,7 +832,7 @@ void CBattleInterface::bFleef()
heroName = defendingHeroInstance->name; heroName = defendingHeroInstance->name;
//calculating text //calculating text
char buffer[1000]; char buffer[1000];
sprintf(buffer, CGI->generaltexth->allTexts[340].c_str(), heroName.c_str()); //The Shackles of War are present. %s can not retreat! snprintf(buffer, 1000, CGI->generaltexth->allTexts[340].c_str(), heroName.c_str()); //The Shackles of War are present. %s can not retreat!
//printing message //printing message
curInt->showInfoDialog(std::string(buffer), comps); curInt->showInfoDialog(std::string(buffer), comps);
@ -1523,7 +1523,7 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
BonusList defenseBonuses = *(stack->getBonuses(Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE))); BonusList defenseBonuses = *(stack->getBonuses(Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE)));
defenseBonuses.remove_if(Selector::durationType(Bonus::STACK_GETS_TURN)); //remove bonuses gained from defensive stance defenseBonuses.remove_if(Selector::durationType(Bonus::STACK_GETS_TURN)); //remove bonuses gained from defensive stance
int val = stack->Defense() - defenseBonuses.totalValue(); int val = stack->Defense() - defenseBonuses.totalValue();
sprintf(txt, CGI->generaltexth->allTexts[txtid].c_str(), (stack->count != 1) ? stack->getCreature()->namePl.c_str() : stack->getCreature()->nameSing.c_str(), val); sprintf(txt, 4000, CGI->generaltexth->allTexts[txtid].c_str(), (stack->count != 1) ? stack->getCreature()->namePl.c_str() : stack->getCreature()->nameSing.c_str(), val);
console->addText(txt); console->addText(txt);
} }
} }
@ -1797,19 +1797,19 @@ void CBattleInterface::printConsoleAttacked( const CStack * defender, int dmg, i
int end = 0; int end = 0;
if (attacker) //ignore if stacks were killed by spell if (attacker) //ignore if stacks were killed by spell
{ {
end = sprintf(tabh, CGI->generaltexth->allTexts[attacker->count > 1 ? 377 : 376].c_str(), end = snprintf(tabh, 200, CGI->generaltexth->allTexts[attacker->count > 1 ? 377 : 376].c_str(),
(attacker->count > 1 ? attacker->getCreature()->namePl.c_str() : attacker->getCreature()->nameSing.c_str()), dmg); (attacker->count > 1 ? attacker->getCreature()->namePl.c_str() : attacker->getCreature()->nameSing.c_str()), dmg);
} }
if(killed > 0) if(killed > 0)
{ {
if(killed > 1) if(killed > 1)
{ {
sprintf(tabh + end, CGI->generaltexth->allTexts[379].c_str(), killed, snprintf(tabh + end, 400, CGI->generaltexth->allTexts[379].c_str(), killed,
multiple ? CGI->generaltexth->allTexts[43].c_str() : defender->getCreature()->namePl.c_str()); // creatures perish multiple ? CGI->generaltexth->allTexts[43].c_str() : defender->getCreature()->namePl.c_str()); // creatures perish
} }
else //killed == 1 else //killed == 1
{ {
sprintf(tabh + end, CGI->generaltexth->allTexts[378].c_str(), snprintf(tabh + end, 400, CGI->generaltexth->allTexts[378].c_str(),
multiple ? CGI->generaltexth->allTexts[42].c_str() : defender->getCreature()->nameSing.c_str()); // creature perishes multiple ? CGI->generaltexth->allTexts[42].c_str() : defender->getCreature()->nameSing.c_str()); // creature perishes
} }
} }

View File

@ -579,7 +579,7 @@ void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
{ {
char tabh[160]; char tabh[160];
const std::string & attackedName = attackedStack->count == 1 ? attackedStack->getCreature()->nameSing : attackedStack->getCreature()->namePl; const std::string & attackedName = attackedStack->count == 1 ? attackedStack->getCreature()->nameSing : attackedStack->getCreature()->namePl;
sprintf(tabh, CGI->generaltexth->allTexts[220].c_str(), attackedName.c_str()); snprintf(tabh, 160, CGI->generaltexth->allTexts[220].c_str(), attackedName.c_str());
myInterface->console->alterTxt = std::string(tabh); myInterface->console->alterTxt = std::string(tabh);
setAlterText = true; setAlterText = true;
} }

View File

@ -383,7 +383,7 @@ void MoraleLuckBox::set(const IBonusBearer *node)
else else
{ {
//it's a creature window //it's a creature window
if ((morale && node->hasBonusOfType(Bonus::UNDEAD)) || if ((morale && node && node->hasBonusOfType(Bonus::UNDEAD)) ||
node->hasBonusOfType(Bonus::BLOCK_MORALE) || node->hasBonusOfType(Bonus::NON_LIVING)) node->hasBonusOfType(Bonus::BLOCK_MORALE) || node->hasBonusOfType(Bonus::NON_LIVING))
{ {
text += CGI->generaltexth->arraytxt[113]; //unaffected by morale text += CGI->generaltexth->arraytxt[113]; //unaffected by morale

View File

@ -1378,11 +1378,11 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack
case -WN: //-17 //left-up or right-up case -WN: //-17 //left-up or right-up
case WN + 1: //18 //right-down case WN + 1: //18 //right-down
case -WN + 1: //-16 //right-up case -WN + 1: //-16 //right-up
BattleHex::checkAndPush (destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : -1 ), hexes); BattleHex::checkAndPush (destinationTile.hex + pseudoVector + (((hex/WN)%2) ? 1 : -1 ), hexes);
break; break;
case WN-1: //16 //left-down case WN-1: //16 //left-down
case -WN-1: //-18 //left-up case -WN-1: //-18 //left-up
BattleHex::checkAndPush (destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : 0), hexes); BattleHex::checkAndPush (destinationTile.hex + pseudoVector + (((hex/WN)%2) ? 1 : 0), hexes);
break; break;
} }
for (BattleHex tile : hexes) for (BattleHex tile : hexes)
@ -1819,7 +1819,6 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
case CSpell::NEUTRAL: case CSpell::NEUTRAL:
targetExists = true; targetExists = true;
break; break;
break;
case CSpell::NEGATIVE: case CSpell::NEGATIVE:
if(!casterStack || !ti.smart) if(!casterStack || !ti.smart)
{ {

View File

@ -478,7 +478,7 @@ std::vector<CTypeList::TypeInfoPtr> CTypeList::castSequence(TypeInfoPtr from, Ty
std::map<TypeInfoPtr, TypeInfoPtr> previous; std::map<TypeInfoPtr, TypeInfoPtr> previous;
std::queue<TypeInfoPtr> q; std::queue<TypeInfoPtr> q;
q.push(to); q.push(to);
while(q.size()) while(!q.empty())
{ {
auto typeNode = q.front(); auto typeNode = q.front();
q.pop(); q.pop();

View File

@ -677,7 +677,7 @@ void CGBonusingObject::initObj()
for (int i=0; i<6; i++) for (int i=0; i<6; i++)
{ {
info[i].limiter.dayOfWeek = i+1; info[i].limiter.dayOfWeek = i+1;
configureBonus(info[i], i%2 ? Bonus::MORALE : Bonus::LUCK, 1, 68); configureBonus(info[i], (i%2) ? Bonus::MORALE : Bonus::LUCK, 1, 68);
info[i].message.addTxt(MetaString::ADVOB_TXT, 62); info[i].message.addTxt(MetaString::ADVOB_TXT, 62);
soundID = soundBase::experience; soundID = soundBase::experience;
} }

View File

@ -430,7 +430,7 @@ void CRmgTemplateZone::fractalize(CMapGenerator* gen)
} }
assert (clearedTiles.size()); //this should come from zone connections assert (clearedTiles.size()); //this should come from zone connections
while (possibleTiles.size()) while (!possibleTiles.empty())
{ {
//link tiles in random order //link tiles in random order
std::vector<int3> tilesToMakePath(possibleTiles.begin(), possibleTiles.end()); std::vector<int3> tilesToMakePath(possibleTiles.begin(), possibleTiles.end());
@ -811,7 +811,7 @@ bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos, float
} }
} }
if (treasures.size()) if (!treasures.empty())
{ {
//find object closest to zone center, then connect it to the middle of the zone //find object closest to zone center, then connect it to the middle of the zone
int3 closestFreeTile (-1,-1,-1); int3 closestFreeTile (-1,-1,-1);
@ -2000,7 +2000,7 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
{ {
creaturesAmount = boost::math::round(creaturesAmount / 5) * 5; creaturesAmount = boost::math::round(creaturesAmount / 5) * 5;
} }
else if (creaturesAmount <= 12) else if (creaturesAmount <= 120)
{ {
creaturesAmount = boost::math::round(creaturesAmount / 10) * 10; creaturesAmount = boost::math::round(creaturesAmount / 10) * 10;
} }
@ -2070,12 +2070,16 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
{ {
case 1: case 1:
school = spell->air; school = spell->air;
break;
case 2: case 2:
school = spell->earth; school = spell->earth;
break;
case 3: case 3:
school = spell->fire; school = spell->fire;
break;
case 4: case 4:
school = spell->water; school = spell->water;
break;
} }
if (school) if (school)
spells.push_back(spell); spells.push_back(spell);

View File

@ -3389,7 +3389,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
break; break;
} }
if(destinationStack && stack->ID == destinationStack->ID) //we should just move, it will be handled by following check if(destinationStack && stack && stack->ID == destinationStack->ID) //we should just move, it will be handled by following check
{ {
destinationStack = nullptr; destinationStack = nullptr;
} }

View File

@ -56,7 +56,7 @@ then
# echo " --download " "Automatically download optional package using wget" # echo " --download " "Automatically download optional package using wget"
# echo " " "Requires wget and Internet connection" # echo " " "Requires wget and Internet connection"
# echo # echo
echo " --dest DIRECTORY " "Path where resulting data will be placed. Default is ~/.vcmi" echo " --dest DIRECTORY " "Path where resulting data will be placed. Default is ~/.local/share/vcmi"
echo echo
echo " --validate " "Run basic validness checks" echo " --validate " "Run basic validness checks"
exit 0 exit 0