mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-12-25 15:14:51 +01:00
Game can be executed and quit without crashes
mostly checks before calling AddReference()/RemReference()
This commit is contained in:
parent
d723153576
commit
882c7773b5
|
@ -615,7 +615,7 @@ CAnimObject::CAnimObject(void)
|
|||
/* Destructor. */
|
||||
CAnimObject::~CAnimObject(void)
|
||||
{
|
||||
ao_AnimData->RemReference();
|
||||
if(ao_AnimData != NULL) ao_AnimData->RemReference();
|
||||
}
|
||||
|
||||
// copy from another object of same class
|
||||
|
@ -818,9 +818,9 @@ BOOL CAnimObject::IsUpToDate(const CUpdateable &ud) const
|
|||
void CAnimObject::SetData(CAnimData *pAD)
|
||||
{
|
||||
// mark new data as referenced once more
|
||||
pAD->AddReference();
|
||||
if(pAD != NULL) pAD->AddReference();
|
||||
// mark old data as referenced once less
|
||||
ao_AnimData->RemReference();
|
||||
if(ao_AnimData != NULL) ao_AnimData->RemReference();
|
||||
// remember new data
|
||||
ao_AnimData = pAD;
|
||||
if( pAD != NULL) StartAnim( 0);
|
||||
|
|
|
@ -186,7 +186,7 @@ CEntity::~CEntity(void)
|
|||
}
|
||||
// clear entity type
|
||||
en_RenderType = RT_NONE;
|
||||
en_pecClass->RemReference();
|
||||
if(en_pecClass != NULL) en_pecClass->RemReference();
|
||||
en_pecClass = NULL;
|
||||
|
||||
en_fSpatialClassificationRadius = -1.0f;
|
||||
|
|
|
@ -670,20 +670,20 @@ BOOL ENGINE_API IsDerivedFromClass(CEntity *pen, const char *pstrClassName);
|
|||
|
||||
// all standard smart pointer functions are here as inlines
|
||||
inline CEntityPointer::CEntityPointer(void) : ep_pen(NULL) {};
|
||||
inline CEntityPointer::~CEntityPointer(void) { ep_pen->RemReference(); };
|
||||
inline CEntityPointer::~CEntityPointer(void) { if(ep_pen != NULL) ep_pen->RemReference(); };
|
||||
inline CEntityPointer::CEntityPointer(const CEntityPointer &penOther) : ep_pen(penOther.ep_pen) {
|
||||
ep_pen->AddReference(); };
|
||||
if(ep_pen != NULL) ep_pen->AddReference(); };
|
||||
inline CEntityPointer::CEntityPointer(CEntity *pen) : ep_pen(pen) {
|
||||
ep_pen->AddReference(); };
|
||||
if(ep_pen != NULL) ep_pen->AddReference(); };
|
||||
inline const CEntityPointer &CEntityPointer::operator=(CEntity *pen) {
|
||||
pen->AddReference(); // must first add, then remove!
|
||||
ep_pen->RemReference();
|
||||
if(pen != NULL) pen->AddReference(); // must first add, then remove!
|
||||
if(ep_pen != NULL) ep_pen->RemReference();
|
||||
ep_pen = pen;
|
||||
return *this;
|
||||
}
|
||||
inline const CEntityPointer &CEntityPointer::operator=(const CEntityPointer &penOther) {
|
||||
penOther.ep_pen->AddReference(); // must first add, then remove!
|
||||
ep_pen->RemReference();
|
||||
if(penOther.ep_pen != NULL) penOther.ep_pen->AddReference(); // must first add, then remove!
|
||||
if(ep_pen != NULL) ep_pen->RemReference();
|
||||
ep_pen = penOther.ep_pen;
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -807,7 +807,7 @@ extern BOOL ProbeMode( CTimerValue tvLast)
|
|||
extern void UncacheShadows(void)
|
||||
{
|
||||
// mute all sounds
|
||||
_pSound->Mute();
|
||||
if(_pSound != NULL) _pSound->Mute();
|
||||
// prepare new saturation factors for shadowmaps
|
||||
gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f);
|
||||
shd_fSaturation = ClampDn( shd_fSaturation, 0.0f);
|
||||
|
|
|
@ -240,9 +240,9 @@ void CSoundObject::Play_internal( CSoundData *pCsdLink, SLONG slFlags)
|
|||
Stop_internal();
|
||||
|
||||
// mark new data as referenced once more
|
||||
pCsdLink->AddReference();
|
||||
if(pCsdLink != NULL) pCsdLink->AddReference();
|
||||
// mark old data as referenced once less
|
||||
so_pCsdLink->RemReference();
|
||||
if(so_pCsdLink != NULL) so_pCsdLink->RemReference();
|
||||
|
||||
// store init SoundData
|
||||
so_pCsdLink = pCsdLink;
|
||||
|
|
Loading…
Reference in New Issue
Block a user