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

Clarified some (im)possible null dereferences

This commit is contained in:
Ivan Savenko 2024-02-12 12:59:22 +02:00
parent 392c360f88
commit 6db405167d
2 changed files with 9 additions and 3 deletions

View File

@ -315,7 +315,7 @@ public:
void ptrAllocated(const T *ptr, ui32 pid)
{
if(smartPointerSerialization && pid != 0xffffffff)
loadedPointers[pid] = static_cast<void*>(ptr); //add loaded pointer to our lookup map; cast is to avoid errors with const T* pt
loadedPointers[pid] = (void*)ptr; //add loaded pointer to our lookup map; cast is to avoid errors with const T* pt
}
template<typename Base, typename Derived> void registerType(const Base * b = nullptr, const Derived * d = nullptr)

View File

@ -1573,8 +1573,11 @@ bool BattleActionProcessor::makePlayerBattleAction(const CBattleInfoCallback & b
else
{
auto active = battle.battleActiveUnit();
if(!active && gameHandler->complain("No active unit in battle!"))
if(!active)
{
gameHandler->complain("No active unit in battle!");
return false;
}
if (ba.isUnitAction() && ba.stackNumber != active->unitId())
{
@ -1584,9 +1587,12 @@ bool BattleActionProcessor::makePlayerBattleAction(const CBattleInfoCallback & b
auto unitOwner = battle.battleGetOwner(active);
if(player != unitOwner && gameHandler->complain("Can not make actions in battles you are not part of!"))
if(player != unitOwner)
{
gameHandler->complain("Can not make actions in battles you are not part of!");
return false;
}
}
return makeBattleActionImpl(battle, ba);
}