Compare commits

...

17 Commits

Author SHA1 Message Date
Marco Tylus
eed32fb3ab
Merge 8935c520c0 into fe06d5e820 2026-01-22 22:24:34 +00:00
fallenoak
fe06d5e820
feat(world): add CMap::AllocEntity 2026-01-22 16:06:48 -06:00
fallenoak
ba6f00d96c
feat(world): initialize map allocation heaps 2026-01-22 15:46:17 -06: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
aomizu
8935c520c0 feat: Add texture matrix transform support to Metal shaders for animated textures 2025-12-26 17:03:37 +09:00
aomizu
7cf7127810 feat: Implement color animation in Metal shaders by using diffuse and emissive vertex constants for output color. 2025-12-25 15:11:18 +09:00
aomizu
8fb51991e0 revert: remove non-metal shader init from Client.cpp 2025-12-25 13:24:07 +09:00
aomizu
7fdd22545f feat: Convert GxTex_Argb4444 textures to RGBA8 during Metal upload to simplify handling 2025-12-25 13:10:25 +09:00
aomizu
15eafe92d7 feat: Implement fog and point size in Metal shaders and refine render state processing for textures and other states. 2025-12-25 13:10:25 +09:00
aomizu
1ad3679f90 feat: Implement initial Metal graphics device with comprehensive shader system and pipeline management. 2025-12-25 13:10:25 +09:00
aomizu
81970958a8 feat: Add debug rendering pipeline to draw a triangle in the Metal backend. 2025-12-25 13:10:25 +09:00
aomizu
a9cad5238d init metal backend 2025-12-25 13:10:25 +09:00
52 changed files with 2614 additions and 9 deletions

View File

@ -32,6 +32,8 @@ if(WHOA_SYSTEM_MAC)
"-framework AppKit"
"-framework Carbon"
"-framework IOKit"
"-framework Metal"
"-framework QuartzCore"
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mac/MainMenu.nib DESTINATION "bin")

View File

@ -0,0 +1,9 @@
#ifndef APP_MAC_ENGINE_MTL_LAYER_VIEW_H
#define APP_MAC_ENGINE_MTL_LAYER_VIEW_H
#include "app/mac/EngineGLLayerView.h"
@interface EngineMTLLayerView : EngineGLLayerView
@end
#endif

View File

@ -0,0 +1,36 @@
#include "app/mac/EngineMTLLayerView.h"
#import <QuartzCore/CAMetalLayer.h>
@implementation EngineMTLLayerView
- (CALayer*)makeBackingLayer {
return [CAMetalLayer layer];
}
- (id)initWithFrame:(NSRect)frame glWindow:(GLWindow*)window {
self = [super initWithFrame:frame glWindow:window];
if (self) {
[self setWantsLayer:YES];
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect {
// Rendering is driven by CGxDeviceMTL.
}
- (void)update {
[super update];
if (![self.layer isKindOfClass:[CAMetalLayer class]]) {
return;
}
CAMetalLayer* layer = (CAMetalLayer*)self.layer;
CGSize size = [self convertSizeToBacking:self.bounds.size];
layer.drawableSize = size;
}
@end

View File

@ -1,7 +1,9 @@
#include "app/mac/View.h"
#include "app/mac/EngineGLLayerView.h"
#include "app/mac/EngineMTLLayerView.h"
#include "app/mac/WindowCallbacks.h"
#include "gx/gll/GLWindow.h"
#include "gx/Device.hpp"
GLWindowCallbacks EngineViewCallbacks = {
&MacOnResized,
@ -23,5 +25,9 @@ void AssignEngineViewCallbacks(GLWindowCallbacks* callbacks) {
}
Class GetEngineViewClass() {
if (GxDevApi() == GxApi_Metal) {
return [EngineMTLLayerView class];
}
return [EngineGLLayerView class];
}

View File

@ -2,6 +2,7 @@
#include "app/mac/MacClient.h"
#include "event/Input.hpp"
#include "gx/gll/CGxDeviceGLL.hpp"
#include "gx/mtl/CGxDeviceMTL.hpp"
#include "gx/Device.hpp"
#include "gx/Window.hpp"
#include <bc/Debug.hpp>
@ -171,7 +172,11 @@ void MacOnResized(int32_t width, int32_t height, bool a3) {
return;
}
static_cast<CGxDeviceGLL*>(g_theGxDevicePtr)->Resize(width, height);
if (GxDevApi() == GxApi_GLL) {
static_cast<CGxDeviceGLL*>(g_theGxDevicePtr)->Resize(width, height);
} else if (GxDevApi() == GxApi_Metal) {
static_cast<CGxDeviceMTL*>(g_theGxDevicePtr)->Resize(width, height);
}
OsQueuePut(OS_INPUT_SIZE, width, height, 0, 0);

View File

@ -6,6 +6,7 @@
#include "gx/Adapter.hpp"
#include "gx/Device.hpp"
#include <storm/Array.hpp>
#include <cstdlib>
#include <cstring>
static CGxDevice* s_device;
@ -417,6 +418,13 @@ void ConsoleDeviceInitialize(const char* title) {
api = GxApi_GLL;
#endif
#if defined(WHOA_SYSTEM_MAC)
const char* apiOverride = getenv("WHOA_GX_API");
if (apiOverride && !strcmp(apiOverride, "metal")) {
api = GxApi_Metal;
}
#endif
s_device = GxDevCreate(api, OsWindowProc, format);
// TODO

View File

@ -18,6 +18,7 @@
#if defined(WHOA_SYSTEM_MAC)
#include "gx/gll/CGxDeviceGLL.hpp"
#include "gx/mtl/CGxDeviceMTL.hpp"
#include "gx/mac/Display.hpp"
#include <ApplicationServices/ApplicationServices.h>
#include <OpenGL/OpenGL.h>
@ -117,6 +118,8 @@ int32_t CGxDevice::AdapterFormats(EGxApi api, TSGrowableArray<CGxFormat>& adapte
CGxDevice::OpenGlAdapterFormats(adapterFormats);
} else if (api == GxApi_GLL) {
CGxDevice::GLLAdapterFormats(adapterFormats);
} else if (api == GxApi_Metal) {
CGxDevice::OpenGlAdapterFormats(adapterFormats);
}
#elif defined(WHOA_SYSTEM_LINUX)
@ -228,6 +231,11 @@ CGxDevice* CGxDevice::NewGLL() {
auto m = SMemAlloc(sizeof(CGxDeviceGLL), __FILE__, __LINE__, 0x0);
return new (m) CGxDeviceGLL();
}
CGxDevice* CGxDevice::NewMTL() {
auto m = SMemAlloc(sizeof(CGxDeviceMTL), __FILE__, __LINE__, 0x0);
return new (m) CGxDeviceMTL();
}
#endif
CGxDevice* CGxDevice::NewOpenGl() {

View File

@ -70,6 +70,7 @@ class CGxDevice {
#endif
#if defined(WHOA_SYSTEM_MAC)
static CGxDevice* NewGLL();
static CGxDevice* NewMTL();
#endif
static CGxDevice* NewOpenGl();
static void OpenGlAdapterFormats(TSGrowableArray<CGxFormat>& adapterFormats);

View File

@ -20,6 +20,7 @@ if(WHOA_SYSTEM_MAC)
file(GLOB MAC_SOURCES
"gll/*.cpp"
"gll/*.mm"
"mtl/*.mm"
"mac/*.cpp"
)

View File

@ -24,6 +24,8 @@ CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t
device = CGxDevice::NewOpenGl();
} else if (api == GxApi_GLL) {
device = CGxDevice::NewGLL();
} else if (api == GxApi_Metal) {
device = CGxDevice::NewMTL();
} else {
// Error
}

View File

@ -35,7 +35,8 @@ enum EGxApi {
GxApi_D3d10 = 3,
GxApi_D3d11 = 4,
GxApi_GLL = 5,
GxApis_Last = 6
GxApi_Metal = 6,
GxApis_Last = 7
};
enum EGxBlend {

View File

@ -0,0 +1,81 @@
#ifndef GX_MTL_C_GX_DEVICE_MTL_HPP
#define GX_MTL_C_GX_DEVICE_MTL_HPP
#include "gx/CGxDevice.hpp"
#include "gx/gll/GLWindow.h"
class CGxBatch;
class CGxShader;
class CGxDeviceMTL : public CGxDevice {
public:
// Member variables
GLWindow m_window;
// Virtual member functions
void ITexMarkAsUpdated(CGxTex*) override;
void IRsSendToHw(EGxRenderState) override;
int32_t DeviceCreate(int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat&) override;
int32_t DeviceSetFormat(const CGxFormat&) override;
void* DeviceWindow() override;
void DeviceWM(EGxWM wm, uintptr_t param1, uintptr_t param2) override {};
void CapsWindowSize(CRect&) override;
void CapsWindowSizeInScreenCoords(CRect& dst) override;
void ScenePresent() override;
void SceneClear(uint32_t, CImVector) override;
void Draw(CGxBatch* batch, int32_t indexed) override;
void PoolSizeSet(CGxPool*, uint32_t) override;
char* BufLock(CGxBuf*) override;
int32_t BufUnlock(CGxBuf*, uint32_t) override;
void BufData(CGxBuf* buf, const void* data, size_t size, uintptr_t offset) override;
void TexDestroy(CGxTex* texId) override;
void IShaderCreate(CGxShader*) override;
void ShaderCreate(CGxShader*[], EGxShTarget, const char*, const char*, int32_t) override;
int32_t StereoEnabled(void) override;
void XformSetProjection(const C44Matrix& matrix) override;
// Member functions
CGxDeviceMTL();
void Resize(uint32_t width, uint32_t height);
private:
void ISetCaps(const CGxFormat& format);
void EnsureLibrary();
void BeginFrame();
void* GetPipeline(EGxVertexBufferFormat format, bool useColor, bool useSkin, bool useTex, int32_t blendMode);
void* GetPoolBuffer(CGxPool* pool);
void ITexCreate(CGxTex* texId);
void ITexUpload(CGxTex* texId);
void* GetTexture(CGxTex* texId);
void* GetSampler(CGxTex* texId);
void EnsureFallbackTexture();
void EnsureDepthTexture(uint32_t width, uint32_t height);
void* GetDepthState(bool depthTest, bool depthWrite, uint32_t depthFunc);
void* m_device = nullptr;
void* m_commandQueue = nullptr;
void* m_layer = nullptr;
void* m_shaderLibrary = nullptr;
void* m_pipelineColor[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSolid[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSkin[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineColorTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSolidTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSkinTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineColorTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSolidTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_pipelineSkinTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
void* m_frameCommandBuffer = nullptr;
void* m_frameEncoder = nullptr;
void* m_frameDrawable = nullptr;
uint32_t m_frameHasDraw = 0;
uint32_t m_clearMask = 0;
uint32_t m_clearColor = 0;
void* m_fallbackTexture = nullptr;
void* m_fallbackSampler = nullptr;
void* m_depthTexture = nullptr;
uint32_t m_depthWidth = 0;
uint32_t m_depthHeight = 0;
void* m_depthStates[2][2][4] = {};
};
#endif

1855
src/gx/mtl/CGxDeviceMTL.mm Normal file

File diff suppressed because it is too large Load Diff

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,9 +28,122 @@ enum UPDATE_TYPE {
UPDATE_IN_RANGE = 5,
};
int32_t SkipPartialObjectUpdate(CDataStore* msg) {
// TODO
return 0;
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) {
@ -322,8 +435,57 @@ int32_t ObjectUpdateFirstPass(CDataStore* msg, uint32_t time, uint32_t updateIdx
}
int32_t ObjectUpdateSecondPass(CDataStore* msg, uint32_t time, uint32_t updateCount) {
// TODO
return 0;
// 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) {

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

View File

@ -88,6 +88,10 @@ void CWorld::Initialize() {
// TODO
CMap::Initialize();
// TODO
CWorld::s_weather = STORM_NEW(Weather);
// TODO

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

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_CHUNK_LIQUID_HPP
#define WORLD_MAP_C_CHUNK_LIQUID_HPP
class CChunkLiquid {
public:
// TODO
};
#endif

View File

@ -1,10 +1,65 @@
#include "world/map/CMap.hpp"
#include "world/map/CChunkLiquid.hpp"
#include "world/map/CMapArea.hpp"
#include "world/map/CMapAreaLow.hpp"
#include "world/map/CMapCacheLight.hpp"
#include "world/map/CMapChunk.hpp"
#include "world/map/CMapDoodadDef.hpp"
#include "world/map/CMapEntity.hpp"
#include "world/map/CMapLight.hpp"
#include "world/map/CMapObj.hpp"
#include "world/map/CMapObjDef.hpp"
#include "world/map/CMapObjDefGroup.hpp"
#include "world/map/CMapObjGroup.hpp"
#include <common/ObjectAlloc.hpp>
#include <storm/String.hpp>
uint32_t* CMap::s_areaHeap;
uint32_t* CMap::s_areaLowHeap;
uint32_t* CMap::s_baseObjLinkHeap;
uint32_t* CMap::s_cacheLightHeap;
uint32_t* CMap::s_chunkHeap;
uint32_t* CMap::s_chunkLiquidHeap;
uint32_t* CMap::s_doodadDefHeap;
uint32_t* CMap::s_entityHeap;
STORM_EXPLICIT_LIST(CMapBaseObj, m_lameAssLink) CMap::s_entityList;
uint32_t* CMap::s_lightHeap;
uint32_t* CMap::s_mapObjDefGroupHeap;
uint32_t* CMap::s_mapObjDefHeap;
uint32_t* CMap::s_mapObjGroupHeap;
uint32_t* CMap::s_mapObjHeap;
char CMap::s_mapName[256];
char CMap::s_mapPath[256];
char CMap::s_wdtFilename[256];
CMapEntity* CMap::AllocEntity(int32_t a1) {
CMapEntity* entity;
uint32_t memHandle;
void* mem = nullptr;
if (ObjectAlloc(*CMap::s_entityHeap, &memHandle, &mem, false)) {
entity = new (mem) CMapEntity();
} else {
entity = nullptr;
}
if (a1) {
CMap::s_entityList.LinkToHead(entity);
} else {
CMap::s_entityList.LinkToTail(entity);
}
return entity;
}
void CMap::Initialize() {
// TODO
CMap::MapMemInitialize();
// TODO
}
void CMap::Load(const char* mapName, int32_t zoneID) {
// TODO
@ -17,3 +72,20 @@ void CMap::Load(const char* mapName, int32_t zoneID) {
// TODO
}
void CMap::MapMemInitialize() {
CMap::s_lightHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapLight), 128, "WLIGHT", true));
CMap::s_cacheLightHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapCacheLight), 256, "WCACHELIGHT", true));
CMap::s_mapObjGroupHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapObjGroup), 128, "WMAPOBJGROUP", true));
CMap::s_mapObjHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapObj), 32, "WMAPOBJ", true));
CMap::s_baseObjLinkHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapBaseObjLink), 10000, "WBASEOBJLINK", true));
CMap::s_areaHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapArea), 16, "WAREA", true));
// CMap::s_areaMedHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapAreaMed), 16, "WAREAMED", true)); ??
CMap::s_areaLowHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapAreaLow), 16, "WAREALOW", true));
CMap::s_chunkHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapChunk), 256, "WCHUNK", true));
CMap::s_doodadDefHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapDoodadDef), 5000, "WDOODADDEF", true));
CMap::s_entityHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapEntity), 128, "WENTITY", true));
CMap::s_mapObjDefGroupHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapObjDefGroup), 128, "WMAPOBJDEFGROUP", true));
CMap::s_mapObjDefHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapObjDef), 64, "WMAPOBJDEF", true));
CMap::s_chunkLiquidHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CChunkLiquid), 64, "WCHUNKLIQUID", true));
}

View File

@ -1,17 +1,38 @@
#ifndef WORLD_MAP_C_MAP_HPP
#define WORLD_MAP_C_MAP_HPP
#include "world/map/CMapBaseObj.hpp"
#include <storm/List.hpp>
#include <cstdint>
class CMapEntity;
class CMap {
public:
// Static variables
static uint32_t* s_areaHeap;
static uint32_t* s_areaLowHeap;
static uint32_t* s_baseObjLinkHeap;
static uint32_t* s_cacheLightHeap;
static uint32_t* s_chunkHeap;
static uint32_t* s_chunkLiquidHeap;
static uint32_t* s_doodadDefHeap;
static uint32_t* s_entityHeap;
static STORM_EXPLICIT_LIST(CMapBaseObj, m_lameAssLink) s_entityList;
static uint32_t* s_lightHeap;
static uint32_t* s_mapObjDefGroupHeap;
static uint32_t* s_mapObjDefHeap;
static uint32_t* s_mapObjGroupHeap;
static uint32_t* s_mapObjHeap;
static char s_mapName[];
static char s_mapPath[];
static char s_wdtFilename[];
// Static functions
static CMapEntity* AllocEntity(int32_t a1);
static void Initialize();
static void Load(const char* mapName, int32_t zoneID);
static void MapMemInitialize();
};
#endif

View File

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

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_MAP_AREA_LOW_HPP
#define WORLD_MAP_C_MAP_AREA_LOW_HPP
class CMapAreaLow {
public:
// TODO
};
#endif

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,9 @@
#ifndef WORLD_MAP_C_MAP_CACHE_LIGHT_HPP
#define WORLD_MAP_C_MAP_CACHE_LIGHT_HPP
class CMapCacheLight {
public:
// TODO
};
#endif

View File

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

View File

@ -0,0 +1,11 @@
#ifndef WORLD_MAP_C_MAP_DOODAD_DEF_HPP
#define WORLD_MAP_C_MAP_DOODAD_DEF_HPP
#include "world/map/CMapStaticEntity.hpp"
class CMapDoodadDef : public CMapStaticEntity {
public:
// TODO
};
#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_LIGHT_HPP
#define WORLD_MAP_C_MAP_LIGHT_HPP
#include "world/map/CMapBaseObj.hpp"
class CMapLight : public CMapBaseObj {
public:
// TODO
};
#endif

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_MAP_OBJ_HPP
#define WORLD_MAP_C_MAP_OBJ_HPP
class CMapObj {
public:
// TODO
};
#endif

View File

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

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_MAP_OBJ_DEF_GROUP_HPP
#define WORLD_MAP_C_MAP_OBJ_DEF_GROUP_HPP
class CMapObjDefGroup : public CMapBaseObj {
public:
// TODO
};
#endif

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_MAP_OBJ_GROUP_HPP
#define WORLD_MAP_C_MAP_OBJ_GROUP_HPP
class CMapObjGroup {
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

View File

@ -22,6 +22,8 @@ if(WHOA_SYSTEM_MAC)
"-framework AppKit"
"-framework Carbon"
"-framework IOKit"
"-framework Metal"
"-framework QuartzCore"
)
endif()