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

Fixed a few CWE-457

This commit is contained in:
AlexVinS 2016-11-27 17:48:18 +03:00
parent f11c54b5e9
commit c4ab962cc0
15 changed files with 116 additions and 93 deletions

View File

@ -36,7 +36,7 @@
#define LOGFL(text, formattingEl) print(boost::str(boost::format(text) % formattingEl))
CBattleAI::CBattleAI(void)
: side(-1)
: side(-1), wasWaitingForRealize(false), wasUnlockingGs(false)
{
}

View File

@ -83,6 +83,7 @@ struct SectorMap
Sector()
{
id = -1;
water = false;
}
};

View File

@ -18,7 +18,9 @@ CClientState * CCS = nullptr;
CGameInfo::CGameInfo()
{
generaltexth = nullptr;
mh = nullptr;
townh = nullptr;
}
void CGameInfo::setFromLib()

View File

@ -620,6 +620,7 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
if (screenType == CMenuScreen::campaignList)
{
opt = nullptr;
randMapTab = nullptr;
}
else
{
@ -3912,6 +3913,7 @@ CSavingScreen::~CSavingScreen()
ISelectionScreenInfo::ISelectionScreenInfo(const std::map<ui8, std::string> *Names /*= nullptr*/)
{
multiPlayer = CMenuScreen::SINGLE_PLAYER;
screenType = CMenuScreen::mainMenu;
assert(!SEL);
SEL = this;
current = nullptr;
@ -4102,6 +4104,8 @@ void StartWithCurrentSettings::apply(CSelectionScreen *selScreen)
CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode &config )
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
pos.x += config["x"].Float();
pos.y += config["y"].Float();
pos.w = 200;
@ -4110,24 +4114,23 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode &config )
campFile = config["file"].String();
video = config["video"].String();
OBJ_CONSTRUCTION_CAPTURING_ALL;
status = config["open"].Bool() ? CCampaignScreen::ENABLED : CCampaignScreen::DISABLED;
CCampaignHeader header = CCampaignHandler::getHeader(campFile);
hoverText = header.name;
hoverLabel = nullptr;
if (status != CCampaignScreen::DISABLED)
{
addUsedEvents(LCLICK | HOVER);
image = new CPicture(config["image"].String());
new CPicture(config["image"].String());
hoverLabel = new CLabel(pos.w / 2, pos.h + 20, FONT_MEDIUM, CENTER, Colors::YELLOW, "");
parent->addChild(hoverLabel);
}
if (status == CCampaignScreen::COMPLETED)
checkMark = new CPicture("CAMPCHK");
new CPicture("CAMPCHK");
}
void CCampaignScreen::CCampaignButton::clickLeft(tribool down, bool previousState)
@ -4142,10 +4145,13 @@ void CCampaignScreen::CCampaignButton::clickLeft(tribool down, bool previousStat
void CCampaignScreen::CCampaignButton::hover(bool on)
{
if (on)
hoverLabel->setText(hoverText); // Shows the name of the campaign when you get into the bounds of the button
else
hoverLabel->setText(" ");
if (hoverLabel)
{
if (on)
hoverLabel->setText(hoverText); // Shows the name of the campaign when you get into the bounds of the button
else
hoverLabel->setText(" ");
}
}
void CCampaignScreen::CCampaignButton::show(SDL_Surface * to)
@ -4198,7 +4204,7 @@ CCampaignScreen::CCampaignScreen(const JsonNode &config)
if (!config["exitbutton"].isNull())
{
back = createExitButton(config["exitbutton"]);
CButton * back = createExitButton(config["exitbutton"]);
back->hoverable = true;
}

View File

@ -129,7 +129,6 @@ class InfoCard : public CIntObject
std::shared_ptr<CAnimation> sFlags;
public:
CPicture *bg;
CMenuScreen::EState type;
bool network;
bool chatOn; //if chat is shown, then description is hidden
@ -554,9 +553,6 @@ private:
class CCampaignButton : public CIntObject
{
private:
CPicture *image;
CPicture *checkMark;
CLabel *hoverLabel;
CampaignStatus status;
@ -572,7 +568,6 @@ private:
void show(SDL_Surface * to) override;
};
CButton *back;
std::vector<CCampaignButton*> campButtons;
std::vector<CPicture*> images;

View File

@ -49,13 +49,20 @@ static si64 lodSeek(void * opaque, si64 pos, int whence)
CVideoPlayer::CVideoPlayer()
{
stream = -1;
format = nullptr;
frame = nullptr;
codecContext = nullptr;
codec = nullptr;
frame = nullptr;
sws = nullptr;
context = nullptr;
texture = nullptr;
dest = nullptr;
context = nullptr;
destRect = genRect(0,0,0,0);
pos = genRect(0,0,0,0);
refreshWait = 0;
refreshCount = 0;
doLoop = false;
// Register codecs. TODO: May be overkill. Should call a
// combination of av_register_input_format() /

View File

@ -133,11 +133,11 @@ bool CAttackAnimation::checkInitialConditions()
}
CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, BattleHex _dest, const CStack *defender)
: CBattleStackAnimation(_owner, attacker),
soundPlayed(false),
dest(_dest), attackedStack(defender), attackingStack(attacker)
: CBattleStackAnimation(_owner, attacker),
shooting(false), group(CCreatureAnim::SHOOT_FRONT),
soundPlayed(false),
dest(_dest), attackedStack(defender), attackingStack(attacker)
{
assert(attackingStack && "attackingStack is nullptr in CBattleAttack::CBattleAttack !\n");
bool isCatapultAttack = attackingStack->hasBonusOfType(Bonus::CATAPULT)
&& owner->getCurrentPlayerInterface()->cb->battleHexToWallPart(_dest) >= 0;
@ -150,7 +150,7 @@ CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attac
CDefenceAnimation::CDefenceAnimation(StackAttackedInfo _attackedInfo, CBattleInterface * _owner)
: CBattleStackAnimation(_owner, _attackedInfo.defender),
attacker(_attackedInfo.attacker), rangedAttack(_attackedInfo.indirectAttack),
killed(_attackedInfo.killed)
killed(_attackedInfo.killed), timeToWait(0)
{
logAnim->debugStream() << "Created defence anim for " << _attackedInfo.defender->getName();
}

View File

@ -1557,8 +1557,7 @@ bool CFadeAnimation::isFinished() const
}
CFadeAnimation::CFadeAnimation()
: fadingSurface(nullptr),
fading(false),
: delta(0), fadingSurface(nullptr), fading(false), fadingCounter(0), shouldFreeSurface(false),
fadingMode(EMode::NONE)
{
}

View File

@ -430,7 +430,7 @@ void CGuiHandler::renderFrame()
CGuiHandler::CGuiHandler()
:lastClick(-500, -500)
: lastClick(-500, -500),lastClickTime(0), defActionsDef(0), captureChildren(false)
{
curInt = nullptr;
current = nullptr;
@ -546,6 +546,8 @@ CFramerateManager::CFramerateManager(int rate)
this->fps = 0;
this->accumulatedFrames = 0;
this->accumulatedTime = 0;
this->lastticks = 0;
this->timeElapsed = 0;
}
void CFramerateManager::init()

View File

@ -77,6 +77,10 @@ public:
Point lastClick;
unsigned lastClickTime;
ui8 defActionsDef; //default auto actions
bool captureChildren; //all newly created objects will get their parents from stack and will be added to parents children list
std::list<CIntObject *> createdObj; //stack of objs being created
CGuiHandler();
~CGuiHandler();
@ -99,9 +103,6 @@ public:
void fakeMouseMove();
void breakEventHandling(); //current event won't be propagated anymore
void drawFPSCounter(); // draws the FPS to the upper left corner of the screen
ui8 defActionsDef; //default auto actions
ui8 captureChildren; //all newly created objects will get their parents from stack and will be added to parents children list
std::list<CIntObject *> createdObj; //stack of objs being created
static SDL_Keycode arrowToNum(SDL_Keycode key); //converts arrow key to according numpad key
static SDL_Keycode numToDigit(SDL_Keycode key);//converts numpad digit key to normal digit key

View File

@ -1377,6 +1377,9 @@ CMapHandler::CMapHandler()
worldViewBlitter = new CMapWorldViewBlitter(this);
puzzleViewBlitter = new CMapPuzzleViewBlitter(this);
fadeAnimCounter = 0;
map = nullptr;
tilesW = tilesH = 0;
offsetX = offsetY = 0;
egdeAnimation = make_unique<CAnimation>("EDG");
egdeAnimation->preload();
@ -1413,6 +1416,11 @@ void CMapHandler::discardWorldViewCache()
cache.discardWorldViewCache();
}
CMapHandler::CMapCache::CMapCache()
{
worldViewCachedScale = 0;
}
void CMapHandler::CMapCache::discardWorldViewCache()
{
for(auto & cache : data)

View File

@ -162,6 +162,7 @@ class CMapHandler
std::array< std::map<intptr_t, std::unique_ptr<IImage>>, (ui8)EMapCacheType::AFTER_LAST> data;
float worldViewCachedScale;
public:
CMapCache();
/// destroys all cached data (frees surfaces)
void discardWorldViewCache();
/// updates scale and determines if currently cached data is still valid

View File

@ -199,9 +199,6 @@ class CSlider : public CIntObject
int capacity;//how many elements can be active at same time (e.g. hero list = 5)
int positions; //number of highest position (0 if there is only one)
bool horizontal;
bool wheelScrolling;
bool keyScrolling;
int amount; //total amount of elements (e.g. hero list = 0-8)
int value; //first active element
int scrollStep; // how many elements will be scrolled via one click, default = 1

View File

@ -1329,6 +1329,7 @@ bool IPropagator::shouldBeAttached(CBonusSystemNode *dest)
}
CPropagatorNodeType::CPropagatorNodeType()
:nodeType(0)
{
}
@ -1349,6 +1350,7 @@ CreatureNativeTerrainLimiter::CreatureNativeTerrainLimiter(int TerrainType)
}
CreatureNativeTerrainLimiter::CreatureNativeTerrainLimiter()
: terrainType(-1)
{
}
@ -1366,6 +1368,7 @@ CreatureFactionLimiter::CreatureFactionLimiter(int Faction)
}
CreatureFactionLimiter::CreatureFactionLimiter()
: faction(-1)
{
}
@ -1376,6 +1379,7 @@ int CreatureFactionLimiter::limit(const BonusLimitationContext &context) const
}
CreatureAlignmentLimiter::CreatureAlignmentLimiter()
: alignment(-1)
{
}

View File

@ -142,7 +142,7 @@ public:
EBonusType bonusType;
ui16 bonusID; //ID of skill/spell
CGScholar() : bonusType(EBonusType::RANDOM){};
CGScholar() : bonusType(EBonusType::RANDOM),bonusID(0){};
void onHeroVisit(const CGHeroInstance * h) const override;
void initObj(CRandomGenerator & rand) override;
template <typename Handler> void serialize(Handler &h, const int version)