Skip to content

Instantly share code, notes, and snippets.

@St3eT
Created June 3, 2024 12:11
Show Gist options
  • Save St3eT/822c291c952bc3393f22bb67bd3ff90a to your computer and use it in GitHub Desktop.
Save St3eT/822c291c952bc3393f22bb67bd3ff90a to your computer and use it in GitHub Desktop.
void __fastcall CNPC::Despawn(CNPC *this)
{
wchar_t *v1; // rax
int v2; // [rsp+40h] [rbp-48h]
int v3; // [rsp+44h] [rbp-44h]
unsigned int m_nId; // [rsp+58h] [rbp-30h]
CNPC *ObjectW; // [rsp+68h] [rbp-20h]
v2 = *(_DWORD *)(*((_QWORD *)NtCurrentTeb()->Reserved1[11] + tls_index) + 824736i64);
v3 = GuardHelper::_callStackDepth[v2];
GuardHelper::_callStackDepth[v2] = v3 + 1;
GuardHelper::_pszCallStack[v2][v3] = _FUNC_NAME___1259;
GuardHelper::_dwCallStackStartTick[v2][v3] = GetTickCount();
if ( _InterlockedCompareExchange(&this->m_nNpcDespawnCount, 1, 0) )
{
m_nId = this->m_nId;
v1 = this->GetName(this);
CLog::Add(&Log, LOG_ERROR, (wchar_t *)L"[%s][%d] Invalid Despawn() (npc[%s][%d]) called count[%d] ", L"NPC.cpp", 9224, v1, m_nId, 1);
--GuardHelper::_callStackDepth[v2];
}
else if ( this->mDeleteCount )
{
--GuardHelper::_callStackDepth[v2];
}
else
{
ObjectW = CNPC::GetObjectW(this->m_data->m_BossID);
if ( ObjectW )
{
CNPC::PartyDied(ObjectW, this);
}
else if ( this->m_bBoss )
{
CNPC::PartyDied(this, this);
}
NPCServer::Send(&g_ns, "cdd", 46i64, this->m_nId, this->m_data->index);
--GuardHelper::_callStackDepth[v2];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment