From e3320fd439555a94b6cd2dd8113f7ebf13e67a96 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Tue, 6 Aug 2024 19:06:50 +0800 Subject: [PATCH] [saco] Implement/match `CEntity::Add()` --- saco/game/entity.cpp | 36 ++++++++++++++++++++++++++++++++++++ saco/game/entity.h | 1 + 2 files changed, 37 insertions(+) diff --git a/saco/game/entity.cpp b/saco/game/entity.cpp index d821a3a..aa86d0b 100644 --- a/saco/game/entity.cpp +++ b/saco/game/entity.cpp @@ -248,6 +248,42 @@ float CEntity::GetDistanceFromPoint(float X, float Y, float Z) //----------------------------------------------------------- +void CEntity::Add() +{ + // Check for CPlaceable messup + if(!m_pEntity || m_pEntity->vtable == 0x863C40) + { +#ifdef _DEBUG + OutputDebugString("CEntity::Add - m_pEntity == NULL or CPlaceable"); +#endif + return; + } + + if(!m_pEntity->dwUnkModelRel) { + // Make sure the move/turn speed is reset + + VECTOR vec = {0.0f,0.0f,0.0f}; + + SetMoveSpeedVector(vec); + SetTurnSpeedVector(vec); + + WorldAddEntity((PDWORD)m_pEntity); + + MATRIX4X4 mat; + GetMatrix(&mat); + TeleportTo(mat.pos.X,mat.pos.Y,mat.pos.Z); + +#ifdef _DEBUG + if (!IsAdded()) + { + OutputDebugString("CEntity::Add failed..."); + } +#endif + } +} + +//----------------------------------------------------------- + BOOL CEntity::IsAdded() { // Check for CPlaceable messup diff --git a/saco/game/entity.h b/saco/game/entity.h index ae85b37..3dbf3c7 100644 --- a/saco/game/entity.h +++ b/saco/game/entity.h @@ -31,6 +31,7 @@ public: BOOL FUNC_1009FDE0(); + virtual void Add(); BOOL IsAdded(); VECTOR field_4[5];