mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 00:32:45 +03:00
Compare commits
4 Commits
6262f1fa52
...
17e8b5c5e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17e8b5c5e7 | ||
|
|
5a8fb5e2d3 | ||
|
|
305849b164 | ||
|
|
012e97f410 |
@ -4,6 +4,10 @@ CGContainer_C::CGContainer_C(uint32_t time, CClientObjCreate& objCreate) : CGIte
|
||||
// TODO
|
||||
}
|
||||
|
||||
CGContainer_C::~CGContainer_C() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGContainer_C::SetStorage(uint32_t* storage, uint32_t* saved) {
|
||||
this->CGItem_C::SetStorage(storage, saved);
|
||||
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
|
||||
class CGContainer_C : public CGItem_C, public CGContainer {
|
||||
public:
|
||||
// Virtual public member functions
|
||||
virtual ~CGContainer_C();
|
||||
|
||||
// Public member functions
|
||||
CGContainer_C(uint32_t time, CClientObjCreate& objCreate);
|
||||
void SetStorage(uint32_t* storage, uint32_t* saved);
|
||||
|
||||
@ -4,6 +4,10 @@ CGCorpse_C::CGCorpse_C(uint32_t time, CClientObjCreate& objCreate) : CGObject_C(
|
||||
// TODO
|
||||
}
|
||||
|
||||
CGCorpse_C::~CGCorpse_C() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGCorpse_C::SetStorage(uint32_t* storage, uint32_t* saved) {
|
||||
this->CGObject_C::SetStorage(storage, saved);
|
||||
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
|
||||
class CGCorpse_C : public CGObject_C, public CGCorpse {
|
||||
public:
|
||||
// Virtual public member functions
|
||||
virtual ~CGCorpse_C();
|
||||
|
||||
// Public member functions
|
||||
CGCorpse_C(uint32_t time, CClientObjCreate& objCreate);
|
||||
void SetStorage(uint32_t* storage, uint32_t* saved);
|
||||
|
||||
@ -4,6 +4,10 @@ CGDynamicObject_C::CGDynamicObject_C(uint32_t time, CClientObjCreate& objCreate)
|
||||
// TODO
|
||||
}
|
||||
|
||||
CGDynamicObject_C::~CGDynamicObject_C() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGDynamicObject_C::SetStorage(uint32_t* storage, uint32_t* saved) {
|
||||
this->CGObject_C::SetStorage(storage, saved);
|
||||
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
|
||||
class CGDynamicObject_C : public CGObject_C, public CGDynamicObject {
|
||||
public:
|
||||
// Virtual public member functions
|
||||
virtual ~CGDynamicObject_C();
|
||||
|
||||
// Public member functions
|
||||
CGDynamicObject_C(uint32_t time, CClientObjCreate& objCreate);
|
||||
void SetStorage(uint32_t* storage, uint32_t* saved);
|
||||
|
||||
@ -4,6 +4,10 @@ CGGameObject_C::CGGameObject_C(uint32_t time, CClientObjCreate& objCreate) : CGO
|
||||
// TODO
|
||||
}
|
||||
|
||||
CGGameObject_C::~CGGameObject_C() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGGameObject_C::SetStorage(uint32_t* storage, uint32_t* saved) {
|
||||
this->CGObject_C::SetStorage(storage, saved);
|
||||
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
|
||||
class CGGameObject_C : public CGObject_C, public CGGameObject {
|
||||
public:
|
||||
// Virtual public member functions
|
||||
virtual ~CGGameObject_C();
|
||||
|
||||
// Public member functions
|
||||
CGGameObject_C(uint32_t time, CClientObjCreate& objCreate);
|
||||
void SetStorage(uint32_t* storage, uint32_t* saved);
|
||||
|
||||
@ -4,6 +4,10 @@ CGItem_C::CGItem_C(uint32_t time, CClientObjCreate& objCreate) : CGObject_C(time
|
||||
// TODO
|
||||
}
|
||||
|
||||
CGItem_C::~CGItem_C() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGItem_C::SetStorage(uint32_t* storage, uint32_t* saved) {
|
||||
this->CGObject_C::SetStorage(storage, saved);
|
||||
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
|
||||
class CGItem_C : public CGObject_C, public CGItem {
|
||||
public:
|
||||
// Virtual public member functions
|
||||
virtual ~CGItem_C();
|
||||
|
||||
// Public member functions
|
||||
CGItem_C(uint32_t time, CClientObjCreate& objCreate);
|
||||
void SetStorage(uint32_t* storage, uint32_t* saved);
|
||||
|
||||
@ -19,6 +19,10 @@ CGObject_C::CGObject_C(uint32_t time, CClientObjCreate& objCreate) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
CGObject_C::~CGObject_C() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGObject_C::AddWorldObject() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ class CGObject_C : public CGObject, public TSHashObject<CGObject_C, CHashKeyGUID
|
||||
// TODO
|
||||
|
||||
// Virtual public member functions
|
||||
// TODO
|
||||
virtual ~CGObject_C();
|
||||
virtual void Disable();
|
||||
// TODO
|
||||
virtual void HandleOutOfRange(OUT_OF_RANGE_TYPE type) {};
|
||||
|
||||
@ -7,6 +7,10 @@ CGPlayer_C::CGPlayer_C(uint32_t time, CClientObjCreate& objCreate) : CGUnit_C(ti
|
||||
// TODO
|
||||
}
|
||||
|
||||
CGPlayer_C::~CGPlayer_C() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGPlayer_C::SetStorage(uint32_t* storage, uint32_t* saved) {
|
||||
this->CGUnit_C::SetStorage(storage, saved);
|
||||
|
||||
|
||||
@ -10,6 +10,9 @@ class CreatureModelDataRec;
|
||||
|
||||
class CGPlayer_C : public CGUnit_C, public CGPlayer {
|
||||
public:
|
||||
// Virtual public member functions
|
||||
virtual ~CGPlayer_C();
|
||||
|
||||
// Public member functions
|
||||
CGPlayer_C(uint32_t time, CClientObjCreate& objCreate);
|
||||
void SetStorage(uint32_t* storage, uint32_t* saved);
|
||||
|
||||
@ -93,6 +93,10 @@ CGUnit_C::CGUnit_C(uint32_t time, CClientObjCreate& objCreate) : CGObject_C(time
|
||||
// TODO
|
||||
}
|
||||
|
||||
CGUnit_C::~CGUnit_C() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGUnit_C::SetStorage(uint32_t* storage, uint32_t* saved) {
|
||||
this->CGObject_C::SetStorage(storage, saved);
|
||||
|
||||
|
||||
@ -15,6 +15,9 @@ class CGUnit_C : public CGObject_C, public CGUnit {
|
||||
static const char* GetDisplayClassNameFromRecord(const ChrClassesRec* classRec, UNIT_SEX sex, UNIT_SEX* displaySex);
|
||||
static const char* GetDisplayRaceNameFromRecord(const ChrRacesRec* raceRec, UNIT_SEX sex, UNIT_SEX* displaySex);
|
||||
|
||||
// Virtual public member functions
|
||||
virtual ~CGUnit_C();
|
||||
|
||||
// Public member functions
|
||||
CGUnit_C(uint32_t time, CClientObjCreate& objCreate);
|
||||
void SetStorage(uint32_t* storage, uint32_t* saved);
|
||||
|
||||
@ -384,6 +384,8 @@ int32_t ObjectUpdateHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataS
|
||||
uint32_t updateCount;
|
||||
msg->Get(updateCount);
|
||||
|
||||
// If first update type is out of range, handle it before continuing with normal processing
|
||||
|
||||
auto startPos = msg->Tell();
|
||||
|
||||
uint8_t firstUpdateType;
|
||||
@ -398,6 +400,8 @@ int32_t ObjectUpdateHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataS
|
||||
msg->Seek(startPos);
|
||||
}
|
||||
|
||||
// Process all updates in two passes (creates, updates and disables objects as appropriate)
|
||||
|
||||
int32_t result = 0;
|
||||
|
||||
if (ObjectUpdateFirstPass(msg, time, updateIdx, updateCount)) {
|
||||
@ -405,7 +409,11 @@ int32_t ObjectUpdateHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataS
|
||||
result = ObjectUpdateSecondPass(msg, time, updateCount);
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Garbage collect objects disabled more than 2 minutes ago (catch all)
|
||||
|
||||
for (int32_t typeID = ID_OBJECT; typeID < NUM_CLIENT_OBJECT_TYPES; typeID++) {
|
||||
GarbageCollect(static_cast<OBJECT_TYPE_ID>(typeID), 120000);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ CGObject_C* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, WOWGUID guid) {
|
||||
return static_cast<CGObject_C*>(STORM_ALLOC(sizeof(CGPlayer_C) + CGPlayer::GetDataSize() + CGPlayer::GetDataSizeSaved()));
|
||||
}
|
||||
|
||||
// TODO GarbageCollect(typeID, 10000);
|
||||
GarbageCollect(typeID, 10000);
|
||||
|
||||
uint32_t memHandle;
|
||||
void* mem;
|
||||
@ -91,6 +91,36 @@ CGObject_C* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, WOWGUID guid) {
|
||||
return object;
|
||||
}
|
||||
|
||||
void ClntObjMgrFreeObject(CGObject_C* object) {
|
||||
auto playerGUID = ClntObjMgrGetActivePlayer();
|
||||
auto isActivePlayer = object->m_obj->m_guid == playerGUID;
|
||||
|
||||
switch (object->m_obj->m_type) {
|
||||
case TYPE_OBJECT:
|
||||
case HIER_TYPE_ITEM:
|
||||
case HIER_TYPE_CONTAINER:
|
||||
case HIER_TYPE_UNIT:
|
||||
case HIER_TYPE_PLAYER:
|
||||
case HIER_TYPE_GAMEOBJECT:
|
||||
case HIER_TYPE_DYNAMICOBJECT:
|
||||
case HIER_TYPE_CORPSE: {
|
||||
object->~CGObject_C();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isActivePlayer) {
|
||||
STORM_FREE(object);
|
||||
} else {
|
||||
ObjectFree(s_objHeapId[object->m_typeID], object->m_memHandle);
|
||||
}
|
||||
}
|
||||
|
||||
WOWGUID ClntObjMgrGetActivePlayer() {
|
||||
if (!s_curMgr) {
|
||||
return 0;
|
||||
|
||||
@ -10,6 +10,8 @@ CGObject_C* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, WOWGUID guid);
|
||||
|
||||
WOWGUID ClntObjMgrGetActivePlayer();
|
||||
|
||||
void ClntObjMgrFreeObject(CGObject_C* object);
|
||||
|
||||
ClntObjMgr* ClntObjMgrGetCurrent();
|
||||
|
||||
uint32_t ClntObjMgrGetMapID();
|
||||
|
||||
@ -9,11 +9,35 @@
|
||||
#include "object/client/CGPlayer_C.hpp"
|
||||
#include "object/client/CGUnit_C.hpp"
|
||||
#include "object/client/ObjMgr.hpp"
|
||||
#include <common/Time.hpp>
|
||||
|
||||
CGObject_C* FindActiveObject(WOWGUID guid) {
|
||||
return ClntObjMgrGetCurrent()->m_objects.Ptr(guid, CHashKeyGUID(guid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an object type and collection age, free the object at the head of that type's FIFO queue
|
||||
* if it was disabled longer ago than the collection age. Only frees at most one object per call.
|
||||
*/
|
||||
void GarbageCollect(OBJECT_TYPE_ID typeID, uint32_t collectAgeMs) {
|
||||
auto object = ClntObjMgrGetCurrent()->m_lazyCleanupFifo[typeID - 1].Head();
|
||||
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t disableAgeMs = OsGetAsyncTimeMsPrecise() - object->m_disableTimeMs;
|
||||
|
||||
if (disableAgeMs < collectAgeMs) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClntObjMgrGetCurrent()->m_lazyCleanupObjects.Unlink(object);
|
||||
object->m_link.Unlink();
|
||||
|
||||
ClntObjMgrFreeObject(object);
|
||||
}
|
||||
|
||||
CGObject_C* GetUpdateObject(WOWGUID guid, int32_t* reenable) {
|
||||
*reenable = false;
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@ class CGObject_C;
|
||||
|
||||
CGObject_C* FindActiveObject(WOWGUID guid);
|
||||
|
||||
void GarbageCollect(OBJECT_TYPE_ID typeID, uint32_t collectAgeMs);
|
||||
|
||||
CGObject_C* GetUpdateObject(WOWGUID guid, int32_t* reenable);
|
||||
|
||||
int32_t HandleObjectOutOfRangePass1(CGObject_C* object, OUT_OF_RANGE_TYPE type);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user