1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +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) void ptrAllocated(const T *ptr, ui32 pid)
{ {
if(smartPointerSerialization && pid != 0xffffffff) 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) 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 else
{ {
auto active = battle.battleActiveUnit(); auto active = battle.battleActiveUnit();
if(!active && gameHandler->complain("No active unit in battle!")) if(!active)
{
gameHandler->complain("No active unit in battle!");
return false; return false;
}
if (ba.isUnitAction() && ba.stackNumber != active->unitId()) if (ba.isUnitAction() && ba.stackNumber != active->unitId())
{ {
@@ -1584,8 +1587,11 @@ bool BattleActionProcessor::makePlayerBattleAction(const CBattleInfoCallback & b
auto unitOwner = battle.battleGetOwner(active); 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 false;
}
} }
return makeBattleActionImpl(battle, ba); return makeBattleActionImpl(battle, ba);