Compare commits

...

8 Commits

Author SHA1 Message Date
Tristan 'Natrist' Cormier
2a8c79915d
Merge 4a102c6ace into aa62781560 2026-01-22 09:30:36 +00:00
fallenoak
aa62781560
feat(world): populate CMapBaseObj
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
2026-01-21 16:06:21 -06:00
fallenoak
536c94a7b7
feat(world): add HWORLDOBJECT
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
2026-01-20 20:56:21 -06:00
fallenoak
88ea9325be
feat(world): stub core map entity classes 2026-01-20 20:56:04 -06:00
fallenoak
8cf0abb1b1
feat(object): manage post init flag across base object classes
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
2026-01-19 20:04:17 -06:00
fallenoak
3d02539112
feat(object): add post update handling to ObjectUpdateSecondPass
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
2026-01-19 16:11:09 -06:00
fallenoak
1de58d83e5
feat(object): finish reenabling objects in object update handler 2026-01-19 11:23:18 -06:00
Tristan Cormier
4a102c6ace feat(glue): implement Script_ContestAccepted 2026-01-11 17:01:24 -05:00
29 changed files with 403 additions and 8 deletions

View File

@ -64,6 +64,7 @@ float CGlueMgr::m_aspect;
bool CGlueMgr::m_authenticated;
const CharacterSelectionDisplay* CGlueMgr::m_characterInfo;
int32_t CGlueMgr::m_clientKickReason;
int32_t CGlueMgr::m_contestAccepted = 1; // TODO
char CGlueMgr::m_currentScreen[64];
EffectDeath* CGlueMgr::m_deathEffect;
int32_t CGlueMgr::m_disconnectPending;

View File

@ -41,6 +41,7 @@ class CGlueMgr {
static bool m_authenticated;
static const CharacterSelectionDisplay* m_characterInfo;
static int32_t m_clientKickReason;
static int32_t m_contestAccepted;
static char m_currentScreen[];
static EffectDeath* m_deathEffect;
static int32_t m_disconnectPending;

View File

@ -222,7 +222,14 @@ int32_t Script_ShowContestNotice(lua_State* L) {
}
int32_t Script_ContestAccepted(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
if (CGlueMgr::m_contestAccepted) {
lua_pushnumber(L, 1.0);
}
else {
lua_pushnil(L);
}
return 1;
}
int32_t Script_AcceptContest(lua_State* L) {

View File

@ -8,6 +8,14 @@ CGCorpse_C::~CGCorpse_C() {
// TODO
}
void CGCorpse_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
// TODO
this->CGObject_C::PostInit(time, init, a4);
// TODO
}
void CGCorpse_C::SetStorage(uint32_t* storage, uint32_t* saved) {
this->CGObject_C::SetStorage(storage, saved);

View File

@ -12,6 +12,7 @@ class CGCorpse_C : public CGObject_C, public CGCorpse {
// Public member functions
CGCorpse_C(uint32_t time, CClientObjCreate& objCreate);
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
void SetStorage(uint32_t* storage, uint32_t* saved);
};

View File

@ -8,6 +8,14 @@ CGDynamicObject_C::~CGDynamicObject_C() {
// TODO
}
void CGDynamicObject_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
// TODO
this->CGObject_C::PostInit(time, init, a4);
// TODO
}
void CGDynamicObject_C::SetStorage(uint32_t* storage, uint32_t* saved) {
this->CGObject_C::SetStorage(storage, saved);

View File

@ -12,6 +12,7 @@ class CGDynamicObject_C : public CGObject_C, public CGDynamicObject {
// Public member functions
CGDynamicObject_C(uint32_t time, CClientObjCreate& objCreate);
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
void SetStorage(uint32_t* storage, uint32_t* saved);
};

View File

@ -8,6 +8,14 @@ CGGameObject_C::~CGGameObject_C() {
// TODO
}
void CGGameObject_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
// TODO
this->CGObject_C::PostInit(time, init, a4);
// TODO
}
void CGGameObject_C::SetStorage(uint32_t* storage, uint32_t* saved) {
this->CGObject_C::SetStorage(storage, saved);

View File

@ -12,6 +12,7 @@ class CGGameObject_C : public CGObject_C, public CGGameObject {
// Public member functions
CGGameObject_C(uint32_t time, CClientObjCreate& objCreate);
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
void SetStorage(uint32_t* storage, uint32_t* saved);
};

View File

@ -8,6 +8,12 @@ CGItem_C::~CGItem_C() {
// TODO
}
void CGItem_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
this->CGObject_C::PostInit(time, init, a4);
// TODO
}
void CGItem_C::SetStorage(uint32_t* storage, uint32_t* saved) {
this->CGObject_C::SetStorage(storage, saved);

View File

@ -12,6 +12,7 @@ class CGItem_C : public CGObject_C, public CGItem {
// Public member functions
CGItem_C(uint32_t time, CClientObjCreate& objCreate);
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
void SetStorage(uint32_t* storage, uint32_t* saved);
};

View File

@ -44,6 +44,14 @@ int32_t CGObject_C::IsObjectLocked() {
return this->m_lockCount != 0;
}
void CGObject_C::PostReenable() {
// TODO
this->m_inReenable = false;
// TODO
}
void CGObject_C::Reenable() {
this->m_disabled = false;
this->m_inReenable = true;
@ -51,6 +59,12 @@ void CGObject_C::Reenable() {
// TODO
}
void CGObject_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
this->m_postInited = true;
// TODO
}
void CGObject_C::SetBlock(uint32_t block, uint32_t value) {
auto storage = reinterpret_cast<uint32_t*>(this->m_obj);
storage[block] = value;

View File

@ -25,7 +25,8 @@ class CGObject_C : public CGObject, public TSHashObject<CGObject_C, CHashKeyGUID
// Virtual public member functions
virtual ~CGObject_C();
virtual void Disable();
// TODO
void Reenable();
void PostReenable();
virtual void HandleOutOfRange(OUT_OF_RANGE_TYPE type) {};
// TODO
@ -35,7 +36,7 @@ class CGObject_C : public CGObject, public TSHashObject<CGObject_C, CHashKeyGUID
void AddWorldObject();
int32_t IsInReenable();
int32_t IsObjectLocked();
void Reenable();
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
void SetBlock(uint32_t block, uint32_t value);
void SetDisablePending(int32_t pending);
void SetObjectLocked(int32_t locked);

View File

@ -11,6 +11,14 @@ CGPlayer_C::~CGPlayer_C() {
// TODO
}
void CGPlayer_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
// TODO
this->CGUnit_C::PostInit(time, init, a4);
// TODO
}
void CGPlayer_C::SetStorage(uint32_t* storage, uint32_t* saved) {
this->CGUnit_C::SetStorage(storage, saved);

View File

@ -15,6 +15,7 @@ class CGPlayer_C : public CGUnit_C, public CGPlayer {
// Public member functions
CGPlayer_C(uint32_t time, CClientObjCreate& objCreate);
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
void SetStorage(uint32_t* storage, uint32_t* saved);
};

View File

@ -1,6 +1,8 @@
#include "object/client/CGUnit_C.hpp"
#include "db/Db.hpp"
WOWGUID CGUnit_C::s_activeMover;
const char* CGUnit_C::GetDisplayClassNameFromRecord(const ChrClassesRec* classRec, UNIT_SEX sex, UNIT_SEX* displaySex) {
if (displaySex) {
*displaySex = sex;
@ -97,6 +99,18 @@ CGUnit_C::~CGUnit_C() {
// TODO
}
void CGUnit_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
// TODO
this->CGObject_C::PostInit(time, init, a4);
// TODO
}
void CGUnit_C::PostMovementUpdate(const CClientMoveUpdate& move, int32_t activeMover) {
// TODO
}
void CGUnit_C::SetStorage(uint32_t* storage, uint32_t* saved) {
this->CGObject_C::SetStorage(storage, saved);

View File

@ -5,12 +5,16 @@
#include "object/client/CGObject_C.hpp"
#include "object/client/CGUnit.hpp"
#include "object/Types.hpp"
#include "util/GUID.hpp"
class ChrClassesRec;
class ChrRacesRec;
class CGUnit_C : public CGObject_C, public CGUnit {
public:
// Public static variables
static WOWGUID s_activeMover;
// Public static functions
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);
@ -20,6 +24,8 @@ class CGUnit_C : public CGObject_C, public CGUnit {
// Public member functions
CGUnit_C(uint32_t time, CClientObjCreate& objCreate);
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
void PostMovementUpdate(const CClientMoveUpdate& move, int32_t activeMover);
void SetStorage(uint32_t* storage, uint32_t* saved);
};

View File

@ -28,11 +28,124 @@ enum UPDATE_TYPE {
UPDATE_IN_RANGE = 5,
};
int32_t SkipPartialObjectUpdate(CDataStore* msg) {
// TODO
void SkipSetOfObjects(CDataStore* msg) {
uint32_t count;
msg->Get(count);
for (int32_t i = 0; i < count; i++) {
SmartGUID guid;
*msg >> guid;
}
}
int32_t PostInitObject(CDataStore* msg, uint32_t time, bool a3) {
SmartGUID guid;
*msg >> guid;
uint8_t _typeID;
msg->Get(_typeID);
auto typeID = static_cast<OBJECT_TYPE_ID>(_typeID);
if (guid == 0) {
return 0;
}
auto object = FindActiveObject(guid);
if (!object) {
return 0;
}
CClientObjCreate init;
if (!init.Get(msg)) {
return 0;
}
if (object->m_inReenable && object->m_obj->m_type & TYPE_UNIT) {
// TODO
}
if (object->m_postInited) {
return CallMirrorHandlers(msg, true, guid);
}
switch (typeID) {
case ID_OBJECT: {
object->PostInit(time, init, a3);
break;
}
case ID_ITEM:
case ID_CONTAINER: {
static_cast<CGItem_C*>(object)->PostInit(time, init, a3);
break;
}
case ID_UNIT: {
static_cast<CGUnit_C*>(object)->PostInit(time, init, a3);
break;
}
case ID_PLAYER: {
static_cast<CGPlayer_C*>(object)->PostInit(time, init, a3);
break;
}
case ID_GAMEOBJECT: {
static_cast<CGGameObject_C*>(object)->PostInit(time, init, a3);
break;
}
case ID_DYNAMICOBJECT: {
static_cast<CGDynamicObject_C*>(object)->PostInit(time, init, a3);
break;
}
case ID_CORPSE: {
static_cast<CGCorpse_C*>(object)->PostInit(time, init, a3);
break;
}
default: {
STORM_APP_FATAL("PostInitObject: unknown object type %d", typeID);
}
}
return SkipPartialObjectUpdate(msg);
}
void PostMovementUpdate(CDataStore* msg) {
SmartGUID guid;
*msg >> guid;
CClientMoveUpdate move;
*msg >> move;
if (guid == CGUnit_C::s_activeMover) {
return;
}
int32_t reenable;
auto unit = static_cast<CGUnit_C*>(GetUpdateObject(guid, &reenable));
if (!unit) {
return;
}
unit->PostMovementUpdate(move, unit->m_obj->m_guid == CGUnit_C::s_activeMover);
if (reenable) {
unit->Reenable();
}
}
void UpdateOutOfRangeObjects(CDataStore* msg) {
uint32_t count;
msg->Get(count);
@ -322,10 +435,59 @@ int32_t ObjectUpdateFirstPass(CDataStore* msg, uint32_t time, uint32_t updateIdx
}
int32_t ObjectUpdateSecondPass(CDataStore* msg, uint32_t time, uint32_t updateCount) {
// TODO
// Handle post updates
for (int32_t i = 0; i < updateCount; i++) {
uint8_t updateType;
msg->Get(updateType);
switch (updateType) {
case UPDATE_PARTIAL: {
if (!CallMirrorHandlers(msg, false, 0)) {
return 0;
}
break;
}
case UPDATE_MOVEMENT: {
PostMovementUpdate(msg);
break;
}
case UPDATE_FULL:
case UPDATE_3: {
if (!PostInitObject(msg, time, updateType == UPDATE_3)) {
return 0;
}
break;
}
case UPDATE_IN_RANGE:
case UPDATE_OUT_OF_RANGE: {
SkipSetOfObjects(msg);
break;
}
default: {
break;
}
}
}
// Finish reenabling objects
while (auto reenabledObject = ClntObjMgrGetCurrent()->m_reenabledObjects.Head()) {
ClntObjMgrGetCurrent()->m_visibleObjects.LinkToTail(reenabledObject);
reenabledObject->PostReenable();
}
return 1;
}
int32_t ObjectCompressedUpdateHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
uint32_t origSize;
msg->Get(origSize);

View File

@ -8,6 +8,7 @@
#include "object/client/CGPlayer.hpp"
#include "object/client/CGUnit.hpp"
#include "object/client/ObjMgr.hpp"
#include "object/client/Util.hpp"
#include "object/Types.hpp"
#include <common/DataStore.hpp>
@ -150,6 +151,49 @@ int32_t IsMaskBitSet(uint32_t* masks, uint32_t block) {
return masks[block / 32] & (1 << (block % 32));
}
int32_t CallMirrorHandlers(CDataStore* msg, bool a2, WOWGUID guid) {
if (!a2) {
SmartGUID _guid;
*msg >> _guid;
guid = _guid;
}
auto object = FindActiveObject(guid);
if (!object) {
return SkipPartialObjectUpdate(msg);
}
uint8_t changeMaskCount;
uint32_t changeMasks[MAX_CHANGE_MASKS];
if (!ExtractDirtyMasks(msg, &changeMaskCount, changeMasks)) {
return 0;
}
OBJECT_TYPE_ID typeID = ID_OBJECT;
uint32_t blockOffset = 0;
uint32_t numBlocks = GetNumDwordBlocks(object->m_obj->m_type, guid);
for (int32_t block = 0; block < numBlocks; block++) {
if (block >= s_objMirrorBlocks[typeID]) {
blockOffset = s_objMirrorBlocks[typeID];
typeID = IncTypeID(object, typeID);
}
// TODO
if (IsMaskBitSet(changeMasks, block)) {
uint32_t blockValue = 0;
msg->Get(blockValue);
}
// TODO
}
return 1;
}
int32_t FillInPartialObjectData(CGObject_C* object, WOWGUID guid, CDataStore* msg, bool forFullUpdate, bool zeroZeroBits) {
uint8_t changeMaskCount;
uint32_t changeMasks[MAX_CHANGE_MASKS];

View File

@ -7,6 +7,8 @@
class CDataStore;
class CGObject_C;
int32_t CallMirrorHandlers(CDataStore* msg, bool a2, WOWGUID guid);
int32_t FillInPartialObjectData(CGObject_C* object, WOWGUID guid, CDataStore* msg, bool forFullUpdate, bool zeroZeroBits);
#endif

View File

@ -164,3 +164,8 @@ void InitObject(CGObject_C* object, uint32_t time, CClientObjCreate& objCreate)
}
}
}
int32_t SkipPartialObjectUpdate(CDataStore* msg) {
// TODO
return 0;
}

View File

@ -20,4 +20,6 @@ void HandleObjectOutOfRangePass2(CGObject_C* object);
void InitObject(CGObject_C* object, uint32_t time, CClientObjCreate& objCreate);
int32_t SkipPartialObjectUpdate(CDataStore* msg);
#endif

8
src/world/Types.hpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef WORLD_TYPES_HPP
#define WORLD_TYPES_HPP
#include <cstdint>
typedef uintptr_t HWORLDOBJECT;
#endif

View File

@ -1,6 +1,7 @@
#include "world/map/CMap.hpp"
#include <storm/String.hpp>
STORM_EXPLICIT_LIST(CMapBaseObj, m_lameAssLink) CMap::s_entityList;
char CMap::s_mapName[256];
char CMap::s_mapPath[256];
char CMap::s_wdtFilename[256];

View File

@ -1,11 +1,14 @@
#ifndef WORLD_MAP_C_MAP_HPP
#define WORLD_MAP_C_MAP_HPP
#include "world/map/CMapBaseObj.hpp"
#include <storm/List.hpp>
#include <cstdint>
class CMap {
public:
// Static variables
static STORM_EXPLICIT_LIST(CMapBaseObj, m_lameAssLink) s_entityList;
static char s_mapName[];
static char s_mapPath[];
static char s_wdtFilename[];

View File

@ -0,0 +1,5 @@
#include "world/map/CMapBaseObj.hpp"
uint32_t CMapBaseObj::GetType() {
return this->m_type;
}

View File

@ -0,0 +1,54 @@
#ifndef WORLD_MAP_C_MAP_BASE_OBJ_HPP
#define WORLD_MAP_C_MAP_BASE_OBJ_HPP
#include <storm/List.hpp>
#include <cstdint>
class CM2Lighting;
class CMapBaseObj;
class CMapBaseObjLink {
public:
// Member variables
uint32_t memHandle;
CMapBaseObj* owner;
CMapBaseObj* ref;
TSLink<CMapBaseObjLink> refLink;
TSLink<CMapBaseObjLink> ownerLink;
};
class CMapBaseObj {
public:
// Enums
enum {
Type_BaseObj = 0x1,
Type_Area = 0x2,
Type_Chunk = 0x4,
Type_MapObjDef = 0x8,
Type_MapObjDefGroup = 0x10,
Type_Entity = 0x20,
Type_DoodadDef = 0x40,
Type_Light = 0x80,
};
// Public member variables
uint32_t m_memHandle;
TSLink<CMapBaseObj> m_lameAssLink;
STORM_EXPLICIT_LIST(CMapBaseObjLink, ownerLink) m_parentLinkList;
// TODO
// Public virtual member functions
virtual ~CMapBaseObj() = default;
virtual void SelectLights(CM2Lighting* lighting) {};
virtual void SelectUnderwater(CM2Lighting* lighting) {};
// Public member functions
uint32_t GetType();
protected:
// Protected member variables
uint16_t m_type = Type_BaseObj;
};
#endif

View File

@ -0,0 +1,11 @@
#ifndef WORLD_MAP_C_MAP_ENTITY_HPP
#define WORLD_MAP_C_MAP_ENTITY_HPP
#include "world/map/CMapStaticEntity.hpp"
class CMapEntity : public CMapStaticEntity {
public:
// TODO
};
#endif

View File

@ -0,0 +1,11 @@
#ifndef WORLD_MAP_C_MAP_STATIC_ENTITY_HPP
#define WORLD_MAP_C_MAP_STATIC_ENTITY_HPP
#include "world/map/CMapBaseObj.hpp"
class CMapStaticEntity : public CMapBaseObj {
public:
// TODO
};
#endif