feat(object): implement CGObject_C::AddWorldObject
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run

This commit is contained in:
fallenoak 2026-02-09 15:40:23 -06:00
parent 9f3160b1d2
commit b4751725a6
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 88 additions and 1 deletions

View File

@ -1,4 +1,5 @@
#include "object/client/CGObject_C.hpp" #include "object/client/CGObject_C.hpp"
#include "model/Model2.hpp"
#include "object/client/ObjMgr.hpp" #include "object/client/ObjMgr.hpp"
#include "world/World.hpp" #include "world/World.hpp"
@ -6,6 +7,7 @@ CGObject_C::CGObject_C(uint32_t time, CClientObjCreate& objCreate) {
// TODO // TODO
this->m_model = nullptr; this->m_model = nullptr;
this->m_worldObject = 0;
// TODO // TODO
@ -28,7 +30,52 @@ CGObject_C::~CGObject_C() {
} }
void CGObject_C::AddWorldObject() { void CGObject_C::AddWorldObject() {
// TODO if (!this->m_model) {
const char* fileName;
if (this->GetModelFileName(fileName)) {
auto model = CWorld::GetM2Scene()->CreateModel(fileName, 0);
this->SetModel(model);
model->Release();
}
}
if (!this->m_model) {
return;
}
if (ClntObjMgrGetPlayerType() != PLAYER_NORMAL) {
return;
}
if (this->m_worldObject) {
// TODO SysMsgPrintf(1, 2, "OBJECTALREADYACTIVE|0x%016I64X", this->GetGUID());
return;
}
uint32_t objFlags = 0x0;
if (this->IsA(TYPE_GAMEOBJECT)) {
objFlags |= 0x8 | 0x2 | 0x1;
} else if (this->IsA(TYPE_DYNAMICOBJECT)) {
objFlags |= 0x8 | 0x2;
} else if (this->IsA(TYPE_CORPSE)) {
// TODO
} else if (this->IsA(TYPE_UNIT)) {
// TODO
objFlags |= 0x10;
if (this->IsA(TYPE_PLAYER)) {
objFlags |= 0x20;
}
}
this->m_worldObject = CWorld::AddObject(this->GetObjectModel(), nullptr, nullptr, this->GetGUID(), 0, objFlags);
if (!this->m_inReenable && this->m_postInited) {
this->UpdateWorldObject(false);
}
} }
int32_t CGObject_C::CanBeTargetted() { int32_t CGObject_C::CanBeTargetted() {
@ -48,6 +95,14 @@ void CGObject_C::Disable() {
this->m_disableTimeMs = CWorld::GetCurTimeMs(); this->m_disableTimeMs = CWorld::GetCurTimeMs();
} }
int32_t CGObject_C::GetModelFileName(const char*& name) {
return false;
}
CM2Model* CGObject_C::GetObjectModel() {
return this->m_model;
}
int32_t CGObject_C::IsInReenable() { int32_t CGObject_C::IsInReenable() {
return this->m_inReenable; return this->m_inReenable;
} }
@ -90,6 +145,25 @@ void CGObject_C::SetDisablePending(int32_t pending) {
} }
} }
void CGObject_C::SetModel(CM2Model* model) {
// No change
if (this->m_model == model) {
return;
}
if (model) {
model->AddRef();
}
this->m_model = model;
this->SetModelFinish(model);
}
void CGObject_C::SetModelFinish(CM2Model* model) {
// TODO
}
void CGObject_C::SetObjectLocked(int32_t locked) { void CGObject_C::SetObjectLocked(int32_t locked) {
if (locked) { if (locked) {
if (this->m_lockCount != 0xFFFF) { if (this->m_lockCount != 0xFFFF) {
@ -147,3 +221,7 @@ void CGObject_C::SetTypeID(OBJECT_TYPE_ID typeID) {
break; break;
} }
} }
void CGObject_C::UpdateWorldObject(int32_t a2) {
// TODO
}

View File

@ -5,6 +5,7 @@
#include "object/client/CClientObjCreate.hpp" #include "object/client/CClientObjCreate.hpp"
#include "object/client/CGObject.hpp" #include "object/client/CGObject.hpp"
#include "util/GUID.hpp" #include "util/GUID.hpp"
#include "world/Types.hpp"
#include <storm/Hash.hpp> #include <storm/Hash.hpp>
#include <storm/List.hpp> #include <storm/List.hpp>
@ -18,6 +19,7 @@ class CGObject_C : public CGObject, public TSHashObject<CGObject_C, CHashKeyGUID
// TODO // TODO
CM2Model* m_model; CM2Model* m_model;
// TODO // TODO
HWORLDOBJECT m_worldObject;
uint32_t m_lockCount : 16; uint32_t m_lockCount : 16;
uint32_t m_disabled : 1; uint32_t m_disabled : 1;
uint32_t m_inReenable : 1; uint32_t m_inReenable : 1;
@ -32,9 +34,14 @@ class CGObject_C : public CGObject, public TSHashObject<CGObject_C, CHashKeyGUID
void Reenable(); void Reenable();
void PostReenable(); void PostReenable();
virtual void HandleOutOfRange(OUT_OF_RANGE_TYPE type) {}; virtual void HandleOutOfRange(OUT_OF_RANGE_TYPE type) {};
virtual void UpdateWorldObject(int32_t a2);
// TODO
virtual int32_t GetModelFileName(const char*& name);
// TODO // TODO
virtual int32_t CanHighlight(); virtual int32_t CanHighlight();
virtual int32_t CanBeTargetted(); virtual int32_t CanBeTargetted();
// TODO
virtual CM2Model* GetObjectModel();
// Public member functions // Public member functions
CGObject_C() = default; CGObject_C() = default;
@ -45,6 +52,8 @@ class CGObject_C : public CGObject, public TSHashObject<CGObject_C, CHashKeyGUID
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4); void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
void SetBlock(uint32_t block, uint32_t value); void SetBlock(uint32_t block, uint32_t value);
void SetDisablePending(int32_t pending); void SetDisablePending(int32_t pending);
void SetModel(CM2Model* model);
void SetModelFinish(CM2Model* model);
void SetObjectLocked(int32_t locked); void SetObjectLocked(int32_t locked);
void SetStorage(uint32_t* storage, uint32_t* saved); void SetStorage(uint32_t* storage, uint32_t* saved);
void SetTypeID(OBJECT_TYPE_ID typeID); void SetTypeID(OBJECT_TYPE_ID typeID);