Procházet zdrojové kódy

Fix potentially uninitialized values

Ivan Savenko před 1 rokem
rodič
revize
c577ea3e8d

+ 1 - 0
AI/Nullkiller/Pathfinding/AINodeStorage.cpp

@@ -843,6 +843,7 @@ ExchangeCandidate HeroChainCalculationTask::calculateExchange(
 	candidate.turns = carrierParentNode->turns;
 	candidate.setCost(carrierParentNode->getCost() + otherParentNode->getCost() / 1000.0);
 	candidate.moveRemains = carrierParentNode->moveRemains;
+	candidate.danger = carrierParentNode->danger;
 
 	if(carrierParentNode->turns < otherParentNode->turns)
 	{

+ 13 - 13
AI/Nullkiller/Pathfinding/Actors.h

@@ -51,24 +51,24 @@ protected:
 
 public:
 	uint64_t chainMask;
-	bool isMovable;
-	bool allowUseResources;
-	bool allowBattle;
-	bool allowSpellCast;
+	bool isMovable = false;
+	bool allowUseResources = false;
+	bool allowBattle = false;
+	bool allowSpellCast = false;
 	std::shared_ptr<SpecialAction> actorAction;
 	const CGHeroInstance * hero;
 	HeroRole heroRole;
-	const CCreatureSet * creatureSet;
-	const ChainActor * battleActor;
-	const ChainActor * castActor;
-	const ChainActor * resourceActor;
-	const ChainActor * carrierParent;
-	const ChainActor * otherParent;
-	const ChainActor * baseActor;
+	const CCreatureSet * creatureSet = nullptr;
+	const ChainActor * battleActor = nullptr;
+	const ChainActor * castActor = nullptr;
+	const ChainActor * resourceActor = nullptr;
+	const ChainActor * carrierParent = nullptr;
+	const ChainActor * otherParent = nullptr;
+	const ChainActor * baseActor = nullptr;
 	int3 initialPosition;
 	EPathfindingLayer layer;
-	uint32_t initialMovement;
-	uint32_t initialTurn;
+	uint32_t initialMovement = 0;
+	uint32_t initialTurn = 0;
 	uint64_t armyValue;
 	float heroFightingStrength;
 	uint8_t actorExchangeCount;

+ 1 - 1
client/Client.cpp

@@ -537,7 +537,7 @@ void CClient::handlePack(CPack * pack)
 
 int CClient::sendRequest(const CPackForServer * request, PlayerColor player)
 {
-	static ui32 requestCounter = 0;
+	static ui32 requestCounter = 1;
 
 	ui32 requestID = requestCounter++;
 	logNetwork->trace("Sending a request \"%s\". It'll have an ID=%d.", typeid(*request).name(), requestID);

+ 1 - 1
lib/networkPacks/NetPacksBase.h

@@ -64,7 +64,7 @@ struct DLL_LINKAGE Query : public CPackForClient
 struct DLL_LINKAGE CPackForServer : public CPack
 {
 	mutable PlayerColor player = PlayerColor::NEUTRAL;
-	mutable si32 requestID;
+	mutable uint32_t requestID = 0;
 
 	template <typename Handler> void serialize(Handler &h)
 	{