CvUnit vs. UnitHandle

Joined
Jul 31, 2014
Messages
836
Is there any meaningful difference between these? My impression is that the UnitHandle is some sort of pseudo-pointer as it can access the same attributes/functions of the CvUnit class that a CvUnit* pointer is able to access.

Code:
CvUnit* pUnit = pPlot->getVisibleEnemyDefender(pPlayer)

UnitHandle hUnit = pPlot->getBestDefender(pPlayer)
 
Is there any meaningful difference between these?

Short answer - no.

Longer answer is in FirePlace\include\FireWorks\FObjectHandle.h which is a way for tracking usage of dangling pointers (a C related bad-programming issue ... now if the code was truly C++ and not a port of C into C++ ...)
 
I see...

I assume nothing "bad" would happen if I were to replace existing UnitHandles with CvUnit* pointers instead (beyond having to rename variable types)?
 
and type checking errors if you try to pass them into a method that's expecting UnitHandles
 
Top Bottom