From c4ab962cc0640c490676d9d25b4c3f6524d8f955 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sun, 27 Nov 2016 17:48:18 +0300 Subject: [PATCH] Fixed a few CWE-457 --- AI/BattleAI/BattleAI.cpp | 2 +- AI/VCAI/VCAI.h | 1 + client/CGameInfo.cpp | 2 ++ client/CPreGame.cpp | 24 ++++++++----- client/CPreGame.h | 5 --- client/CVideoHandler.cpp | 27 +++++++++------ client/battle/CBattleAnimations.cpp | 52 ++++++++++++++--------------- client/gui/CAnimation.cpp | 3 +- client/gui/CGuiHandler.cpp | 50 ++++++++++++++------------- client/gui/CGuiHandler.h | 25 +++++++------- client/mapHandler.cpp | 8 +++++ client/mapHandler.h | 1 + client/widgets/Buttons.h | 3 -- lib/HeroBonus.cpp | 4 +++ lib/mapObjects/MiscObjects.h | 2 +- 15 files changed, 116 insertions(+), 93 deletions(-) diff --git a/AI/BattleAI/BattleAI.cpp b/AI/BattleAI/BattleAI.cpp index b43feef8f..37f3d7294 100644 --- a/AI/BattleAI/BattleAI.cpp +++ b/AI/BattleAI/BattleAI.cpp @@ -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) { } diff --git a/AI/VCAI/VCAI.h b/AI/VCAI/VCAI.h index bd83a9863..320b39a0f 100644 --- a/AI/VCAI/VCAI.h +++ b/AI/VCAI/VCAI.h @@ -83,6 +83,7 @@ struct SectorMap Sector() { id = -1; + water = false; } }; diff --git a/client/CGameInfo.cpp b/client/CGameInfo.cpp index cf2f596f0..6d0f9f63d 100644 --- a/client/CGameInfo.cpp +++ b/client/CGameInfo.cpp @@ -18,7 +18,9 @@ CClientState * CCS = nullptr; CGameInfo::CGameInfo() { + generaltexth = nullptr; mh = nullptr; + townh = nullptr; } void CGameInfo::setFromLib() diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 86182029b..cca557051 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -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 *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; } diff --git a/client/CPreGame.h b/client/CPreGame.h index 3dec873aa..89be9799e 100644 --- a/client/CPreGame.h +++ b/client/CPreGame.h @@ -129,7 +129,6 @@ class InfoCard : public CIntObject std::shared_ptr 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 campButtons; std::vector images; diff --git a/client/CVideoHandler.cpp b/client/CVideoHandler.cpp index 2be6eed85..aa5ffc911 100644 --- a/client/CVideoHandler.cpp +++ b/client/CVideoHandler.cpp @@ -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() / @@ -143,17 +150,17 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal } // Allocate video frame frame = av_frame_alloc(); - + //setup scaling if(scale) { - pos.w = screen->w; + pos.w = screen->w; pos.h = screen->h; } else { - pos.w = codecContext->width; - pos.h = codecContext->height; + pos.w = codecContext->width; + pos.h = codecContext->height; } // Allocate a place to put our YUV image on that screen @@ -174,7 +181,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal if (texture) { // Convert the image into YUV format that SDL uses - sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt, + sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt, pos.w, pos.h, AV_PIX_FMT_YUV420P, SWS_BICUBIC, nullptr, nullptr, nullptr); @@ -205,8 +212,8 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal } } - sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt, - pos.w, pos.h, screenFormat, + sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt, + pos.w, pos.h, screenFormat, SWS_BICUBIC, nullptr, nullptr, nullptr); } @@ -357,7 +364,7 @@ void CVideoPlayer::close() if (frame) { - av_frame_free(&frame);//will be set to null + av_frame_free(&frame);//will be set to null } if (codec) diff --git a/client/battle/CBattleAnimations.cpp b/client/battle/CBattleAnimations.cpp index 3bf787dbf..fe908d99c 100644 --- a/client/battle/CBattleAnimations.cpp +++ b/client/battle/CBattleAnimations.cpp @@ -133,13 +133,13 @@ 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) + bool isCatapultAttack = attackingStack->hasBonusOfType(Bonus::CATAPULT) && owner->getCurrentPlayerInterface()->cb->battleHexToWallPart(_dest) >= 0; assert(attackedStack || isCatapultAttack); @@ -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(); } @@ -198,7 +198,7 @@ bool CDefenceAnimation::init() //unit reversed if(rangedAttack) //delay hit animation - { + { for(std::list::const_iterator it = owner->projectiles.begin(); it != owner->projectiles.end(); ++it) { if(it->creID == attacker->getCreature()->idNumber) @@ -243,7 +243,7 @@ CCreatureAnim::EAnimType CDefenceAnimation::getMyAnimType() { if(killed) return CCreatureAnim::DEATH; - + if (vstd::contains(stack->state, EBattleStackState::DEFENDING_ANIM)) return CCreatureAnim::DEFENCE; @@ -281,7 +281,7 @@ void CDefenceAnimation::endAnim() delete this; } -CDummyAnimation::CDummyAnimation(CBattleInterface * _owner, int howManyFrames) +CDummyAnimation::CDummyAnimation(CBattleInterface * _owner, int howManyFrames) : CBattleAnimation(_owner), counter(0), howMany(howManyFrames) { logAnim->debugStream() << "Created dummy animation for " << howManyFrames <<" frames"; @@ -314,7 +314,7 @@ bool CMeleeAttackAnimation::init() if(!attackingStack || myAnim->isDead()) { endAnim(); - + return false; } @@ -370,7 +370,7 @@ bool CMeleeAttackAnimation::init() } CMeleeAttackAnimation::CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked) -: CAttackAnimation(_owner, attacker, _dest, _attacked) +: CAttackAnimation(_owner, attacker, _dest, _attacked) { logAnim->debugStream() << "Created melee attack anim for " << attacker->getName(); } @@ -534,7 +534,7 @@ CMovementAnimation::CMovementAnimation(CBattleInterface *_owner, const CStack *_ } CMovementEndAnimation::CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, BattleHex destTile) -: CBattleStackAnimation(_owner, _stack), destinationTile(destTile) +: CBattleStackAnimation(_owner, _stack), destinationTile(destTile) { logAnim->debugStream() << "Created movement end anim for " << stack->getName(); } @@ -573,7 +573,7 @@ void CMovementEndAnimation::endAnim() } CMovementStartAnimation::CMovementStartAnimation(CBattleInterface * _owner, const CStack * _stack) -: CBattleStackAnimation(_owner, _stack) +: CBattleStackAnimation(_owner, _stack) { logAnim->debugStream() << "Created movement start anim for " << stack->getName(); } @@ -776,7 +776,7 @@ bool CShootingAnimation::init() spi.dx = (destPos.x - spi.x) / spi.lastStep; spi.dy = (destPos.y - spi.y) / spi.lastStep; } - else + else { // Catapult attack spi.catapultInfo.reset(new CatapultProjectileInfo(Point(spi.x, spi.y), destPos)); @@ -885,7 +885,7 @@ CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, std::str CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, std::string _customAnim, BattleHex _destTile, bool _Vflip, bool _alignToBottom) :CBattleAnimation(_owner), effect(-1), destTile(_destTile), customAnim(_customAnim), x(-1), y(-1), dx(0), dy(0), Vflip(_Vflip), alignToBottom(_alignToBottom) { - logAnim->debugStream() << "Created spell anim for " << customAnim; + logAnim->debugStream() << "Created spell anim for " << customAnim; } @@ -893,21 +893,21 @@ bool CSpellEffectAnimation::init() { if(!isEarliest(true)) return false; - + if(customAnim.empty() && effect != ui32(-1) && !graphics->battleACToDef[effect].empty()) - { + { customAnim = graphics->battleACToDef[effect][0]; } - + if(customAnim.empty()) { endAnim(); - return false; + return false; } - + const bool areaEffect = (!destTile.isValid() && x == -1 && y == -1); - if(areaEffect) //f.e. armageddon + if(areaEffect) //f.e. armageddon { CDefHandler * anim = CDefHandler::giveDef(customAnim); @@ -934,7 +934,7 @@ bool CSpellEffectAnimation::init() owner->battleEffects.push_back(be); } } - + delete anim; } else // Effects targeted at a specific creature/hex. @@ -956,9 +956,9 @@ bool CSpellEffectAnimation::init() be.currentFrame = 0; be.maxFrame = be.anim->ourImages.size(); - + //todo: lightning anim frame count override - + // if(effect == 1) // be.maxFrame = 3; @@ -970,7 +970,7 @@ bool CSpellEffectAnimation::init() { be.x = x; } - + if(y == -1) { if(alignToBottom) @@ -993,7 +993,7 @@ bool CSpellEffectAnimation::init() owner->battleEffects.push_back(be); } - //battleEffects + //battleEffects return true; } diff --git a/client/gui/CAnimation.cpp b/client/gui/CAnimation.cpp index 91cde61f6..7df63e1a7 100644 --- a/client/gui/CAnimation.cpp +++ b/client/gui/CAnimation.cpp @@ -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) { } diff --git a/client/gui/CGuiHandler.cpp b/client/gui/CGuiHandler.cpp index f2cf35a32..f8a154de3 100644 --- a/client/gui/CGuiHandler.cpp +++ b/client/gui/CGuiHandler.cpp @@ -170,15 +170,15 @@ void CGuiHandler::updateTime() void CGuiHandler::handleEvents() { - //player interface may want special event handling + //player interface may want special event handling if(nullptr != LOCPLINT && LOCPLINT->capturedAllEvents()) return; - - boost::unique_lock lock(eventsM); + + boost::unique_lock lock(eventsM); while(!events.empty()) { SDL_Event ev = events.front(); - events.pop(); + events.pop(); this->handleEvent(&ev); } } @@ -286,14 +286,14 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent) { it->textInputed(sEvent->text); } - } + } else if(sEvent->type == SDL_TEXTEDITING) { for(auto it : textInterested) { it->textEdited(sEvent->edit); } - } + } //todo: muiltitouch else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_LEFT)) { @@ -398,9 +398,9 @@ void CGuiHandler::renderFrame() // Updating GUI requires locking pim mutex (that protects screen and GUI state). // During game: // When ending the game, the pim mutex might be hold by other thread, - // that will notify us about the ending game by setting terminate_cond flag. - //in PreGame terminate_cond stay false - + // that will notify us about the ending game by setting terminate_cond flag. + //in PreGame terminate_cond stay false + bool acquiredTheLockOnPim = false; //for tracking whether pim mutex locking succeeded while(!terminate_cond.get() && !(acquiredTheLockOnPim = CPlayerInterface::pim->try_lock())) //try acquiring long until it succeeds or we are told to terminate boost::this_thread::sleep(boost::posix_time::milliseconds(15)); @@ -412,25 +412,25 @@ void CGuiHandler::renderFrame() if(nullptr != curInt) curInt->update(); - + if (settings["general"]["showfps"].Bool()) - drawFPSCounter(); - + drawFPSCounter(); + // draw the mouse cursor and update the screen CCS->curh->render(); if(0 != SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr)) logGlobal->errorStream() << __FUNCTION__ << " SDL_RenderCopy " << SDL_GetError(); - SDL_RenderPresent(mainRenderer); - } + SDL_RenderPresent(mainRenderer); + } - mainFPSmng->framerateDelay(); // holds a constant FPS + mainFPSmng->framerateDelay(); // holds a constant FPS } CGuiHandler::CGuiHandler() -:lastClick(-500, -500) + : lastClick(-500, -500),lastClickTime(0), defActionsDef(0), captureChildren(false) { curInt = nullptr; current = nullptr; @@ -439,7 +439,7 @@ CGuiHandler::CGuiHandler() // Creates the FPS manager and sets the framerate to 48 which is doubled the value of the original Heroes 3 FPS rate mainFPSmng = new CFramerateManager(48); //do not init CFramerateManager here --AVS - + terminate_cond.set(false); } @@ -477,7 +477,7 @@ SDL_Keycode CGuiHandler::arrowToNum(SDL_Keycode key) return SDLK_KP_6; default: throw std::runtime_error("Wrong key!"); - } + } } SDL_Keycode CGuiHandler::numToDigit(SDL_Keycode key) @@ -495,7 +495,7 @@ SDL_Keycode CGuiHandler::numToDigit(SDL_Keycode key) REMOVE_KP(6) REMOVE_KP(7) REMOVE_KP(8) - REMOVE_KP(9) + REMOVE_KP(9) REMOVE_KP(PERIOD) REMOVE_KP(MINUS) REMOVE_KP(PLUS) @@ -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() @@ -557,23 +559,23 @@ void CFramerateManager::framerateDelay() { ui32 currentTicks = SDL_GetTicks(); timeElapsed = currentTicks - lastticks; - + // FPS is higher than it should be, then wait some time if (timeElapsed < rateticks) { SDL_Delay(ceil(this->rateticks) - timeElapsed); } - + accumulatedTime += timeElapsed; accumulatedFrames++; if(accumulatedFrames >= 100) { //about 2 second should be passed - fps = ceil(1000.0 / (accumulatedTime/accumulatedFrames)); + fps = ceil(1000.0 / (accumulatedTime/accumulatedFrames)); accumulatedTime = 0; - accumulatedFrames = 0; - }; + accumulatedFrames = 0; + }; currentTicks = SDL_GetTicks(); // recalculate timeElapsed for external calls via getElapsed() diff --git a/client/gui/CGuiHandler.h b/client/gui/CGuiHandler.h index 9226eafa3..3449dd76c 100644 --- a/client/gui/CGuiHandler.h +++ b/client/gui/CGuiHandler.h @@ -49,11 +49,11 @@ public: private: typedef std::list CIntObjectList; - + //active GUI elements (listening for events - CIntObjectList lclickable, - rclickable, - hoverable, + CIntObjectList lclickable, + rclickable, + hoverable, keyinterested, motioninterested, timeinterested, @@ -61,12 +61,12 @@ private: doubleClickInterested, textInterested; - - void processLists(const ui16 activityFlag, std::function *)> cb); + + void processLists(const ui16 activityFlag, std::function *)> cb); public: void handleElementActivate(CIntObject * elem, ui16 activityFlag); void handleElementDeActivate(CIntObject * elem, ui16 activityFlag); - + public: //objs to blit std::vector objsToBlit; @@ -77,9 +77,13 @@ 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 createdObj; //stack of objs being created + CGuiHandler(); ~CGuiHandler(); - + void renderFrame(); void totalRedraw(); //forces total redraw (using showAll), sets a flag, method gets called at the end of the rendering @@ -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 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 @@ -109,7 +110,7 @@ public: static bool isArrowKey(SDL_Keycode key); static bool amIGuiThread(); static void pushSDLEvent(int type, int usercode = 0); - + static CondSh terminate_cond; // confirm termination }; diff --git a/client/mapHandler.cpp b/client/mapHandler.cpp index 84c90a056..7efac572a 100644 --- a/client/mapHandler.cpp +++ b/client/mapHandler.cpp @@ -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("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) diff --git a/client/mapHandler.h b/client/mapHandler.h index 90a3f1938..635c53ea3 100644 --- a/client/mapHandler.h +++ b/client/mapHandler.h @@ -162,6 +162,7 @@ class CMapHandler std::array< std::map>, (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 diff --git a/client/widgets/Buttons.h b/client/widgets/Buttons.h index afe35bb35..e068f311e 100644 --- a/client/widgets/Buttons.h +++ b/client/widgets/Buttons.h @@ -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 diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 3d50f5eff..0d8a8e008 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -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) { } diff --git a/lib/mapObjects/MiscObjects.h b/lib/mapObjects/MiscObjects.h index eb571faf4..0585a9c44 100644 --- a/lib/mapObjects/MiscObjects.h +++ b/lib/mapObjects/MiscObjects.h @@ -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 void serialize(Handler &h, const int version)