diff --git a/src/app/mac/WindowCallbacks.mm b/src/app/mac/WindowCallbacks.mm index ccdd816..44adf52 100644 --- a/src/app/mac/WindowCallbacks.mm +++ b/src/app/mac/WindowCallbacks.mm @@ -7,7 +7,7 @@ #include void MacOnKeyDown(NSEvent* event) { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } void MacOnKeyUp(NSEvent* event) { diff --git a/src/client/Client.cpp b/src/client/Client.cpp index e92484c..27f9ac5 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -24,8 +24,7 @@ #include #include #include -#include - +#include CVar* Client::g_accountNameVar; CVar* Client::g_accountListVar; diff --git a/src/client/ClientServices.cpp b/src/client/ClientServices.cpp index ec19c4a..a306b70 100644 --- a/src/client/ClientServices.cpp +++ b/src/client/ClientServices.cpp @@ -6,9 +6,8 @@ #include "console/Client.hpp" #include "console/CVar.hpp" #include "console/Types.hpp" -#include +#include #include -#include ClientConnection* g_clientConnection; @@ -59,19 +58,16 @@ ClientServices* ClientServices::GetInstance() { return ClientServices::s_instance; } - auto m = SMemAlloc(sizeof(ClientServices), __FILE__, __LINE__, 0x0); - auto instance = new (m) ClientServices(); - ClientServices::s_instance = instance; - + ClientServices::s_instance = NEW(ClientServices); return ClientServices::s_instance; } + void ClientServices::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param) { STORM_ASSERT(ClientServices::s_currentConnection); STORM_ASSERT(handler); s_currentConnection->SetMessageHandler(msgId, handler, param); } - void ClientServices::GetRealmList() { // TODO } @@ -116,13 +112,9 @@ const REALM_INFO* ClientServices::GetSelectedRealm() { void ClientServices::Initialize() { if (!g_clientConnection) { - auto adapterMem = SMemAlloc(sizeof(ClientRealmResponseAdapter), __FILE__, __LINE__, 0x0); - auto clientRealmResponse = new (adapterMem) ClientRealmResponseAdapter(); - ClientServices::s_clientRealmResponse = clientRealmResponse; + ClientServices::s_clientRealmResponse = NEW(ClientRealmResponseAdapter); - auto connectionMem = SMemAlloc(sizeof(ClientConnection), __FILE__, __LINE__, 0x0); - auto clientConnection = new (connectionMem) ClientConnection(ClientServices::s_clientRealmResponse); - g_clientConnection = clientConnection; + g_clientConnection = NEW(ClientConnection, ClientServices::s_clientRealmResponse); } ClientServices::s_currentConnection = g_clientConnection; @@ -153,8 +145,7 @@ void ClientServices::Logon(const char* accountName, const char* password) { if (useBattlenet) { // TODO } else { - auto loginMem = SMemAlloc(sizeof(GruntLogin), __FILE__, __LINE__, 0x0); - loginObj = new (loginMem) GruntLogin(); + loginObj = NEW(GruntLogin); } ClientServices::s_loginObj = loginObj; diff --git a/src/console/CMakeLists.txt b/src/console/CMakeLists.txt index 42c8794..d10e728 100644 --- a/src/console/CMakeLists.txt +++ b/src/console/CMakeLists.txt @@ -14,6 +14,7 @@ target_include_directories(console target_link_libraries(console PUBLIC + bc common gx storm diff --git a/src/console/CVar.cpp b/src/console/CVar.cpp index 5a3b05e..0cded9e 100644 --- a/src/console/CVar.cpp +++ b/src/console/CVar.cpp @@ -209,7 +209,7 @@ int32_t CVar::Load(HOSFILE file) { auto grown = 0x1fff < size; int32_t result = 0; - size_t bytesRead = 0; + uint32_t bytesRead = 0; if (OsReadFile(file, data, size, &bytesRead) == 0) { result = 0; diff --git a/src/console/Screen.cpp b/src/console/Screen.cpp index cd2a0a2..e1452f6 100644 --- a/src/console/Screen.cpp +++ b/src/console/Screen.cpp @@ -250,7 +250,7 @@ void GenerateNodeString(CONSOLELINE* node) { auto fontHeight = ConsoleGetFontHeight(); GxuFontCreateString(font, node->buffer, fontHeight, pos, 1.0f, fontHeight, 0.0f, node->fontPointer, GxVJ_Middle, GxHJ_Left, s_baseTextFlags, s_colorArray[node->colorType], s_charSpacing, 1.0f); - BLIZZARD_ASSERT(node->fontPointer); + BC_ASSERT(node->fontPointer); } } @@ -313,7 +313,7 @@ void PaintText(void* param, const RECTF* rect, const RECTF* visible, float elaps void UpdateHighlight() { auto font = TextBlockGetFontPtr(s_textFont); - BLIZZARD_ASSERT(font); + BC_ASSERT(font); auto len = SStrLen(s_copyText); diff --git a/src/db/CMakeLists.txt b/src/db/CMakeLists.txt index 7c61184..e1bf74b 100644 --- a/src/db/CMakeLists.txt +++ b/src/db/CMakeLists.txt @@ -11,6 +11,7 @@ target_include_directories(db target_link_libraries(db PUBLIC + bc common storm ) diff --git a/src/db/WowClientDB.hpp b/src/db/WowClientDB.hpp index 51495c4..a332a9f 100644 --- a/src/db/WowClientDB.hpp +++ b/src/db/WowClientDB.hpp @@ -1,11 +1,11 @@ #ifndef DB_WOW_CLIENT_DB_HPP #define DB_WOW_CLIENT_DB_HPP -#include "db/IDatabase.hpp" -#include "db/WowClientDB_Common.hpp" #include #include -#include +#include +#include "db/IDatabase.hpp" +#include "db/WowClientDB_Common.hpp" template class WowClientDB : public WowClientDB_Common, IDatabase { diff --git a/src/event/CMakeLists.txt b/src/event/CMakeLists.txt index 6346430..db6b7e4 100644 --- a/src/event/CMakeLists.txt +++ b/src/event/CMakeLists.txt @@ -42,6 +42,7 @@ target_link_libraries(event client gx PUBLIC + bc common storm tempest diff --git a/src/event/Event.cpp b/src/event/Event.cpp index a8573a6..d4ea245 100644 --- a/src/event/Event.cpp +++ b/src/event/Event.cpp @@ -136,12 +136,11 @@ void EventRegister(EVENTID id, EVENTHANDLERFUNC handler) { } void EventRegisterEx(EVENTID id, EVENTHANDLERFUNC handler, void* param, float priority) { - STORM_ASSERT(id >= 0); - STORM_VALIDATE(id >= 0, ERROR_INVALID_PARAMETER); - STORM_ASSERT(id < EVENTIDS); - STORM_VALIDATE(id < EVENTIDS, ERROR_INVALID_PARAMETER); - STORM_ASSERT(handler); - STORM_VALIDATE(handler, ERROR_INVALID_PARAMETER); + STORM_VALIDATE_BEGIN; + STORM_VALIDATE(id >= 0); + STORM_VALIDATE(id < EVENTIDS); + STORM_VALIDATE(handler); + STORM_VALIDATE_END_VOID; HEVENTCONTEXT hContext = PropGet(PROP_EVENTCONTEXT); diff --git a/src/event/Input.cpp b/src/event/Input.cpp index 8a25fca..fd06895 100644 --- a/src/event/Input.cpp +++ b/src/event/Input.cpp @@ -192,8 +192,9 @@ void PostSize(EvtContext* context, int32_t w, int32_t h) { } void ProcessInput(const int32_t param[], OSINPUT id, int32_t* shutdown, EvtContext* context) { - STORM_ASSERT(context); - STORM_VALIDATE(context, ERROR_INVALID_PARAMETER); + STORM_VALIDATE_BEGIN; + STORM_VALIDATE(context); + STORM_VALIDATE_END_VOID; switch (id) { case OS_INPUT_CAPTURE_CHANGED: @@ -361,8 +362,9 @@ void ConvertPosition(int32_t clientx, int32_t clienty, float* x, float* y) { } void EventSetMouseMode(MOUSEMODE mode, uint32_t holdButton) { - STORM_ASSERT(mode < MOUSE_MODES); - STORM_VALIDATE(mode < MOUSE_MODES, ERROR_INVALID_PARAMETER); + STORM_VALIDATE_BEGIN; + STORM_VALIDATE(mode < MOUSE_MODES); + STORM_VALIDATE_END_VOID; auto contextId = *reinterpret_cast(PropGet(PROP_EVENTCONTEXT)); int32_t findMask; @@ -468,8 +470,9 @@ void IEvtInputInitialize() { } int32_t IEvtInputProcess(EvtContext* context, int32_t* shutdown) { - STORM_ASSERT(context); - STORM_VALIDATE(context, ERROR_INVALID_PARAMETER, 0); + STORM_VALIDATE_BEGIN; + STORM_VALIDATE(context); + STORM_VALIDATE_END; int32_t v4 = 0; OSINPUT id; @@ -484,8 +487,9 @@ int32_t IEvtInputProcess(EvtContext* context, int32_t* shutdown) { } void IEvtInputSetMouseMode(EvtContext* context, MOUSEMODE mode, uint32_t holdButton) { - STORM_ASSERT(context); - STORM_VALIDATE(context, ERROR_INVALID_PARAMETER); + STORM_VALIDATE_BEGIN; + STORM_VALIDATE(context); + STORM_VALIDATE_END; if ((Input::s_buttonState & holdButton) == holdButton) { Input::s_mouseHoldButton = holdButton; diff --git a/src/event/Queue.cpp b/src/event/Queue.cpp index 03bb4db..7aae11d 100644 --- a/src/event/Queue.cpp +++ b/src/event/Queue.cpp @@ -145,7 +145,9 @@ void IEvtQueueRegister(EvtContext* context, EVENTID id, int32_t (*handler)(const } int32_t IEvtQueueCheckSyncKeyState(EvtContext* context, KEY key) { - STORM_VALIDATE(context, ERROR_INVALID_PARAMETER, 0); + STORM_VALIDATE_BEGIN; + STORM_VALIDATE(context); + STORM_VALIDATE_END; context->m_critsect.Enter(); diff --git a/src/event/Scheduler.cpp b/src/event/Scheduler.cpp index 7712d56..c7f1b17 100644 --- a/src/event/Scheduler.cpp +++ b/src/event/Scheduler.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -37,8 +37,7 @@ HEVENTCONTEXT IEvtSchedulerCreateContext(int32_t interactive, int32_t (*initiali callContext = OsCallInitializeContext(contextName); } - auto m = SMemAlloc(sizeof(EvtContext), __FILE__, __LINE__, 0x0); - auto context = new (m) EvtContext( + auto context = NEW(EvtContext, interactive != 0 ? 2 : 0, idleTime, interactive != 0 ? 1000 : 1, diff --git a/src/event/win/Input.cpp b/src/event/win/Input.cpp index 619942f..5866f53 100644 --- a/src/event/win/Input.cpp +++ b/src/event/win/Input.cpp @@ -561,8 +561,9 @@ int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param } void OsInputSetMouseMode(OS_MOUSE_MODE mode) { - STORM_ASSERT(mode < OS_MOUSE_MODES); - STORM_VALIDATE(mode < OS_MOUSE_MODES, ERROR_INVALID_PARAMETER); + STORM_VALIDATE_BEGIN; + STORM_VALIDATE(mode < OS_MOUSE_MODES); + STORM_VALIDATE_END_VOID; if (Input::s_osMouseMode == mode) { return; diff --git a/src/gameui/CGWorldFrame.cpp b/src/gameui/CGWorldFrame.cpp index 01e72c3..2c1c449 100644 --- a/src/gameui/CGWorldFrame.cpp +++ b/src/gameui/CGWorldFrame.cpp @@ -2,7 +2,7 @@ #include "gx/Transform.hpp" -#include +#include #include diff --git a/src/gameui/CMakeLists.txt b/src/gameui/CMakeLists.txt index a162bae..60fa0c3 100644 --- a/src/gameui/CMakeLists.txt +++ b/src/gameui/CMakeLists.txt @@ -22,6 +22,7 @@ target_link_libraries(gameui ui util PUBLIC + bc common storm tempest diff --git a/src/glue/CMakeLists.txt b/src/glue/CMakeLists.txt index 5e3a357..e408125 100644 --- a/src/glue/CMakeLists.txt +++ b/src/glue/CMakeLists.txt @@ -22,5 +22,6 @@ target_link_libraries(glue ui util PUBLIC + bc storm ) diff --git a/src/glue/CRealmList.cpp b/src/glue/CRealmList.cpp index 9525b5e..3a44a6f 100644 --- a/src/glue/CRealmList.cpp +++ b/src/glue/CRealmList.cpp @@ -2,8 +2,7 @@ #include "client/ClientServices.hpp" #include "db/Db.hpp" #include "ui/FrameScript.hpp" -#include -#include +#include #include float CRealmList::s_avgLoad; @@ -15,8 +14,7 @@ void CRealmList::Initialize() { CRealmList::s_categories.SetCount(g_cfg_CategoriesDB.GetNumRecords()); for (int32_t i = 0; i < g_cfg_CategoriesDB.GetNumRecords(); i++) { - auto m = SMemAlloc(sizeof(RealmCategory), __FILE__, __LINE__, 0x0); - auto category = new (m) RealmCategory(); + auto category = NEW(RealmCategory); CRealmList::s_categories[i] = category; CRealmList::s_categories[i]->m_category = g_cfg_CategoriesDB.GetRecordByIndex(i); diff --git a/src/gx/Buffer.cpp b/src/gx/Buffer.cpp index 55a4950..004078c 100644 --- a/src/gx/Buffer.cpp +++ b/src/gx/Buffer.cpp @@ -353,7 +353,7 @@ void GxPrimVertexPtr(uint32_t vertexCount, const C3Vector* pos, uint32_t posStri } void GxPrimLockVertexPtrs(uint32_t vertexCount, const C3Vector* pos, uint32_t posStride, const C3Vector* normal, uint32_t normalStride, const CImVector* color, uint32_t colorStride, const uint8_t* bone, uint32_t boneStride, const C2Vector* tex0, uint32_t tex0Stride, const C2Vector* tex1, uint32_t tex1Stride) { - BLIZZARD_ASSERT(Buffer::s_lockVertexCount == 0); + BC_ASSERT(Buffer::s_lockVertexCount == 0); Buffer::s_lockVertexCount = vertexCount; GxPrimVertexPtr(vertexCount, pos, posStride, normal, normalStride, color, colorStride, tex0, tex0Stride, tex1, tex1Stride); diff --git a/src/gx/CGxDevice.cpp b/src/gx/CGxDevice.cpp index 890a3a9..c86ccde 100644 --- a/src/gx/CGxDevice.cpp +++ b/src/gx/CGxDevice.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #if defined(WHOA_SYSTEM_WIN) #include "gx/d3d/CGxDeviceD3d.hpp" @@ -124,8 +124,7 @@ void CGxDevice::Log(const CGxFormat& format) { #if defined(WHOA_SYSTEM_WIN) CGxDevice* CGxDevice::NewD3d() { - auto m = SMemAlloc(sizeof(CGxDeviceD3d), __FILE__, __LINE__, 0x0); - return new (m) CGxDeviceD3d(); + return NEW(CGxDeviceD3d); } CGxDevice* CGxDevice::NewD3d9Ex() { @@ -136,8 +135,7 @@ CGxDevice* CGxDevice::NewD3d9Ex() { #if defined(WHOA_SYSTEM_MAC) CGxDevice* CGxDevice::NewGLL() { - auto m = SMemAlloc(sizeof(CGxDeviceGLL), __FILE__, __LINE__, 0x0); - return new (m) CGxDeviceGLL(); + return NEW(CGxDeviceGLL); } #endif @@ -147,8 +145,7 @@ CGxDevice* CGxDevice::NewOpenGl() { #if defined(WHOA_BUILD_GLSDL) CGxDevice* CGxDevice::NewGLSDL() { - auto m = SMemAlloc(sizeof(CGxDeviceGLSDL), __FILE__, __LINE__, 0x0); - return new (m) CGxDeviceGLSDL(); + return NEW(CGxDeviceGLSDL); } #endif @@ -190,8 +187,7 @@ CGxDevice::CGxDevice() { } CGxBuf* CGxDevice::BufCreate(CGxPool* pool, uint32_t itemSize, uint32_t itemCount, uint32_t index) { - auto m = SMemAlloc(sizeof(CGxBuf), __FILE__, __LINE__, 0x0); - auto buf = new (m) CGxBuf(pool, itemSize, itemCount, index); + auto buf = NEW(CGxBuf, pool, itemSize, itemCount, index); pool->m_bufList.LinkToTail(buf); @@ -904,8 +900,7 @@ void CGxDevice::PrimVertexPtr(CGxBuf* buf, EGxVertexBufferFormat format) { } CGxPool* CGxDevice::PoolCreate(EGxPoolTarget target, EGxPoolUsage usage, uint32_t size, EGxPoolHintBits hint, const char* name) { - auto m = SMemAlloc(sizeof(CGxPool), __FILE__, __LINE__, 0x0); - auto pool = new (m) CGxPool(target, usage, size, hint, name); + auto pool = NEW(CGxPool, target, usage, size, hint, name); this->m_poolList.LinkToTail(pool); @@ -1160,8 +1155,7 @@ void CGxDevice::ShaderCreate(CGxShader* shaders[], EGxShTarget target, const cha } int32_t CGxDevice::TexCreate(EGxTexTarget target, uint32_t width, uint32_t height, uint32_t depth, EGxTexFormat format, EGxTexFormat dataFormat, CGxTexFlags flags, void* userArg, void (*userFunc)(EGxTexCommand, uint32_t, uint32_t, uint32_t, uint32_t, void*, uint32_t&, const void*&), const char* name, CGxTex*& texId) { - auto m = SMemAlloc(sizeof(CGxTex), __FILE__, __LINE__, 0); - auto tex = new (m) CGxTex( + auto tex = NEW(CGxTex, target, width, height, @@ -1185,9 +1179,7 @@ int32_t CGxDevice::TexCreate(EGxTexTarget target, uint32_t width, uint32_t heigh void CGxDevice::TexDestroy(CGxTex* texId) { // TODO - if (texId) { - delete texId; - } + DEL(texId); } void CGxDevice::TexMarkForUpdate(CGxTex* texId, const CiRect& updateRect, int32_t immediate) { diff --git a/src/gx/Device.cpp b/src/gx/Device.cpp index cbe7687..f1aac0c 100644 --- a/src/gx/Device.cpp +++ b/src/gx/Device.cpp @@ -42,8 +42,9 @@ CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t break; } - if (device == nullptr) { - STORM_PANIC("GxDevCreate: failed to create graphics device %d", api); + if (!device) { + SErrPrepareAppFatal(__FILE__, __LINE__); + SErrDisplayAppFatal("GxDevCreate: failed to create graphics device %d", api); } // STORM_ASSERT(device != nullptr); diff --git a/src/gx/Draw.cpp b/src/gx/Draw.cpp index 4d3ea68..91e67bf 100644 --- a/src/gx/Draw.cpp +++ b/src/gx/Draw.cpp @@ -21,7 +21,7 @@ void GxDrawLockedElements(EGxPrim primType, uint32_t indexCount, const uint16_t* batch.m_start = 0; batch.m_count = indexCount; - BLIZZARD_ASSERT(batch.m_count > 0); + BC_ASSERT(batch.m_count > 0); g_theGxDevicePtr->Draw(&batch, 1); } diff --git a/src/gx/Font.cpp b/src/gx/Font.cpp index 6212c34..a81e91e 100644 --- a/src/gx/Font.cpp +++ b/src/gx/Font.cpp @@ -10,9 +10,8 @@ #include "gx/Shader.hpp" #include #include -#include +#include #include -#include #include #include #include @@ -247,8 +246,7 @@ CGxStringBatch* GxuFontCreateBatch(bool a1, bool a2) { batch = s_unusedBatches.Head(); s_unusedBatches.UnlinkNode(batch); } else { - auto m = SMemAlloc(sizeof(CGxStringBatch), __FILE__, __LINE__, 0x8); - batch = new (m) CGxStringBatch(); + batch = NEW_ZERO(CGxStringBatch); } if (a1) { @@ -679,7 +677,7 @@ int32_t IGxuFontGlyphRenderGlyph(FT_Face face, uint32_t pixelHeight, uint32_t co dummyGlyph = 1; } - void* data = SMemAlloc(dataSize, __FILE__, __LINE__, 0x0); + void* data = ALLOC(dataSize); if (data) { memset(data, 0, dataSize); @@ -737,6 +735,7 @@ float ScreenToPixelWidth(int32_t billboarded, float width) { return CMath::fint_n(pixelCoords); } +// TODO: name this float Sub6C2280(FT_Face face, float height) { int32_t numFixedSizes = face->num_fixed_sizes; @@ -774,8 +773,7 @@ HTEXTBLOCK TextBlockCreate(HTEXTFONT font, const char* text, const CImVector& co STORM_ASSERT(font); STORM_ASSERT(text); - auto m = SMemAlloc(sizeof(TEXTBLOCK), __FILE__, __LINE__, 0x0); - auto textBlock = new (m) TEXTBLOCK(); + auto textBlock = NEW(TEXTBLOCK); C3Vector position = { 0.0f, 0.0f, pos.z }; DDCToNDC(pos.x, pos.y, &position.x, &position.y); diff --git a/src/gx/Texture.cpp b/src/gx/Texture.cpp index 3f7664f..a009894 100644 --- a/src/gx/Texture.cpp +++ b/src/gx/Texture.cpp @@ -7,9 +7,8 @@ #include "util/SFile.hpp" #include #include -#include +#include #include -#include #include namespace Texture { @@ -805,7 +804,7 @@ CTexture* CreateBlpSync(int32_t createFlags, char* fileName, char* fileExt, CGxT size_t fileSize = SFile::GetFileSize(file, 0); - void* buf = SMemAlloc(fileSize, __FILE__, __LINE__, 0); + void* buf = ALLOC(fileSize); if (!SFile::Read(file, buf, fileSize, nullptr, nullptr, nullptr)) { // nullsub_3(); @@ -817,7 +816,7 @@ CTexture* CreateBlpSync(int32_t createFlags, char* fileName, char* fileExt, CGxT SFile::Close(file); - SMemFree(buf, __FILE__, __LINE__, 0); + FREE(buf); return texture; } @@ -979,8 +978,7 @@ HTEXTURE TextureCreate(uint32_t width, uint32_t height, EGxTexFormat format, EGx } HTEXTURE TextureCreate(EGxTexTarget target, uint32_t width, uint32_t height, uint32_t depth, EGxTexFormat format, EGxTexFormat dataFormat, CGxTexFlags texFlags, void* userArg, TEXTURE_CALLBACK* userFunc, const char* a10, int32_t a11) { - auto m = SMemAlloc(sizeof(CTexture), __FILE__, __LINE__, 0x0); - auto texture = new (m) CTexture(); + auto texture = NEW(CTexture); if (a11) { texFlags.m_filter = CTexture::s_filterMode; @@ -1010,8 +1008,7 @@ HTEXTURE TextureCreateSolid(const CImVector& color) { return textureHandle; } - auto m = SMemAlloc(sizeof(CTexture), __FILE__, __LINE__, 0x0); - auto texture = new (m) CTexture(); + auto texture = NEW(CTexture); FillInSolidTexture(color, texture); textureHandle = HandleCreate(texture); diff --git a/src/gx/font/CGxString.cpp b/src/gx/font/CGxString.cpp index 3383189..6694241 100644 --- a/src/gx/font/CGxString.cpp +++ b/src/gx/font/CGxString.cpp @@ -6,8 +6,7 @@ #include "gx/Gx.hpp" #include #include -#include -#include +#include #include #include @@ -15,16 +14,13 @@ TEXTLINETEXTURE* TEXTLINETEXTURE::NewTextLineTexture() { // TODO // Allocate off of TEXTLINETEXTURE::s_freeTextLineTextures - auto m = SMemAlloc(sizeof(TEXTLINETEXTURE), __FILE__, __LINE__, 0x0); - return new (m) TEXTLINETEXTURE(); + return NEW(TEXTLINETEXTURE); } void TEXTLINETEXTURE::Recycle(TEXTLINETEXTURE* ptr) { // TODO if (TEXTLINETEXTURE::s_recycledBytes <= 0x80000) - if (ptr) { - delete ptr; - } + DEL(ptr); } void TEXTLINETEXTURE::WriteGeometry(CGxVertexPCT* buf, const CImVector& fontColor, const C2Vector& shadowOffset, const CImVector& shadowColor, const C3Vector& viewTranslation, bool a7, bool a8, int32_t ofs, int32_t size) { @@ -118,8 +114,7 @@ CGxString* CGxString::GetNewString(int32_t linkOnList) { return string; } - auto m = SMemAlloc(sizeof(CGxString), __FILE__, __LINE__, 0x8); - string = new (m) CGxString(); + string = NEW_ZERO(CGxString); if (linkOnList) { g_strings.LinkToTail(string); @@ -331,11 +326,11 @@ int32_t CGxString::Initialize(float fontHeight, const C3Vector& position, float uint32_t textLen = SStrLen(text) + 1; if (textLen > this->m_textLen) { if (this->m_text) { - SMemFree(this->m_text, __FILE__, __LINE__, 0x0); + FREE(this->m_text); } this->m_textLen = textLen; - this->m_text = static_cast(SMemAlloc(textLen, __FILE__, __LINE__, 0x0)); + this->m_text = static_cast(ALLOC(textLen)); } SStrCopy(this->m_text, text, this->m_textLen); diff --git a/src/gx/font/FreeTypeInternal.cpp b/src/gx/font/FreeTypeInternal.cpp index 16f7c96..85918ab 100644 --- a/src/gx/font/FreeTypeInternal.cpp +++ b/src/gx/font/FreeTypeInternal.cpp @@ -1,5 +1,5 @@ #include "gx/font/FreeTypeInternal.hpp" -#include +#include void* FreeTypeAllocFunction(FT_Memory memory, long size) { return SMemAlloc(size, __FILE__, __LINE__, 0); diff --git a/src/gx/gll/CGxDeviceGLL.cpp b/src/gx/gll/CGxDeviceGLL.cpp index 74cff07..58feb5b 100644 --- a/src/gx/gll/CGxDeviceGLL.cpp +++ b/src/gx/gll/CGxDeviceGLL.cpp @@ -586,7 +586,7 @@ void CGxDeviceGLL::IRsSendToHw(EGxRenderState which) { int32_t mode = static_cast(state->m_value); // TODO - // BLIZZARD_ASSERT(mode <= GxCullState_CCW); + // BC_ASSERT(mode <= GxCullState_CCW); this->m_glDevice.SetCullMode(cullMode[mode]); @@ -720,7 +720,7 @@ void CGxDeviceGLL::IShaderBindPixel(CGxShader* sh) { this->IShaderCreatePixel(sh); } - BLIZZARD_ASSERT(sh->Valid()); + BC_ASSERT(sh->Valid()); this->m_glDevice.SetShader(GLShader::ePixelShader, static_cast(sh->apiSpecific)); } @@ -737,7 +737,7 @@ void CGxDeviceGLL::IShaderBindVertex(CGxShader* sh) { this->IShaderCreateVertex(sh); } - BLIZZARD_ASSERT(sh->Valid()); + BC_ASSERT(sh->Valid()); this->m_glDevice.SetShader(GLShader::eVertexShader, static_cast(sh->apiSpecific)); } @@ -779,7 +779,7 @@ void CGxDeviceGLL::IShaderCreate(CGxShader* sh) { } void CGxDeviceGLL::IShaderCreatePixel(CGxShader* ps) { - BLIZZARD_ASSERT(!ps->loaded); + BC_ASSERT(!ps->loaded); ps->loaded = 1; ps->valid = 0; @@ -805,7 +805,7 @@ void CGxDeviceGLL::IShaderCreatePixel(CGxShader* ps) { } void CGxDeviceGLL::IShaderCreateVertex(CGxShader* vs) { - BLIZZARD_ASSERT(!vs->loaded); + BC_ASSERT(!vs->loaded); vs->loaded = 1; vs->valid = 0; @@ -1067,7 +1067,7 @@ void CGxDeviceGLL::ITexUpload(CGxTex* texId) { texels ); - BLIZZARD_ASSERT(texels != nullptr || texId->m_flags.m_renderTarget); + BC_ASSERT(texels != nullptr || texId->m_flags.m_renderTarget); if (!texId->m_flags.m_renderTarget) { GLMipmap* mipmap = static_cast(texId->m_apiSpecificData)->GetMipmap(mipLevel - baseMip, CGxDeviceGLL::s_glCubeMapFaces[face]); @@ -1082,8 +1082,8 @@ void CGxDeviceGLL::ITexUpload(CGxTex* texId) { lockRect.maxY = std::min(lockRect.maxY, static_cast(height)); lockRect.maxX = std::min(lockRect.maxX, static_cast(width)); - BLIZZARD_ASSERT(lockRect.minX >= 0 && lockRect.maxX <= static_cast(width)); - BLIZZARD_ASSERT(lockRect.minY >= 0 && lockRect.maxY <= static_cast(height)); + BC_ASSERT(lockRect.minX >= 0 && lockRect.maxX <= static_cast(width)); + BC_ASSERT(lockRect.minY >= 0 && lockRect.maxY <= static_cast(height)); GLRect rect = { lockRect.minX, @@ -1326,7 +1326,7 @@ int32_t CGxDeviceGLL::StereoEnabled() { } void CGxDeviceGLL::TexDestroy(CGxTex* texId) { - BLIZZARD_ASSERT(texId); + BC_ASSERT(texId); auto texture = static_cast(texId->m_apiSpecificData); diff --git a/src/gx/gll/GLBuffer.cpp b/src/gx/gll/GLBuffer.cpp index bff77d8..1a93417 100644 --- a/src/gx/gll/GLBuffer.cpp +++ b/src/gx/gll/GLBuffer.cpp @@ -52,10 +52,10 @@ GLBuffer::GLBuffer() : GLObject() { } char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) { - BLIZZARD_ASSERT((offset + size) <= this->m_Size); - BLIZZARD_ASSERT(this->m_Usage == GL_STATIC_DRAW || flag != GLMap_None); - BLIZZARD_ASSERT(this->m_MapFlag == GLMap_NotMapped); - BLIZZARD_ASSERT(flag >= GLMap_None && flag < GLMap_Count); + BC_ASSERT((offset + size) <= this->m_Size); + BC_ASSERT(this->m_Usage == GL_STATIC_DRAW || flag != GLMap_None); + BC_ASSERT(this->m_MapFlag == GLMap_NotMapped); + BC_ASSERT(flag >= GLMap_None && flag < GLMap_Count); this->m_MapOffset = offset; this->m_MapSize = offset + size == 0 ? this->m_Size : size; @@ -67,7 +67,7 @@ char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) { if (flag == GLMap_Unk2) { if (this->m_Usage - GL_DYNAMIC_DRAW <= 1) { - BLIZZARD_ASSERT(offset == 0); + BC_ASSERT(offset == 0); } glBufferData(this->m_Type, this->m_Size, nullptr, this->m_Usage); @@ -76,7 +76,7 @@ char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) { void* data = glMapBuffer(this->m_Type, GLBuffer::s_FlagToAccess[flag]); this->m_Data = reinterpret_cast(data); - BLIZZARD_ASSERT(this->m_Data != nullptr); + BC_ASSERT(this->m_Data != nullptr); } return this->m_Data + offset; @@ -103,7 +103,7 @@ void GLBuffer::ReleaseObject() { } void GLBuffer::Unmap(uint32_t size) { - BLIZZARD_ASSERT((this->m_MapOffset + size) <= m_Size); + BC_ASSERT((this->m_MapOffset + size) <= m_Size); GLDevice* device = GLDevice::Get(); device->BindBuffer(this, GL_ZERO); @@ -123,7 +123,7 @@ void GLBuffer::Unmap(uint32_t size) { } GLboolean result = glUnmapBuffer(this->m_Type); - BLIZZARD_ASSERT(result); + BC_ASSERT(result); this->m_MapFlag = GLMap_NotMapped; } diff --git a/src/gx/gll/GLContext.mm b/src/gx/gll/GLContext.mm index cc2558d..9f0e9de 100644 --- a/src/gx/gll/GLContext.mm +++ b/src/gx/gll/GLContext.mm @@ -121,7 +121,7 @@ bool GLContext::IsCurrentContext() { } void GLContext::MakeCurrent(bool a2) { - BLIZZARD_ASSERT(this->m_Context->context != nullptr); + BC_ASSERT(this->m_Context->context != nullptr); if (a2) { NSOpenGLContext* v6 = GLContext::GetNSOpenGLCurrentContext(); @@ -213,17 +213,17 @@ void GLContext::SetContextFormat(GLTextureFormat a2, uint32_t sampleCount) { break; default: - BLIZZARD_ASSERT(false); + BC_ASSERT(false); break; } if (sampleCount > 1) { - BLIZZARD_ASSERT(sampleCount % 2 == 0); - BLIZZARD_ASSERT(formatAttributes[13] == 0); - BLIZZARD_ASSERT(formatAttributes[14] == 0); - BLIZZARD_ASSERT(formatAttributes[15] == 0); - BLIZZARD_ASSERT(formatAttributes[16] == 0); - BLIZZARD_ASSERT(formatAttributes[17] == 0); + BC_ASSERT(sampleCount % 2 == 0); + BC_ASSERT(formatAttributes[13] == 0); + BC_ASSERT(formatAttributes[14] == 0); + BC_ASSERT(formatAttributes[15] == 0); + BC_ASSERT(formatAttributes[16] == 0); + BC_ASSERT(formatAttributes[17] == 0); formatAttributes[13] = NSOpenGLPFASampleBuffers; formatAttributes[14] = 1; @@ -237,14 +237,14 @@ void GLContext::SetContextFormat(GLTextureFormat a2, uint32_t sampleCount) { initWithAttributes: formatAttributes ]; - BLIZZARD_ASSERT(context.pixelFormat != nullptr); + BC_ASSERT(context.pixelFormat != nullptr); context.context = [[NSOpenGLContext alloc] initWithFormat: context.pixelFormat shareContext: GLContext::s_MainContext ]; - BLIZZARD_ASSERT(context.context != nullptr); + BC_ASSERT(context.context != nullptr); this->m_Context = &context; @@ -256,7 +256,7 @@ void GLContext::SetContextFormat(GLTextureFormat a2, uint32_t sampleCount) { auto result = this->m_MTGLEnabled ? CGLEnable(contextObj, kCGLCEMPEngine) : CGLDisable(contextObj, kCGLCEMPEngine); - BLIZZARD_ASSERT(result == kCGLNoError); + BC_ASSERT(result == kCGLNoError); if (this->m_Window) { this->m_Window->SetOpenGLContext(this); diff --git a/src/gx/gll/GLDevice.cpp b/src/gx/gll/GLDevice.cpp index facc73c..12d159f 100644 --- a/src/gx/gll/GLDevice.cpp +++ b/src/gx/gll/GLDevice.cpp @@ -157,7 +157,7 @@ void GLDevice::SetOption(GLDeviceOption option, bool enable) { } default: { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } } } @@ -993,8 +993,8 @@ void GLDevice::ApplyTransforms() { } void GLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); - BLIZZARD_ASSERT(buffer != nullptr || target != GL_ZERO); + BC_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(buffer != nullptr || target != GL_ZERO); GLEnum bindTarget = target == GL_ZERO ? buffer->m_Type : target; GLuint bindName = buffer == nullptr ? 0 : buffer->m_BufferID; @@ -1010,7 +1010,7 @@ void GLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) { } else if (bindTarget == GL_PIXEL_UNPACK_BUFFER) { bindIndex = 3; } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } if (bindTarget == GL_ARRAY_BUFFER) { @@ -1032,7 +1032,7 @@ void GLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) { } void GLDevice::BindFramebuffer(GLFramebuffer* framebuffer) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); GLuint v3; @@ -1055,8 +1055,8 @@ void GLDevice::BindGLSLProgram(GLGLSLProgram* a2) { } void GLDevice::BindShader(GLShader* shader) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); - BLIZZARD_ASSERT(shader); + BC_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(shader); if (shader->var5 == GL_FRAGMENT_PROGRAM_ARB) { if (this->m_States.binding.pixelProgram != shader->m_ShaderID) { @@ -1069,19 +1069,19 @@ void GLDevice::BindShader(GLShader* shader) { this->m_States.binding.vertexProgram = shader->m_ShaderID; } } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } } void GLDevice::BindTexture(GLEnum textureType, GLTexture* texture) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); - BLIZZARD_ASSERT(texture == nullptr || textureType == texture->m_TextureType); + BC_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(texture == nullptr || textureType == texture->m_TextureType); uint32_t textureID = texture ? texture->m_TextureID : 0; uint32_t index = GLLTextureTypeToIndex(textureType); - BLIZZARD_ASSERT(this->m_States.binding.texture[index][this->m_States.binding.currentActiveTexture] != textureID); - BLIZZARD_ASSERT(this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture] != texture); + BC_ASSERT(this->m_States.binding.texture[index][this->m_States.binding.currentActiveTexture] != textureID); + BC_ASSERT(this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture] != texture); GLTexture* boundTexture = this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture]; if (boundTexture) { @@ -1125,7 +1125,7 @@ void GLDevice::BindTexture(GLEnum textureType, GLTexture* texture) { } void GLDevice::BindVertexArray(GLVertexArray* a2) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); int32_t v4 = a2 ? a2->m_VertexArrayID : 0; @@ -1137,8 +1137,8 @@ void GLDevice::BindVertexArray(GLVertexArray* a2) { } void GLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* dst, const GLRect* dstRect, GLEnum mask, GLEnum filter) { - BLIZZARD_ASSERT(mask == GL_COLOR_BUFFER_BIT); - BLIZZARD_ASSERT(src != nullptr); + BC_ASSERT(mask == GL_COLOR_BUFFER_BIT); + BC_ASSERT(src != nullptr); GLRect fullSrcRect = { 0, @@ -1154,9 +1154,9 @@ void GLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* d dst ? dst->GetHeight() : this->m_Context.GetHeight() }; - BLIZZARD_ASSERT(filter == GL_NEAREST); + BC_ASSERT(filter == GL_NEAREST); // TODO - // BLIZZARD_ASSERT(srcRect == nullptr || *srcRect == fullSrcRect); + // BC_ASSERT(srcRect == nullptr || *srcRect == fullSrcRect); // TODO // - non-shader code path @@ -1377,18 +1377,18 @@ void GLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* d } void GLDevice::CheckDepthTarget() { - BLIZZARD_ASSERT(this->m_CurrentTargetColor[0] == nullptr || this->m_CurrentTargetColor[0]->GetTexture()->IsValid()); - BLIZZARD_ASSERT(this->m_CurrentTargetColor[1] == nullptr || this->m_CurrentTargetColor[1]->GetTexture()->IsValid()); - BLIZZARD_ASSERT(this->m_CurrentTargetColor[2] == nullptr || this->m_CurrentTargetColor[2]->GetTexture()->IsValid()); - BLIZZARD_ASSERT(this->m_CurrentTargetColor[3] == nullptr || this->m_CurrentTargetColor[3]->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentTargetColor[0] == nullptr || this->m_CurrentTargetColor[0]->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentTargetColor[1] == nullptr || this->m_CurrentTargetColor[1]->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentTargetColor[2] == nullptr || this->m_CurrentTargetColor[2]->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentTargetColor[3] == nullptr || this->m_CurrentTargetColor[3]->GetTexture()->IsValid()); - BLIZZARD_ASSERT(this->m_CurrentTargetDepth == nullptr || this->m_CurrentDepthBuffer != nullptr); + BC_ASSERT(this->m_CurrentTargetDepth == nullptr || this->m_CurrentDepthBuffer != nullptr); if (!this->m_CurrentDepthBuffer) { return; } - BLIZZARD_ASSERT(this->m_CurrentDepthBuffer->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentDepthBuffer->GetTexture()->IsValid()); auto currentTargetColor = this->m_CurrentTargetColor[0]; auto currentDepthBuffer = this->m_CurrentDepthBuffer; @@ -1540,8 +1540,8 @@ void GLDevice::Clear(uint32_t clearMask, const GLColor4f& clearColor, double cle } void GLDevice::CopyTex(uint32_t a2, uint32_t a3, GLMipmap* dst, const GLRect* framebufferRect) { - BLIZZARD_ASSERT(framebufferRect->width == dst->GetWidth()); - BLIZZARD_ASSERT(framebufferRect->height == dst->GetHeight()); + BC_ASSERT(framebufferRect->width == dst->GetWidth()); + BC_ASSERT(framebufferRect->height == dst->GetHeight()); dst->m_Texture->Bind(nullptr, false); @@ -1636,7 +1636,7 @@ const GLStates::VertexArrayObject& GLDevice::GetVertexArrayStates() { } void GLDevice::GLLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t a5, uint32_t a6, uint32_t count) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); this->CheckDepthTarget(); @@ -1698,7 +1698,7 @@ void GLDevice::GLLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t a5, } else if (format == GL_UNSIGNED_INT) { v18 = 2; } else { - BLIZZARD_ASSERT(!"buffer uses unknown format"); + BC_ASSERT(!"buffer uses unknown format"); } void* indices = GLBuffer::m_UsingVBO @@ -2016,7 +2016,7 @@ void GLDevice::LoadDefaultStates() { } void GLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureFormat colorFormat, GLTextureFormat depthFormat, uint32_t sampleCount) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); if ( this->m_BackBufferColor @@ -2113,7 +2113,7 @@ void GLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureFormat this->SetDepthTestEnable(1); } - BLIZZARD_ASSERT(this->m_CurrentTarget->IsValid()); + BC_ASSERT(this->m_CurrentTarget->IsValid()); this->Clear(0x4500, GLColor4f::BLACK, 1.0, 0); } @@ -2135,7 +2135,7 @@ void GLDevice::Resize(uint32_t width, uint32_t height) { } void GLDevice::RestoreTextures() { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); for (int32_t i = 0; i < 16; i++) { GLTexture* texture = this->m_Textures[i]; @@ -2182,7 +2182,7 @@ void GLDevice::SetAlphaBlendEnable(bool enable) { void GLDevice::SetAlphaTest(GLEnum func, float ref) { if (this->m_States.fixedFunc.alphaTestFunc != func || this->m_States.fixedFunc.alphaTestRef != ref) { - BLIZZARD_ASSERT(ref <= 1.0f); + BC_ASSERT(ref <= 1.0f); glAlphaFunc(func, ref); this->m_States.fixedFunc.alphaTestFunc = func; @@ -2391,12 +2391,12 @@ void GLDevice::SetFogParam(GLEnum param, float value) { this->m_States.fixedFunc.fogDensity = value; } } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } } void GLDevice::SetIndexBuffer(GLBuffer* buffer) { - BLIZZARD_ASSERT(buffer == nullptr || buffer->m_IndexFormat != GL_ZERO); + BC_ASSERT(buffer == nullptr || buffer->m_IndexFormat != GL_ZERO); this->m_DefaultVertexArrayObject.m_Properties.m_IndexBuffer = buffer; } @@ -2424,7 +2424,7 @@ void GLDevice::SetModelView(GLEnum transform) { } if (transform != GL_MODELVIEW) { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } auto& world = this->m_States.fixedFunc.transforms.world; @@ -2445,7 +2445,7 @@ void GLDevice::SetModelView(GLEnum transform) { modelView.isDirty = true; } else { // TODO assign model * view to modelView - BLIZZARD_ASSERT(!"Unimplemented"); + BC_ASSERT(!"Unimplemented"); } if (this->m_States.fixedFunc.transforms.matrixMode != GL_MODELVIEW) { @@ -2473,8 +2473,8 @@ void GLDevice::SetShader(GLShader::ShaderType shaderType, GLShader* shader) { // TODO } - BLIZZARD_ASSERT(shader->IsEnabled()); - BLIZZARD_ASSERT(shader->GetShaderType() == shaderType); + BC_ASSERT(shader->IsEnabled()); + BC_ASSERT(shader->GetShaderType() == shaderType); this->BindShader(shader); } @@ -2506,12 +2506,12 @@ void GLDevice::SetShader(GLShader::ShaderType shaderType, GLShader* shader) { this->m_PixelShader = shader; } else { - BLIZZARD_ASSERT(!"Unknown shader type!"); + BC_ASSERT(!"Unknown shader type!"); } } void GLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) { - BLIZZARD_ASSERT(count != 0); + BC_ASSERT(count != 0); GLShader* shader = nullptr; @@ -2537,12 +2537,12 @@ void GLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t inde void GLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) { if (shaderType == GLShader::eVertexShader) { - BLIZZARD_ASSERT((index + count) <= std::extentm_States.shader.vertexShaderConst)>::value); + BC_ASSERT((index + count) <= std::extentm_States.shader.vertexShaderConst)>::value); memcpy(&this->m_States.shader.vertexShaderConst[index], constants, (sizeof(float) * 4) * count); - BLIZZARD_ASSERT(index <= 0xFFFF); - BLIZZARD_ASSERT(count <= 0xFFFF); + BC_ASSERT(index <= 0xFFFF); + BC_ASSERT(count <= 0xFFFF); uint16_t start = std::min(static_cast(index), this->m_DirtyVertexShaderConsts.start); uint16_t end = std::max(static_cast(index + count), this->m_DirtyVertexShaderConsts.end); @@ -2550,12 +2550,12 @@ void GLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint3 this->m_DirtyVertexShaderConsts.start = start; this->m_DirtyVertexShaderConsts.end = end; } else if (shaderType == GLShader::ePixelShader) { - BLIZZARD_ASSERT((index + count) <= std::extentm_States.shader.pixelShaderConst)>::value); + BC_ASSERT((index + count) <= std::extentm_States.shader.pixelShaderConst)>::value); memcpy(&this->m_States.shader.pixelShaderConst[index], constants, (sizeof(float) * 4) * count); - BLIZZARD_ASSERT(index <= 0xFFFF); - BLIZZARD_ASSERT(count <= 0xFFFF); + BC_ASSERT(index <= 0xFFFF); + BC_ASSERT(count <= 0xFFFF); uint16_t start = std::min(static_cast(index), this->m_DirtyPixelShaderConsts.start); uint16_t end = std::max(static_cast(index + count), this->m_DirtyPixelShaderConsts.end); @@ -2564,16 +2564,16 @@ void GLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint3 this->m_DirtyPixelShaderConsts.end = end; } else { // TODO - // BLIZZARD_ASSERT(false, "Unknown shader type %d!", shaderType); + // BC_ASSERT(false, "Unknown shader type %d!", shaderType); } } void GLDevice::SetTexture(uint32_t stage, GLTexture* texture) { if (stage > 15) { - BLIZZARD_ASSERT(!"setting an unsupported texture stage to a non-NULL texture"); + BC_ASSERT(!"setting an unsupported texture stage to a non-NULL texture"); } - BLIZZARD_ASSERT(texture == nullptr || texture->IsValid()); + BC_ASSERT(texture == nullptr || texture->IsValid()); uint32_t textureID = 0; GLEnum textureType = GL_TEXTURE_2D; @@ -2614,7 +2614,7 @@ void GLDevice::SetTransform(GLEnum transform, const float* a3) { } else if (transform >= GL_TEXTURE0 && transform <= GL_TEXTURE7) { t = &this->m_States.fixedFunc.transforms.texture[transform - GL_TEXTURE0]; } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } if (*t != a3) { @@ -2639,8 +2639,8 @@ void GLDevice::SetUnpackClientStorage(bool enable) { } void GLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t offset, uint32_t stride) { - BLIZZARD_ASSERT(index < GL_MAX_STREAM); - BLIZZARD_ASSERT(buffer == nullptr || buffer->m_IndexFormat == GL_ZERO); + BC_ASSERT(index < GL_MAX_STREAM); + BC_ASSERT(buffer == nullptr || buffer->m_IndexFormat == GL_ZERO); auto properties = &this->m_DefaultVertexArrayObject.m_Properties; properties->m_VertexBuffer[index] = buffer; @@ -2649,7 +2649,7 @@ void GLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t offset } void GLDevice::SetVertexFormat(GLVertexFormat* format) { - BLIZZARD_ASSERT(format->m_Size <= kMAX_VERTEX_ATTRIBS); + BC_ASSERT(format->m_Size <= kMAX_VERTEX_ATTRIBS); this->m_DefaultVertexArrayObject.m_Properties.m_VertexBufferFormat = format; } diff --git a/src/gx/gll/GLFramebuffer.cpp b/src/gx/gll/GLFramebuffer.cpp index a172d32..343b22d 100644 --- a/src/gx/gll/GLFramebuffer.cpp +++ b/src/gx/gll/GLFramebuffer.cpp @@ -10,10 +10,10 @@ GLFramebuffer* GLFramebuffer::Create(bool a1) { if (!a1) { // TODO - // BLIZZARD_ASSERT(framebuffer->m_FramebufferID >= PoolStats::NAME_POOL_FIRST_NAME); + // BC_ASSERT(framebuffer->m_FramebufferID >= PoolStats::NAME_POOL_FIRST_NAME); } - BLIZZARD_ASSERT(framebuffer->m_NumAttach == 0); + BC_ASSERT(framebuffer->m_NumAttach == 0); framebuffer->m_Width = 0; framebuffer->m_Height = 0; @@ -29,7 +29,7 @@ GLFramebuffer::GLFramebuffer(bool a1) : GLObject() { } void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { - BLIZZARD_ASSERT(this->m_Device == GLDevice::Get()); + BC_ASSERT(this->m_Device == GLDevice::Get()); if (!image) { this->Detach(a3); @@ -37,7 +37,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { } if (a3 == GL_DEPTH_STENCIL) { - BLIZZARD_ASSERT(image->GetFormat() == GLTF_D24S8); + BC_ASSERT(image->GetFormat() == GLTF_D24S8); this->Attach(image, GL_DEPTH_ATTACHMENT, 0); this->Attach(image, GL_STENCIL_ATTACHMENT, 0); @@ -57,7 +57,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { index = a3 - GL_COLOR_ATTACHMENT0; } - BLIZZARD_ASSERT(index < MAX_ATTACHMENT); + BC_ASSERT(index < MAX_ATTACHMENT); GLMipmap* oldImage = this->m_Attachments[index]; @@ -77,7 +77,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { this->m_Device->Sub38460(0); } - BLIZZARD_ASSERT((*image->m_AttachPoints)[m_FramebufferID].framebuffer == this); + BC_ASSERT((*image->m_AttachPoints)[m_FramebufferID].framebuffer == this); } void GLFramebuffer::Detach(GLenum a2) { @@ -96,7 +96,7 @@ void GLFramebuffer::Detach(GLenum a2) { index = a2 - GL_COLOR_ATTACHMENT0; } - BLIZZARD_ASSERT(index < MAX_ATTACHMENT); + BC_ASSERT(index < MAX_ATTACHMENT); GLMipmap* oldImage = this->m_Attachments[index]; @@ -129,7 +129,7 @@ GLMipmap* GLFramebuffer::GetAttachment(GLEnum a2) { index = a2 - GL_COLOR_ATTACHMENT0; } - BLIZZARD_ASSERT(index < MAX_ATTACHMENT); + BC_ASSERT(index < MAX_ATTACHMENT); return this->m_Attachments[index]; } diff --git a/src/gx/gll/GLMipmap.cpp b/src/gx/gll/GLMipmap.cpp index 68d9fa8..cd721ba 100644 --- a/src/gx/gll/GLMipmap.cpp +++ b/src/gx/gll/GLMipmap.cpp @@ -19,7 +19,7 @@ void GLMipmap::Attach(GLFramebuffer* framebuffer, GLenum attachPoint, int32_t a4 if (framebufferID >= attachPoints.size()) { attachPoints.resize(framebufferID + 1); } else { - BLIZZARD_ASSERT(attachPoints[framebufferID].framebuffer != framebuffer || attachPoints[framebufferID].point != attachPoint); + BC_ASSERT(attachPoints[framebufferID].framebuffer != framebuffer || attachPoints[framebufferID].point != attachPoint); auto& attach = attachPoints[framebufferID]; @@ -85,8 +85,8 @@ void GLMipmap::Detach(GLFramebuffer* framebuffer, GLenum attachPoint, bool a4) { auto& attachPoints = *this->m_AttachPoints; - BLIZZARD_ASSERT(attachPoints.size() >= framebufferID); - BLIZZARD_ASSERT(attachPoints[framebufferID].framebuffer == framebuffer); + BC_ASSERT(attachPoints.size() >= framebufferID); + BC_ASSERT(attachPoints[framebufferID].framebuffer == framebuffer); if (!a4 && framebufferID) { GLDevice* v12 = GLDevice::Get(); @@ -105,17 +105,17 @@ void GLMipmap::Detach(GLFramebuffer* framebuffer, GLenum attachPoint, bool a4) { GLAttachPoint* v9 = &attachPoints[framebufferID]; if (v9->point == GL_DEPTH_STENCIL) { - BLIZZARD_ASSERT(this->GetFormat() == GLTF_D24S8); + BC_ASSERT(this->GetFormat() == GLTF_D24S8); if (attachPoint == GL_DEPTH_ATTACHMENT) { v9->point = GL_STENCIL_ATTACHMENT; } else if (attachPoint == GL_STENCIL_ATTACHMENT) { v9->point = GL_DEPTH_ATTACHMENT; } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } } else { - BLIZZARD_ASSERT(attachPoints[framebufferID].point == attachPoint); + BC_ASSERT(attachPoints[framebufferID].point == attachPoint); v9->framebuffer = 0; v9->point = 0; @@ -133,8 +133,8 @@ void GLMipmap::DetachAll() { auto& attachPoints = *this->m_AttachPoints; for (int32_t i = 0; i < attachPoints.size(); i++) { - BLIZZARD_ASSERT(attachPoints[i].point != GL_ZERO); - BLIZZARD_ASSERT(attachPoints[i].framebuffer->m_FramebufferID == i); + BC_ASSERT(attachPoints[i].point != GL_ZERO); + BC_ASSERT(attachPoints[i].framebuffer->m_FramebufferID == i); attachPoints[i].framebuffer->Detach(attachPoints[i].point); } @@ -171,11 +171,11 @@ uint16_t GLMipmap::GetWidth() { } void* GLMipmap::Map(GLEnum mode, const GLBox* area) { - BLIZZARD_ASSERT(!this->m_Texture->IsSystemBuffer()); - BLIZZARD_ASSERT(this->m_Data != nullptr); - BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget()); - BLIZZARD_ASSERT(mode != GL_ZERO); - BLIZZARD_ASSERT(this->m_MapParams == nullptr); + BC_ASSERT(!this->m_Texture->IsSystemBuffer()); + BC_ASSERT(this->m_Data != nullptr); + BC_ASSERT(!this->m_Texture->IsRenderTarget()); + BC_ASSERT(mode != GL_ZERO); + BC_ASSERT(this->m_MapParams == nullptr); if (mode != GL_READ_ONLY) { this->m_Texture->m_MappedMipmaps++; @@ -185,13 +185,13 @@ void* GLMipmap::Map(GLEnum mode, const GLBox* area) { this->m_MapParams = mapParams; if (area) { - BLIZZARD_ASSERT(area->width > 0); - BLIZZARD_ASSERT(area->height > 0); - BLIZZARD_ASSERT(area->depth > 0); - BLIZZARD_ASSERT(!this->GetFormatInfo().m_IsCompressed || ((area->top & 0x3) == 0 && (area->left & 0x3) == 0 && (area->width & 0x3) == 0 && (area->height & 0x3) == 0)); - BLIZZARD_ASSERT((area->height + area->top) <= this->m_Height); - BLIZZARD_ASSERT((area->depth + area->front) <= this->m_Depth); - BLIZZARD_ASSERT((area->width + area->left) <= this->m_Width); + BC_ASSERT(area->width > 0); + BC_ASSERT(area->height > 0); + BC_ASSERT(area->depth > 0); + BC_ASSERT(!this->GetFormatInfo().m_IsCompressed || ((area->top & 0x3) == 0 && (area->left & 0x3) == 0 && (area->width & 0x3) == 0 && (area->height & 0x3) == 0)); + BC_ASSERT((area->height + area->top) <= this->m_Height); + BC_ASSERT((area->depth + area->front) <= this->m_Depth); + BC_ASSERT((area->width + area->left) <= this->m_Width); mapParams->m_MapArea = { area->left, @@ -232,7 +232,7 @@ void* GLMipmap::Map(GLEnum mode, const GLBox* area) { int32_t rowPitch = this->GetPitch(); - BLIZZARD_ASSERT(((mapParams->m_MapArea.top * rowPitch) + mapParams->m_MapArea.left * this->GetFormatInfo().m_BytePerPixel) < (this->GetFormatInfo().m_IsCompressed ? this->m_Size << 4 : this->m_Size)); + BC_ASSERT(((mapParams->m_MapArea.top * rowPitch) + mapParams->m_MapArea.left * this->GetFormatInfo().m_BytePerPixel) < (this->GetFormatInfo().m_IsCompressed ? this->m_Size << 4 : this->m_Size)); int32_t v22 = rowPitch * this->m_Height; if (this->GetFormatInfo().m_IsCompressed) { @@ -266,7 +266,7 @@ void* GLMipmap::Map(GLEnum mode, const GLRect* rect) { } void GLMipmap::ReleaseObject() { - BLIZZARD_ASSERT(this->m_MapParams == nullptr); + BC_ASSERT(this->m_MapParams == nullptr); this->RemoveDebugMipmap(); this->DetachAll(); @@ -284,17 +284,17 @@ void GLMipmap::RemoveDebugMipmap() { } void GLMipmap::ResetData(GLEnum target, int32_t level, unsigned char* data) { - BLIZZARD_ASSERT(this->m_Target != GL_TEXTURE_3D || !this->GetFormatInfo().m_IsCompressed); + BC_ASSERT(this->m_Target != GL_TEXTURE_3D || !this->GetFormatInfo().m_IsCompressed); this->m_Target = target; this->m_Level = level; this->m_Data = data; - BLIZZARD_ASSERT(this->GetFormat() != GLTF_INVALID); - BLIZZARD_ASSERT(this->GetFormat() < GLTF_NUM_TEXTURE_FORMATS); + BC_ASSERT(this->GetFormat() != GLTF_INVALID); + BC_ASSERT(this->GetFormat() < GLTF_NUM_TEXTURE_FORMATS); if (!this->m_Texture->IsSystemBuffer() && this->m_Texture->IsRenderTarget()) { - BLIZZARD_ASSERT(!this->GetFormatInfo().m_IsCompressed); + BC_ASSERT(!this->GetFormatInfo().m_IsCompressed); this->TexImage(nullptr); this->m_Unk24 = 1; @@ -307,7 +307,7 @@ void GLMipmap::ResetSize(uint32_t width, uint32_t height, uint32_t depth) { this->m_Depth = depth ? depth : 1; if (this->GetFormatInfo().m_IsCompressed) { - BLIZZARD_ASSERT(this->m_Depth == 1); + BC_ASSERT(this->m_Depth == 1); this->m_Width = (this->m_Width + 3) & 0xFFFC; this->m_Height = (this->m_Height + 3) & 0xFFFC; @@ -333,7 +333,7 @@ void GLMipmap::ResetSize(uint32_t width, uint32_t height, uint32_t depth) { } void GLMipmap::TexImage(const void* pixels) { - BLIZZARD_ASSERT((this->m_Texture->IsRenderTarget() || pixels != nullptr) && GLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); + BC_ASSERT((this->m_Texture->IsRenderTarget() || pixels != nullptr) && GLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); if (this->m_Target == GL_TEXTURE_3D) { glTexImage3D( @@ -375,7 +375,7 @@ void GLMipmap::TexImage(const void* pixels) { } void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) { - BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget() && pixels != nullptr && GLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); + BC_ASSERT(!this->m_Texture->IsRenderTarget() && pixels != nullptr && GLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); if (this->m_Target == GL_TEXTURE_3D) { glPixelStorei(GL_UNPACK_ROW_LENGTH, this->m_Width); @@ -429,9 +429,9 @@ void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) { } void GLMipmap::Unmap() { - BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget()); - BLIZZARD_ASSERT(!this->m_Texture->IsSystemBuffer()); - BLIZZARD_ASSERT(this->m_MapParams != nullptr); + BC_ASSERT(!this->m_Texture->IsRenderTarget()); + BC_ASSERT(!this->m_Texture->IsSystemBuffer()); + BC_ASSERT(this->m_MapParams != nullptr); if (this->m_MapParams->m_MapMode == GL_READ_ONLY) { delete this->m_MapParams; @@ -441,7 +441,7 @@ void GLMipmap::Unmap() { GLDevice* device = GLDevice::Get(); - BLIZZARD_ASSERT(this->m_Texture->m_MappedMipmaps > 0); + BC_ASSERT(this->m_Texture->m_MappedMipmaps > 0); if (device->m_TexWorker) { device->m_TexWorker->Lock(); @@ -459,7 +459,7 @@ void GLMipmap::Unmap() { } void GLMipmap::Unmap(MapParams* mapParams) { - BLIZZARD_ASSERT(mapParams != nullptr); + BC_ASSERT(mapParams != nullptr); this->m_Texture->Bind(nullptr, 0); diff --git a/src/gx/gll/GLObject.cpp b/src/gx/gll/GLObject.cpp index 269b2b3..7661afd 100644 --- a/src/gx/gll/GLObject.cpp +++ b/src/gx/gll/GLObject.cpp @@ -5,7 +5,7 @@ void GLObject::AddRefTwin() { } uint32_t GLObject::Release() { - BLIZZARD_ASSERT(this->m_RefCount > 0); + BC_ASSERT(this->m_RefCount > 0); this->m_RefCount--; diff --git a/src/gx/gll/GLShader.cpp b/src/gx/gll/GLShader.cpp index 7d1b19c..b3eaff5 100644 --- a/src/gx/gll/GLShader.cpp +++ b/src/gx/gll/GLShader.cpp @@ -13,14 +13,14 @@ GLShader* GLShader::Create(ShaderType shaderType, bool hybrid, bool usingCG, con const char* shaderCode = reinterpret_cast(buf); if (*reinterpret_cast(buf) == 'GSL1') { - BLIZZARD_ASSERT(!usingCG); + BC_ASSERT(!usingCG); const ShaderDataHeader header = *reinterpret_cast(buf); - BLIZZARD_ASSERT(header.shaderType == shaderType); - BLIZZARD_ASSERT(header.size == codeLen); - BLIZZARD_ASSERT(header.codePos >= sizeof(ShaderDataHeader)); - BLIZZARD_ASSERT(header.codeSize > 0); + BC_ASSERT(header.shaderType == shaderType); + BC_ASSERT(header.size == codeLen); + BC_ASSERT(header.codePos >= sizeof(ShaderDataHeader)); + BC_ASSERT(header.codeSize > 0); shaderCode = &reinterpret_cast(buf)[header.codePos]; } @@ -83,7 +83,7 @@ int32_t GLShader::GetShaderType() { } void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) { - BLIZZARD_ASSERT(!this->GetCode().empty()); + BC_ASSERT(!this->GetCode().empty()); this->m_Device = GLDevice::Get(); @@ -103,7 +103,7 @@ void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) { glProgramStringARB(this->var5, GL_PROGRAM_FORMAT_ASCII_ARB, arbLen, arbCode); - BLIZZARD_ASSERT(this->CheckErrorsARB(logInfo)); + BC_ASSERT(this->CheckErrorsARB(logInfo)); } else { // TODO // - handle GLSL shaders diff --git a/src/gx/gll/GLTexture.cpp b/src/gx/gll/GLTexture.cpp index 645138c..09f57fe 100644 --- a/src/gx/gll/GLTexture.cpp +++ b/src/gx/gll/GLTexture.cpp @@ -19,14 +19,14 @@ void GLTexture::DestroyBindings(void* ptr) { } void GLTexture::Bind(GLDevice* device, bool force) { - BLIZZARD_ASSERT(!this->IsSystemBuffer()); - BLIZZARD_ASSERT(this->m_Depth != 0); + BC_ASSERT(!this->IsSystemBuffer()); + BC_ASSERT(this->m_Depth != 0); if (!device) { device = GLDevice::Get(); } - BLIZZARD_ASSERT(device != nullptr); + BC_ASSERT(device != nullptr); auto& bindings = this->GetBindings(); uint32_t deviceID = device->GetID(); @@ -179,10 +179,10 @@ TextureFormatInfo& GLTexture::GetFormatInfo() { } GLMipmap* GLTexture::GetMipmap(uint32_t level, GLEnum face) { - BLIZZARD_ASSERT(face >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); - BLIZZARD_ASSERT(level < this->m_NumMipmap); - BLIZZARD_ASSERT(this->m_Mipmaps != nullptr); - BLIZZARD_ASSERT(this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != nullptr); + BC_ASSERT(face >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); + BC_ASSERT(level < this->m_NumMipmap); + BC_ASSERT(this->m_Mipmaps != nullptr); + BC_ASSERT(this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != nullptr); return &this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X][level]; } @@ -200,7 +200,7 @@ bool GLTexture::IsValid() { } void* GLTexture::Map(uint32_t level, const GLRect* a3, uint32_t& a4, GLEnum a5) { - BLIZZARD_ASSERT(this->m_TextureType != GL_TEXTURE_3D); + BC_ASSERT(this->m_TextureType != GL_TEXTURE_3D); auto mipmap = this->GetMipmap(level, GL_TEXTURE_CUBE_MAP_POSITIVE_X); a4 = mipmap->GetPitch(); @@ -208,7 +208,7 @@ void* GLTexture::Map(uint32_t level, const GLRect* a3, uint32_t& a4, GLEnum a5) } void GLTexture::RecreateGLTexture() { - BLIZZARD_ASSERT(GLDevice::Get()->m_TexWorker != nullptr); + BC_ASSERT(GLDevice::Get()->m_TexWorker != nullptr); if (this->m_TextureType == GL_TEXTURE_RECTANGLE_EXT) { return; @@ -238,7 +238,7 @@ void GLTexture::RecreateGLTexture() { } void GLTexture::ResizeMipmaps() { - BLIZZARD_ASSERT(this->m_Mipmaps == nullptr); + BC_ASSERT(this->m_Mipmaps == nullptr); int32_t numFace = this->m_TextureType == GL_TEXTURE_CUBE_MAP ? 6 : 1; @@ -312,7 +312,7 @@ void GLTexture::SetBorderColor(const GLColor4f& color) { } void GLTexture::SetCompareMode(GLEnum compareMode) { - BLIZZARD_ASSERT( + BC_ASSERT( this->GetFormatInfo().m_DataFormat == GL_DEPTH_COMPONENT || this->GetFormatInfo().m_DataFormat == GL_DEPTH_STENCIL_EXT || compareMode == GL_NONE @@ -364,16 +364,16 @@ void GLTexture::SetMinFilterMode(GLEnum mode) { } void GLTexture::SetupTexture() { - BLIZZARD_ASSERT(this->m_NumMipmap == 1 || (this->m_Flags & GLTFLAG_AUTOGEN_MIPMAP) == 0); - BLIZZARD_ASSERT(!this->IsRenderTarget() || this->m_NumMipmap == 1); - BLIZZARD_ASSERT(!this->IsRenderTarget() || (this->m_Flags & GLTFLAG_READ_ACCESS) == 0); + BC_ASSERT(this->m_NumMipmap == 1 || (this->m_Flags & GLTFLAG_AUTOGEN_MIPMAP) == 0); + BC_ASSERT(!this->IsRenderTarget() || this->m_NumMipmap == 1); + BC_ASSERT(!this->IsRenderTarget() || (this->m_Flags & GLTFLAG_READ_ACCESS) == 0); GLDevice* device = GLDevice::Get(); if (this->GetFormatInfo().m_IsCompressed) { int32_t smallestDim = std::min(this->m_Width, this->m_Height); - BLIZZARD_ASSERT(smallestDim >= 4); + BC_ASSERT(smallestDim >= 4); if (smallestDim == 4) { this->m_NumMipmap = 1; @@ -451,7 +451,7 @@ void GLTexture::SetupTexture() { } if (!(this->m_Flags & GLTFLAG_SYSTEM_BUFFER)) { - BLIZZARD_ASSERT(this->m_RequestedNumMipmaps != 0); + BC_ASSERT(this->m_RequestedNumMipmaps != 0); this->m_NumMipmap = std::min(this->m_NumMipmap, this->m_RequestedNumMipmaps); } @@ -487,7 +487,7 @@ void GLTexture::SetupTexture() { return; } - BLIZZARD_ASSERT(this->m_Data == nullptr); + BC_ASSERT(this->m_Data == nullptr); if (!this->IsRenderTarget()) { this->m_Data = static_cast(Blizzard::Memory::Allocate(this->m_Size)); @@ -574,9 +574,9 @@ void GLTexture::SetupTexture() { void GLTexture::Unbind(GLDevice* device, uint32_t stage) { auto& bindings = this->GetBindings(); - BLIZZARD_ASSERT(device->GetID() < bindings.size()); - BLIZZARD_ASSERT(bindings[device->GetID()].device == device); - BLIZZARD_ASSERT(bindings[device->GetID()].boundStages[stage]); + BC_ASSERT(device->GetID() < bindings.size()); + BC_ASSERT(bindings[device->GetID()].device == device); + BC_ASSERT(bindings[device->GetID()].boundStages[stage]); bindings[device->GetID()].boundStages[stage] = 0; } @@ -628,7 +628,7 @@ GLTexture2D::GLTexture2D() : GLTexture() { } void GLTexture2D::ReleaseObject() { - BLIZZARD_ASSERT(this->m_TextureType == GL_TEXTURE_2D); + BC_ASSERT(this->m_TextureType == GL_TEXTURE_2D); this->FreeTexture(); } diff --git a/src/gx/gll/GLUtil.cpp b/src/gx/gll/GLUtil.cpp index 1df1438..8b6f009 100644 --- a/src/gx/gll/GLUtil.cpp +++ b/src/gx/gll/GLUtil.cpp @@ -15,7 +15,7 @@ uint32_t GLLTextureTypeToIndex(GLEnum textureType) { } else { index = 5; - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } return index; diff --git a/src/gx/gll/GLVertexArray.cpp b/src/gx/gll/GLVertexArray.cpp index d3af1b0..cb3d494 100644 --- a/src/gx/gll/GLVertexArray.cpp +++ b/src/gx/gll/GLVertexArray.cpp @@ -107,7 +107,7 @@ void GLVertexArray::ApplyVertexFormat(GLDevice* device) { this->m_GLStates.buffers[1] = indexBufferID; } - BLIZZARD_ASSERT(this->GetProperties().m_VertexBufferFormat != nullptr); + BC_ASSERT(this->GetProperties().m_VertexBufferFormat != nullptr); auto& properties = this->GetProperties(); bool attribEnable[16] = {}; @@ -115,12 +115,12 @@ void GLVertexArray::ApplyVertexFormat(GLDevice* device) { bool useVertexShader = device->GetShader(GLShader::eVertexShader) != nullptr; for (int32_t index = 0; index < this->GetProperties().m_VertexBufferFormat->m_Size; index++) { - BLIZZARD_ASSERT(index < kMAX_VERTEX_ATTRIBS); + BC_ASSERT(index < kMAX_VERTEX_ATTRIBS); auto& attrib = this->GetProperties().m_VertexBufferFormat->m_Attribs[index]; - BLIZZARD_ASSERT(attrib.type != GLVT_INVALID); - BLIZZARD_ASSERT(attrib.type < GLVT_NUM_VERTEX_TYPES); + BC_ASSERT(attrib.type != GLVT_INVALID); + BC_ASSERT(attrib.type < GLVT_NUM_VERTEX_TYPES); auto vertexBuffer = this->GetProperties().m_VertexBuffer[attrib.stream]; diff --git a/src/gx/gll/GLWindow.mm b/src/gx/gll/GLWindow.mm index df76eaa..8973174 100644 --- a/src/gx/gll/GLWindow.mm +++ b/src/gx/gll/GLWindow.mm @@ -16,7 +16,7 @@ bool GLWindow::CanEnterFullscreenMode() { void GLWindow::CreateView() { System_Autorelease::ScopedPool autorelease; - BLIZZARD_ASSERT(this->m_View == nullptr); + BC_ASSERT(this->m_View == nullptr); GLLayerView* v1 = [this->m_ViewClass alloc]; NSView* v2 = [this->m_Window contentView]; @@ -70,7 +70,7 @@ void GLWindow::Init(const CGRect& a2, GLWindowCallbacks* a3) { this->SetCallbacks(a3); - BLIZZARD_ASSERT(this->m_Window == nullptr); + BC_ASSERT(this->m_Window == nullptr); NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0]; @@ -102,7 +102,7 @@ void GLWindow::Init(const CGRect& a2, GLWindowCallbacks* a3) { [window setBackgroundColor: [NSColor blackColor]]; - BLIZZARD_ASSERT(this->m_Window != nullptr); + BC_ASSERT(this->m_Window != nullptr); // TODO // return 1; @@ -132,7 +132,7 @@ void GLWindow::SetCallbacks(GLWindowCallbacks* callbacks) { } void GLWindow::SetOpenGLContext(GLContext* a2) { - BLIZZARD_ASSERT(this->m_View != nullptr); + BC_ASSERT(this->m_View != nullptr); System_Autorelease::ScopedPool autorelease; diff --git a/src/gx/glsdl/CGxDeviceGLSDL.cpp b/src/gx/glsdl/CGxDeviceGLSDL.cpp index d45780d..2c622a0 100644 --- a/src/gx/glsdl/CGxDeviceGLSDL.cpp +++ b/src/gx/glsdl/CGxDeviceGLSDL.cpp @@ -564,7 +564,7 @@ void CGxDeviceGLSDL::IRsSendToHw(EGxRenderState which) { int32_t mode = static_cast(state->m_value); // TODO - // BLIZZARD_ASSERT(mode <= GxCullState_CCW); + // BC_ASSERT(mode <= GxCullState_CCW); this->m_GLSDLDevice.SetCullMode(cullMode[mode]); @@ -698,7 +698,7 @@ void CGxDeviceGLSDL::IShaderBindPixel(CGxShader* sh) { this->IShaderCreatePixel(sh); } - BLIZZARD_ASSERT(sh->Valid()); + BC_ASSERT(sh->Valid()); this->m_GLSDLDevice.SetShader(GLShader::ePixelShader, static_cast(sh->apiSpecific)); } @@ -715,7 +715,7 @@ void CGxDeviceGLSDL::IShaderBindVertex(CGxShader* sh) { this->IShaderCreateVertex(sh); } - BLIZZARD_ASSERT(sh->Valid()); + BC_ASSERT(sh->Valid()); this->m_GLSDLDevice.SetShader(GLShader::eVertexShader, static_cast(sh->apiSpecific)); } @@ -757,7 +757,7 @@ void CGxDeviceGLSDL::IShaderCreate(CGxShader* sh) { } void CGxDeviceGLSDL::IShaderCreatePixel(CGxShader* ps) { - BLIZZARD_ASSERT(!ps->loaded); + BC_ASSERT(!ps->loaded); ps->loaded = 1; ps->valid = 0; @@ -783,7 +783,7 @@ void CGxDeviceGLSDL::IShaderCreatePixel(CGxShader* ps) { } void CGxDeviceGLSDL::IShaderCreateVertex(CGxShader* vs) { - BLIZZARD_ASSERT(!vs->loaded); + BC_ASSERT(!vs->loaded); vs->loaded = 1; vs->valid = 0; @@ -1055,7 +1055,7 @@ void CGxDeviceGLSDL::ITexUpload(CGxTex* texId) { texels ); - BLIZZARD_ASSERT(texels != nullptr || texId->m_flags.m_renderTarget); + BC_ASSERT(texels != nullptr || texId->m_flags.m_renderTarget); if (!texId->m_flags.m_renderTarget) { GLMipmap* mipmap = static_cast(texId->m_apiSpecificData)->GetMipmap(mipLevel - baseMip, CGxDeviceGLSDL::s_glCubeMapFaces[face]); @@ -1070,8 +1070,8 @@ void CGxDeviceGLSDL::ITexUpload(CGxTex* texId) { lockRect.maxY = std::min(lockRect.maxY, static_cast(height)); lockRect.maxX = std::min(lockRect.maxX, static_cast(width)); - BLIZZARD_ASSERT(lockRect.minX >= 0 && lockRect.maxX <= static_cast(width)); - BLIZZARD_ASSERT(lockRect.minY >= 0 && lockRect.maxY <= static_cast(height)); + BC_ASSERT(lockRect.minX >= 0 && lockRect.maxX <= static_cast(width)); + BC_ASSERT(lockRect.minY >= 0 && lockRect.maxY <= static_cast(height)); GLRect rect = { lockRect.minX, @@ -1316,7 +1316,7 @@ int32_t CGxDeviceGLSDL::StereoEnabled() { } void CGxDeviceGLSDL::TexDestroy(CGxTex* texId) { - BLIZZARD_ASSERT(texId); + BC_ASSERT(texId); auto texture = static_cast(texId->m_apiSpecificData); diff --git a/src/gx/glsdl/GLBuffer.cpp b/src/gx/glsdl/GLBuffer.cpp index ceb6eea..f89278d 100644 --- a/src/gx/glsdl/GLBuffer.cpp +++ b/src/gx/glsdl/GLBuffer.cpp @@ -54,10 +54,10 @@ GLBuffer::GLBuffer() : GLObject() { } char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) { - BLIZZARD_ASSERT((offset + size) <= this->m_Size); - BLIZZARD_ASSERT(this->m_Usage == GL_STATIC_DRAW || flag != GLMap_None); - BLIZZARD_ASSERT(this->m_MapFlag == GLMap_NotMapped); - BLIZZARD_ASSERT(flag >= GLMap_None && flag < GLMap_Count); + BC_ASSERT((offset + size) <= this->m_Size); + BC_ASSERT(this->m_Usage == GL_STATIC_DRAW || flag != GLMap_None); + BC_ASSERT(this->m_MapFlag == GLMap_NotMapped); + BC_ASSERT(flag >= GLMap_None && flag < GLMap_Count); this->m_MapOffset = offset; this->m_MapSize = offset + size == 0 ? this->m_Size : size; @@ -69,7 +69,7 @@ char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) { if (flag == GLMap_Unk2) { if (this->m_Usage - GL_DYNAMIC_DRAW <= 1) { - BLIZZARD_ASSERT(offset == 0); + BC_ASSERT(offset == 0); } glBufferData(this->m_Type, this->m_Size, nullptr, this->m_Usage); @@ -78,7 +78,7 @@ char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) { void* data = glMapBuffer(this->m_Type, GLBuffer::s_FlagToAccess[flag]); this->m_Data = reinterpret_cast(data); - BLIZZARD_ASSERT(this->m_Data != nullptr); + BC_ASSERT(this->m_Data != nullptr); } return this->m_Data + offset; @@ -105,7 +105,7 @@ void GLBuffer::ReleaseObject() { } void GLBuffer::Unmap(uint32_t size) { - BLIZZARD_ASSERT((this->m_MapOffset + size) <= m_Size); + BC_ASSERT((this->m_MapOffset + size) <= m_Size); GLSDLDevice* device = GLSDLDevice::Get(); device->BindBuffer(this, GL_ZERO); @@ -125,7 +125,7 @@ void GLBuffer::Unmap(uint32_t size) { } GLboolean result = glUnmapBuffer(this->m_Type); - BLIZZARD_ASSERT(result); + BC_ASSERT(result); this->m_MapFlag = GLMap_NotMapped; } diff --git a/src/gx/glsdl/GLFramebuffer.cpp b/src/gx/glsdl/GLFramebuffer.cpp index ade6c35..2e551de 100644 --- a/src/gx/glsdl/GLFramebuffer.cpp +++ b/src/gx/glsdl/GLFramebuffer.cpp @@ -10,10 +10,10 @@ GLFramebuffer* GLFramebuffer::Create(bool a1) { if (!a1) { // TODO - // BLIZZARD_ASSERT(framebuffer->m_FramebufferID >= PoolStats::NAME_POOL_FIRST_NAME); + // BC_ASSERT(framebuffer->m_FramebufferID >= PoolStats::NAME_POOL_FIRST_NAME); } - BLIZZARD_ASSERT(framebuffer->m_NumAttach == 0); + BC_ASSERT(framebuffer->m_NumAttach == 0); framebuffer->m_Width = 0; framebuffer->m_Height = 0; @@ -29,7 +29,7 @@ GLFramebuffer::GLFramebuffer(bool a1) : GLObject() { } void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { - BLIZZARD_ASSERT(this->m_Device == GLSDLDevice::Get()); + BC_ASSERT(this->m_Device == GLSDLDevice::Get()); if (!image) { this->Detach(a3); @@ -37,7 +37,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { } if (a3 == GL_DEPTH_STENCIL) { - BLIZZARD_ASSERT(image->GetFormat() == GLTF_D24S8); + BC_ASSERT(image->GetFormat() == GLTF_D24S8); this->Attach(image, GL_DEPTH_ATTACHMENT, 0); this->Attach(image, GL_STENCIL_ATTACHMENT, 0); @@ -57,7 +57,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { index = a3 - GL_COLOR_ATTACHMENT0; } - BLIZZARD_ASSERT(index < MAX_ATTACHMENT); + BC_ASSERT(index < MAX_ATTACHMENT); GLMipmap* oldImage = this->m_Attachments[index]; @@ -77,7 +77,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { this->m_Device->Sub38460(0); } - BLIZZARD_ASSERT((*image->m_AttachPoints)[m_FramebufferID].framebuffer == this); + BC_ASSERT((*image->m_AttachPoints)[m_FramebufferID].framebuffer == this); } void GLFramebuffer::Detach(GLenum a2) { @@ -96,7 +96,7 @@ void GLFramebuffer::Detach(GLenum a2) { index = a2 - GL_COLOR_ATTACHMENT0; } - BLIZZARD_ASSERT(index < MAX_ATTACHMENT); + BC_ASSERT(index < MAX_ATTACHMENT); GLMipmap* oldImage = this->m_Attachments[index]; @@ -129,7 +129,7 @@ GLMipmap* GLFramebuffer::GetAttachment(GLEnum a2) { index = a2 - GL_COLOR_ATTACHMENT0; } - BLIZZARD_ASSERT(index < MAX_ATTACHMENT); + BC_ASSERT(index < MAX_ATTACHMENT); return this->m_Attachments[index]; } diff --git a/src/gx/glsdl/GLMipmap.cpp b/src/gx/glsdl/GLMipmap.cpp index e66440e..7245e40 100644 --- a/src/gx/glsdl/GLMipmap.cpp +++ b/src/gx/glsdl/GLMipmap.cpp @@ -18,7 +18,7 @@ void GLMipmap::Attach(GLFramebuffer* framebuffer, GLenum attachPoint, int32_t le if (framebufferID >= attachPoints.size()) { attachPoints.resize(framebufferID + 1); } else { - BLIZZARD_ASSERT(attachPoints[framebufferID].framebuffer != framebuffer || attachPoints[framebufferID].point != attachPoint); + BC_ASSERT(attachPoints[framebufferID].framebuffer != framebuffer || attachPoints[framebufferID].point != attachPoint); auto& attach = attachPoints[framebufferID]; @@ -84,8 +84,8 @@ void GLMipmap::Detach(GLFramebuffer* framebuffer, GLenum attachPoint, bool a4) { auto& attachPoints = *this->m_AttachPoints; - BLIZZARD_ASSERT(attachPoints.size() >= framebufferID); - BLIZZARD_ASSERT(attachPoints[framebufferID].framebuffer == framebuffer); + BC_ASSERT(attachPoints.size() >= framebufferID); + BC_ASSERT(attachPoints[framebufferID].framebuffer == framebuffer); if (!a4 && framebufferID) { GLSDLDevice* v12 = GLSDLDevice::Get(); @@ -104,17 +104,17 @@ void GLMipmap::Detach(GLFramebuffer* framebuffer, GLenum attachPoint, bool a4) { GLAttachPoint* v9 = &attachPoints[framebufferID]; if (v9->point == GL_DEPTH_STENCIL) { - BLIZZARD_ASSERT(this->GetFormat() == GLTF_D24S8); + BC_ASSERT(this->GetFormat() == GLTF_D24S8); if (attachPoint == GL_DEPTH_ATTACHMENT) { v9->point = GL_STENCIL_ATTACHMENT; } else if (attachPoint == GL_STENCIL_ATTACHMENT) { v9->point = GL_DEPTH_ATTACHMENT; } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } } else { - BLIZZARD_ASSERT(attachPoints[framebufferID].point == attachPoint); + BC_ASSERT(attachPoints[framebufferID].point == attachPoint); v9->framebuffer = 0; v9->point = 0; @@ -132,8 +132,8 @@ void GLMipmap::DetachAll() { auto& attachPoints = *this->m_AttachPoints; for (int32_t i = 0; i < attachPoints.size(); i++) { - BLIZZARD_ASSERT(attachPoints[i].point != GL_ZERO); - BLIZZARD_ASSERT(attachPoints[i].framebuffer->m_FramebufferID == i); + BC_ASSERT(attachPoints[i].point != GL_ZERO); + BC_ASSERT(attachPoints[i].framebuffer->m_FramebufferID == i); attachPoints[i].framebuffer->Detach(attachPoints[i].point); } @@ -170,11 +170,11 @@ uint16_t GLMipmap::GetWidth() { } void* GLMipmap::Map(GLEnum mode, const GLBox* area) { - BLIZZARD_ASSERT(!this->m_Texture->IsSystemBuffer()); - BLIZZARD_ASSERT(this->m_Data != nullptr); - BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget()); - BLIZZARD_ASSERT(mode != GL_ZERO); - BLIZZARD_ASSERT(this->m_MapParams == nullptr); + BC_ASSERT(!this->m_Texture->IsSystemBuffer()); + BC_ASSERT(this->m_Data != nullptr); + BC_ASSERT(!this->m_Texture->IsRenderTarget()); + BC_ASSERT(mode != GL_ZERO); + BC_ASSERT(this->m_MapParams == nullptr); if (mode != GL_READ_ONLY) { this->m_Texture->m_MappedMipmaps++; @@ -184,13 +184,13 @@ void* GLMipmap::Map(GLEnum mode, const GLBox* area) { this->m_MapParams = mapParams; if (area) { - BLIZZARD_ASSERT(area->width > 0); - BLIZZARD_ASSERT(area->height > 0); - BLIZZARD_ASSERT(area->depth > 0); - BLIZZARD_ASSERT(!this->GetFormatInfo().m_IsCompressed || ((area->top & 0x3) == 0 && (area->left & 0x3) == 0 && (area->width & 0x3) == 0 && (area->height & 0x3) == 0)); - BLIZZARD_ASSERT((area->height + area->top) <= this->m_Height); - BLIZZARD_ASSERT((area->depth + area->front) <= this->m_Depth); - BLIZZARD_ASSERT((area->width + area->left) <= this->m_Width); + BC_ASSERT(area->width > 0); + BC_ASSERT(area->height > 0); + BC_ASSERT(area->depth > 0); + BC_ASSERT(!this->GetFormatInfo().m_IsCompressed || ((area->top & 0x3) == 0 && (area->left & 0x3) == 0 && (area->width & 0x3) == 0 && (area->height & 0x3) == 0)); + BC_ASSERT((area->height + area->top) <= this->m_Height); + BC_ASSERT((area->depth + area->front) <= this->m_Depth); + BC_ASSERT((area->width + area->left) <= this->m_Width); mapParams->m_MapArea = { area->left, @@ -231,7 +231,7 @@ void* GLMipmap::Map(GLEnum mode, const GLBox* area) { int32_t rowPitch = this->GetPitch(); - BLIZZARD_ASSERT(((mapParams->m_MapArea.top * rowPitch) + mapParams->m_MapArea.left * this->GetFormatInfo().m_BytePerPixel) < (this->GetFormatInfo().m_IsCompressed ? this->m_Size << 4 : this->m_Size)); + BC_ASSERT(((mapParams->m_MapArea.top * rowPitch) + mapParams->m_MapArea.left * this->GetFormatInfo().m_BytePerPixel) < (this->GetFormatInfo().m_IsCompressed ? this->m_Size << 4 : this->m_Size)); int32_t v22 = rowPitch * this->m_Height; if (this->GetFormatInfo().m_IsCompressed) { @@ -265,7 +265,7 @@ void* GLMipmap::Map(GLEnum mode, const GLRect* rect) { } void GLMipmap::ReleaseObject() { - BLIZZARD_ASSERT(this->m_MapParams == nullptr); + BC_ASSERT(this->m_MapParams == nullptr); this->RemoveDebugMipmap(); this->DetachAll(); @@ -283,17 +283,17 @@ void GLMipmap::RemoveDebugMipmap() { } void GLMipmap::ResetData(GLEnum target, int32_t level, unsigned char* data) { - BLIZZARD_ASSERT(this->m_Target != GL_TEXTURE_3D || !this->GetFormatInfo().m_IsCompressed); + BC_ASSERT(this->m_Target != GL_TEXTURE_3D || !this->GetFormatInfo().m_IsCompressed); this->m_Target = target; this->m_Level = level; this->m_Data = data; - BLIZZARD_ASSERT(this->GetFormat() != GLTF_INVALID); - BLIZZARD_ASSERT(this->GetFormat() < GLTF_NUM_TEXTURE_FORMATS); + BC_ASSERT(this->GetFormat() != GLTF_INVALID); + BC_ASSERT(this->GetFormat() < GLTF_NUM_TEXTURE_FORMATS); if (!this->m_Texture->IsSystemBuffer() && this->m_Texture->IsRenderTarget()) { - BLIZZARD_ASSERT(!this->GetFormatInfo().m_IsCompressed); + BC_ASSERT(!this->GetFormatInfo().m_IsCompressed); this->TexImage(nullptr); this->m_Unk24 = 1; @@ -306,7 +306,7 @@ void GLMipmap::ResetSize(uint32_t width, uint32_t height, uint32_t depth) { this->m_Depth = depth ? depth : 1; if (this->GetFormatInfo().m_IsCompressed) { - BLIZZARD_ASSERT(this->m_Depth == 1); + BC_ASSERT(this->m_Depth == 1); this->m_Width = (this->m_Width + 3) & 0xFFFC; this->m_Height = (this->m_Height + 3) & 0xFFFC; @@ -332,7 +332,7 @@ void GLMipmap::ResetSize(uint32_t width, uint32_t height, uint32_t depth) { } void GLMipmap::TexImage(const void* pixels) { - BLIZZARD_ASSERT((this->m_Texture->IsRenderTarget() || pixels != nullptr) && GLSDLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); + BC_ASSERT((this->m_Texture->IsRenderTarget() || pixels != nullptr) && GLSDLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); if (this->m_Target == GL_TEXTURE_3D) { glTexImage3D( @@ -374,7 +374,7 @@ void GLMipmap::TexImage(const void* pixels) { } void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) { - BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget() && pixels != nullptr && GLSDLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); + BC_ASSERT(!this->m_Texture->IsRenderTarget() && pixels != nullptr && GLSDLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); if (this->m_Target == GL_TEXTURE_3D) { glPixelStorei(GL_UNPACK_ROW_LENGTH, this->m_Width); @@ -428,9 +428,9 @@ void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) { } void GLMipmap::Unmap() { - BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget()); - BLIZZARD_ASSERT(!this->m_Texture->IsSystemBuffer()); - BLIZZARD_ASSERT(this->m_MapParams != nullptr); + BC_ASSERT(!this->m_Texture->IsRenderTarget()); + BC_ASSERT(!this->m_Texture->IsSystemBuffer()); + BC_ASSERT(this->m_MapParams != nullptr); if (this->m_MapParams->m_MapMode == GL_READ_ONLY) { delete this->m_MapParams; @@ -440,7 +440,7 @@ void GLMipmap::Unmap() { GLSDLDevice* device = GLSDLDevice::Get(); - BLIZZARD_ASSERT(this->m_Texture->m_MappedMipmaps > 0); + BC_ASSERT(this->m_Texture->m_MappedMipmaps > 0); this->Unmap(this->m_MapParams); @@ -448,7 +448,7 @@ void GLMipmap::Unmap() { } void GLMipmap::Unmap(MapParams* mapParams) { - BLIZZARD_ASSERT(mapParams != nullptr); + BC_ASSERT(mapParams != nullptr); this->m_Texture->Bind(nullptr, 0); diff --git a/src/gx/glsdl/GLObject.cpp b/src/gx/glsdl/GLObject.cpp index 205acca..02ba1df 100644 --- a/src/gx/glsdl/GLObject.cpp +++ b/src/gx/glsdl/GLObject.cpp @@ -5,7 +5,7 @@ void GLObject::AddRefTwin() { } uint32_t GLObject::Release() { - BLIZZARD_ASSERT(this->m_RefCount > 0); + BC_ASSERT(this->m_RefCount > 0); this->m_RefCount--; diff --git a/src/gx/glsdl/GLSDLContext.cpp b/src/gx/glsdl/GLSDLContext.cpp index 7750604..0f1216b 100644 --- a/src/gx/glsdl/GLSDLContext.cpp +++ b/src/gx/glsdl/GLSDLContext.cpp @@ -5,11 +5,11 @@ static bool s_GLEW_Initialized = false; void GLSDLContext::Create(GLSDLWindow* window) { - BLIZZARD_ASSERT(this->m_sdlGLContext == nullptr); + BC_ASSERT(this->m_sdlGLContext == nullptr); this->m_sdlGLContext = SDL_GL_CreateContext(window->m_sdlWindow); - BLIZZARD_ASSERT(this->m_sdlGLContext != nullptr); + BC_ASSERT(this->m_sdlGLContext != nullptr); if (s_GLEW_Initialized == false) { glewExperimental = true; @@ -25,7 +25,7 @@ void GLSDLContext::Create(GLSDLWindow* window) { } void GLSDLContext::Destroy() { - BLIZZARD_ASSERT(this->m_sdlGLContext != nullptr); + BC_ASSERT(this->m_sdlGLContext != nullptr); SDL_GL_DeleteContext(this->m_sdlGLContext); this->m_sdlGLContext = nullptr; @@ -37,7 +37,7 @@ bool GLSDLContext::IsCurrentContext() { void GLSDLContext::MakeCurrent(GLSDLWindow* window) { auto status = SDL_GL_MakeCurrent(window->m_sdlWindow, this->m_sdlGLContext); - BLIZZARD_ASSERT(status == 0); + BC_ASSERT(status == 0); } int32_t GLSDLContext::GetSampleCount() { diff --git a/src/gx/glsdl/GLSDLDevice.cpp b/src/gx/glsdl/GLSDLDevice.cpp index 81bfa15..a2f7514 100644 --- a/src/gx/glsdl/GLSDLDevice.cpp +++ b/src/gx/glsdl/GLSDLDevice.cpp @@ -156,7 +156,7 @@ void GLSDLDevice::SetOption(GLSDLDeviceOption option, bool enable) { } default: { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } } } @@ -992,8 +992,8 @@ void GLSDLDevice::ApplyTransforms() { } void GLSDLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); - BLIZZARD_ASSERT(buffer != nullptr || target != GL_ZERO); + BC_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(buffer != nullptr || target != GL_ZERO); GLEnum bindTarget = target == GL_ZERO ? buffer->m_Type : target; GLuint bindName = buffer == nullptr ? 0 : buffer->m_BufferID; @@ -1009,7 +1009,7 @@ void GLSDLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) { } else if (bindTarget == GL_PIXEL_UNPACK_BUFFER) { bindIndex = 3; } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } if (bindTarget == GL_ARRAY_BUFFER) { @@ -1031,7 +1031,7 @@ void GLSDLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) { } void GLSDLDevice::BindFramebuffer(GLFramebuffer* framebuffer) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); GLuint v3; @@ -1054,8 +1054,8 @@ void GLSDLDevice::BindGLSLProgram(GLGLSLProgram* a2) { } void GLSDLDevice::BindShader(GLShader* shader) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); - BLIZZARD_ASSERT(shader); + BC_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(shader); if (shader->var5 == GL_FRAGMENT_PROGRAM_ARB) { if (this->m_States.binding.pixelProgram != shader->m_ShaderID) { @@ -1068,19 +1068,19 @@ void GLSDLDevice::BindShader(GLShader* shader) { this->m_States.binding.vertexProgram = shader->m_ShaderID; } } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } } void GLSDLDevice::BindTexture(GLEnum textureType, GLTexture* texture) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); - BLIZZARD_ASSERT(texture == nullptr || textureType == texture->m_TextureType); + BC_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(texture == nullptr || textureType == texture->m_TextureType); uint32_t textureID = texture ? texture->m_TextureID : 0; uint32_t index = GLSDLTextureTypeToIndex(textureType); - BLIZZARD_ASSERT(this->m_States.binding.texture[index][this->m_States.binding.currentActiveTexture] != textureID); - BLIZZARD_ASSERT(this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture] != texture); + BC_ASSERT(this->m_States.binding.texture[index][this->m_States.binding.currentActiveTexture] != textureID); + BC_ASSERT(this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture] != texture); GLTexture* boundTexture = this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture]; if (boundTexture) { @@ -1124,7 +1124,7 @@ void GLSDLDevice::BindTexture(GLEnum textureType, GLTexture* texture) { } void GLSDLDevice::BindVertexArray(GLVertexArray* a2) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); int32_t v4 = a2 ? a2->m_VertexArrayID : 0; @@ -1136,8 +1136,8 @@ void GLSDLDevice::BindVertexArray(GLVertexArray* a2) { } void GLSDLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* dst, const GLRect* dstRect, GLEnum mask, GLEnum filter) { - BLIZZARD_ASSERT(mask == GL_COLOR_BUFFER_BIT); - BLIZZARD_ASSERT(src != nullptr); + BC_ASSERT(mask == GL_COLOR_BUFFER_BIT); + BC_ASSERT(src != nullptr); GLRect fullSrcRect = { 0, @@ -1153,9 +1153,9 @@ void GLSDLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap dst ? dst->GetHeight() : this->m_Window->GetHeight() }; - BLIZZARD_ASSERT(filter == GL_NEAREST); + BC_ASSERT(filter == GL_NEAREST); // TODO - // BLIZZARD_ASSERT(srcRect == nullptr || *srcRect == fullSrcRect); + // BC_ASSERT(srcRect == nullptr || *srcRect == fullSrcRect); // TODO // - non-shader code path @@ -1376,18 +1376,18 @@ void GLSDLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap } void GLSDLDevice::CheckDepthTarget() { - BLIZZARD_ASSERT(this->m_CurrentTargetColor[0] == nullptr || this->m_CurrentTargetColor[0]->GetTexture()->IsValid()); - BLIZZARD_ASSERT(this->m_CurrentTargetColor[1] == nullptr || this->m_CurrentTargetColor[1]->GetTexture()->IsValid()); - BLIZZARD_ASSERT(this->m_CurrentTargetColor[2] == nullptr || this->m_CurrentTargetColor[2]->GetTexture()->IsValid()); - BLIZZARD_ASSERT(this->m_CurrentTargetColor[3] == nullptr || this->m_CurrentTargetColor[3]->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentTargetColor[0] == nullptr || this->m_CurrentTargetColor[0]->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentTargetColor[1] == nullptr || this->m_CurrentTargetColor[1]->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentTargetColor[2] == nullptr || this->m_CurrentTargetColor[2]->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentTargetColor[3] == nullptr || this->m_CurrentTargetColor[3]->GetTexture()->IsValid()); - BLIZZARD_ASSERT(this->m_CurrentTargetDepth == nullptr || this->m_CurrentDepthBuffer != nullptr); + BC_ASSERT(this->m_CurrentTargetDepth == nullptr || this->m_CurrentDepthBuffer != nullptr); if (!this->m_CurrentDepthBuffer) { return; } - BLIZZARD_ASSERT(this->m_CurrentDepthBuffer->GetTexture()->IsValid()); + BC_ASSERT(this->m_CurrentDepthBuffer->GetTexture()->IsValid()); auto currentTargetColor = this->m_CurrentTargetColor[0]; auto currentDepthBuffer = this->m_CurrentDepthBuffer; @@ -1539,8 +1539,8 @@ void GLSDLDevice::Clear(uint32_t clearMask, const GLColor4f& clearColor, double } void GLSDLDevice::CopyTex(uint32_t a2, uint32_t a3, GLMipmap* dst, const GLRect* framebufferRect) { - BLIZZARD_ASSERT(framebufferRect->width == dst->GetWidth()); - BLIZZARD_ASSERT(framebufferRect->height == dst->GetHeight()); + BC_ASSERT(framebufferRect->width == dst->GetWidth()); + BC_ASSERT(framebufferRect->height == dst->GetHeight()); dst->m_Texture->Bind(nullptr, false); @@ -1637,7 +1637,7 @@ const GLStates::VertexArrayObject& GLSDLDevice::GetVertexArrayStates() { } void GLSDLDevice::GLSDLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t a5, uint32_t a6, uint32_t count) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); this->CheckDepthTarget(); @@ -1699,7 +1699,7 @@ void GLSDLDevice::GLSDLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t } else if (format == GL_UNSIGNED_INT) { v18 = 2; } else { - BLIZZARD_ASSERT(!"buffer uses unknown format"); + BC_ASSERT(!"buffer uses unknown format"); } void* indices = GLBuffer::m_UsingVBO @@ -2015,7 +2015,7 @@ void GLSDLDevice::LoadDefaultStates() { } void GLSDLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureFormat colorFormat, GLTextureFormat depthFormat, uint32_t sampleCount) { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); // if ( // this->m_BackBufferColor @@ -2112,7 +2112,7 @@ void GLSDLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureForm this->SetDepthTestEnable(1); } - BLIZZARD_ASSERT(this->m_CurrentTarget->IsValid()); + BC_ASSERT(this->m_CurrentTarget->IsValid()); this->Clear(0x4500, GLColor4f::BLACK, 1.0, 0); } @@ -2134,7 +2134,7 @@ void GLSDLDevice::Resize(uint32_t width, uint32_t height) { } void GLSDLDevice::RestoreTextures() { - BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); + BC_ASSERT(this->m_Context.IsCurrentContext()); for (int32_t i = 0; i < 16; i++) { GLTexture* texture = this->m_Textures[i]; @@ -2181,7 +2181,7 @@ void GLSDLDevice::SetAlphaBlendEnable(bool enable) { void GLSDLDevice::SetAlphaTest(GLEnum func, float ref) { if (this->m_States.fixedFunc.alphaTestFunc != func || this->m_States.fixedFunc.alphaTestRef != ref) { - BLIZZARD_ASSERT(ref <= 1.0f); + BC_ASSERT(ref <= 1.0f); glAlphaFunc(func, ref); this->m_States.fixedFunc.alphaTestFunc = func; @@ -2396,12 +2396,12 @@ void GLSDLDevice::SetFogParam(GLEnum param, float value) { this->m_States.fixedFunc.fogDensity = value; } } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } } void GLSDLDevice::SetIndexBuffer(GLBuffer* buffer) { - BLIZZARD_ASSERT(buffer == nullptr || buffer->m_IndexFormat != GL_ZERO); + BC_ASSERT(buffer == nullptr || buffer->m_IndexFormat != GL_ZERO); this->m_DefaultVertexArrayObject.m_Properties.m_IndexBuffer = buffer; } @@ -2429,7 +2429,7 @@ void GLSDLDevice::SetModelView(GLEnum transform) { } if (transform != GL_MODELVIEW) { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } auto& world = this->m_States.fixedFunc.transforms.world; @@ -2450,7 +2450,7 @@ void GLSDLDevice::SetModelView(GLEnum transform) { modelView.isDirty = true; } else { // TODO assign model * view to modelView - BLIZZARD_ASSERT(!"Unimplemented"); + BC_ASSERT(!"Unimplemented"); } if (this->m_States.fixedFunc.transforms.matrixMode != GL_MODELVIEW) { @@ -2496,8 +2496,8 @@ void GLSDLDevice::SetShader(GLShader::ShaderType shaderType, GLShader* shader) { // TODO } - BLIZZARD_ASSERT(shader->IsEnabled()); - BLIZZARD_ASSERT(shader->GetShaderType() == shaderType); + BC_ASSERT(shader->IsEnabled()); + BC_ASSERT(shader->GetShaderType() == shaderType); this->BindShader(shader); } @@ -2529,12 +2529,12 @@ void GLSDLDevice::SetShader(GLShader::ShaderType shaderType, GLShader* shader) { this->m_PixelShader = shader; } else { - BLIZZARD_ASSERT(!"Unknown shader type!"); + BC_ASSERT(!"Unknown shader type!"); } } void GLSDLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) { - BLIZZARD_ASSERT(count != 0); + BC_ASSERT(count != 0); GLShader* shader = nullptr; @@ -2560,12 +2560,12 @@ void GLSDLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t i void GLSDLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) { if (shaderType == GLShader::eVertexShader) { - BLIZZARD_ASSERT((index + count) <= std::extentm_States.shader.vertexShaderConst)>::value); + BC_ASSERT((index + count) <= std::extentm_States.shader.vertexShaderConst)>::value); memcpy(&this->m_States.shader.vertexShaderConst[index], constants, (sizeof(float) * 4) * count); - BLIZZARD_ASSERT(index <= 0xFFFF); - BLIZZARD_ASSERT(count <= 0xFFFF); + BC_ASSERT(index <= 0xFFFF); + BC_ASSERT(count <= 0xFFFF); uint16_t start = std::min(static_cast(index), this->m_DirtyVertexShaderConsts.start); uint16_t end = std::max(static_cast(index + count), this->m_DirtyVertexShaderConsts.end); @@ -2573,12 +2573,12 @@ void GLSDLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, ui this->m_DirtyVertexShaderConsts.start = start; this->m_DirtyVertexShaderConsts.end = end; } else if (shaderType == GLShader::ePixelShader) { - BLIZZARD_ASSERT((index + count) <= std::extentm_States.shader.pixelShaderConst)>::value); + BC_ASSERT((index + count) <= std::extentm_States.shader.pixelShaderConst)>::value); memcpy(&this->m_States.shader.pixelShaderConst[index], constants, (sizeof(float) * 4) * count); - BLIZZARD_ASSERT(index <= 0xFFFF); - BLIZZARD_ASSERT(count <= 0xFFFF); + BC_ASSERT(index <= 0xFFFF); + BC_ASSERT(count <= 0xFFFF); uint16_t start = std::min(static_cast(index), this->m_DirtyPixelShaderConsts.start); uint16_t end = std::max(static_cast(index + count), this->m_DirtyPixelShaderConsts.end); @@ -2587,16 +2587,16 @@ void GLSDLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, ui this->m_DirtyPixelShaderConsts.end = end; } else { // TODO - // BLIZZARD_ASSERT(false, "Unknown shader type %d!", shaderType); + // BC_ASSERT(false, "Unknown shader type %d!", shaderType); } } void GLSDLDevice::SetTexture(uint32_t stage, GLTexture* texture) { if (stage > 15) { - BLIZZARD_ASSERT(!"setting an unsupported texture stage to a non-NULL texture"); + BC_ASSERT(!"setting an unsupported texture stage to a non-NULL texture"); } - BLIZZARD_ASSERT(texture == nullptr || texture->IsValid()); + BC_ASSERT(texture == nullptr || texture->IsValid()); uint32_t textureID = 0; GLEnum textureType = GL_TEXTURE_2D; @@ -2637,7 +2637,7 @@ void GLSDLDevice::SetTransform(GLEnum transform, const float* a3) { } else if (transform >= GL_TEXTURE0 && transform <= GL_TEXTURE7) { t = &this->m_States.fixedFunc.transforms.texture[transform - GL_TEXTURE0]; } else { - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } if (*t != a3) { @@ -2662,8 +2662,8 @@ void GLSDLDevice::SetUnpackClientStorage(bool enable) { } void GLSDLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t offset, uint32_t stride) { - BLIZZARD_ASSERT(index < GL_MAX_STREAM); - BLIZZARD_ASSERT(buffer == nullptr || buffer->m_IndexFormat == GL_ZERO); + BC_ASSERT(index < GL_MAX_STREAM); + BC_ASSERT(buffer == nullptr || buffer->m_IndexFormat == GL_ZERO); auto properties = &this->m_DefaultVertexArrayObject.m_Properties; properties->m_VertexBuffer[index] = buffer; @@ -2672,7 +2672,7 @@ void GLSDLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t off } void GLSDLDevice::SetVertexFormat(GLVertexFormat* format) { - BLIZZARD_ASSERT(format->m_Size <= kMAX_VERTEX_ATTRIBS); + BC_ASSERT(format->m_Size <= kMAX_VERTEX_ATTRIBS); this->m_DefaultVertexArrayObject.m_Properties.m_VertexBufferFormat = format; } diff --git a/src/gx/glsdl/GLSDLWindow.cpp b/src/gx/glsdl/GLSDLWindow.cpp index 757e89b..51c918a 100644 --- a/src/gx/glsdl/GLSDLWindow.cpp +++ b/src/gx/glsdl/GLSDLWindow.cpp @@ -13,7 +13,7 @@ static bool s_GLSDL_Initialized = false; void GLSDLWindow::Create(const char* title, const GLSDLWindowRect& rect, GLTextureFormat depthFormat, uint32_t sampleCount) { - BLIZZARD_ASSERT(this->m_sdlWindow == nullptr); + BC_ASSERT(this->m_sdlWindow == nullptr); if (!s_GLSDL_Initialized) { // Initialize SDL video context @@ -48,7 +48,7 @@ void GLSDLWindow::Create(const char* title, const GLSDLWindowRect& rect, GLTextu stencilSize = 8; break; default: - BLIZZARD_ASSERT(false); + BC_ASSERT(false); break; } @@ -74,7 +74,7 @@ void GLSDLWindow::Create(const char* title, const GLSDLWindowRect& rect, GLTextu SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE ); - BLIZZARD_ASSERT(this->m_sdlWindow != nullptr); + BC_ASSERT(this->m_sdlWindow != nullptr); SDL_StartTextInput(); } @@ -126,7 +126,7 @@ void GLSDLWindow::Resize(const GLSDLWindowRect& rect) { if (current.size.width != rect.size.width || current.size.height != rect.size.width) { SDL_SetWindowSize(this->m_sdlWindow, rect.size.width, rect.size.height); - // BLIZZARD_ASSERT(status == 0); + // BC_ASSERT(status == 0); } } diff --git a/src/gx/glsdl/GLShader.cpp b/src/gx/glsdl/GLShader.cpp index fa91a75..e16236d 100644 --- a/src/gx/glsdl/GLShader.cpp +++ b/src/gx/glsdl/GLShader.cpp @@ -15,14 +15,14 @@ GLShader* GLShader::Create(ShaderType shaderType, bool hybrid, bool usingCG, con const char* shaderCode = reinterpret_cast(buf); if (*reinterpret_cast(buf) == 'GSL1') { - BLIZZARD_ASSERT(!usingCG); + BC_ASSERT(!usingCG); const ShaderDataHeader header = *reinterpret_cast(buf); - BLIZZARD_ASSERT(header.shaderType == shaderType); - BLIZZARD_ASSERT(header.size == codeLen); - BLIZZARD_ASSERT(header.codePos >= sizeof(ShaderDataHeader)); - BLIZZARD_ASSERT(header.codeSize > 0); + BC_ASSERT(header.shaderType == shaderType); + BC_ASSERT(header.size == codeLen); + BC_ASSERT(header.codePos >= sizeof(ShaderDataHeader)); + BC_ASSERT(header.codeSize > 0); shaderCode = &reinterpret_cast(buf)[header.codePos]; } @@ -85,7 +85,7 @@ int32_t GLShader::GetShaderType() { } void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) { - BLIZZARD_ASSERT(!this->GetCode().empty()); + BC_ASSERT(!this->GetCode().empty()); this->m_Device = GLSDLDevice::Get(); @@ -105,7 +105,7 @@ void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) { glProgramStringARB(this->var5, GL_PROGRAM_FORMAT_ASCII_ARB, arbLen, arbCode); - BLIZZARD_ASSERT(this->CheckErrorsARB(logInfo)); + BC_ASSERT(this->CheckErrorsARB(logInfo)); } else { // TODO // - handle GLSL shaders diff --git a/src/gx/glsdl/GLTexture.cpp b/src/gx/glsdl/GLTexture.cpp index 6f0d9ff..4451db5 100644 --- a/src/gx/glsdl/GLTexture.cpp +++ b/src/gx/glsdl/GLTexture.cpp @@ -18,14 +18,14 @@ void GLTexture::DestroyBindings(void* ptr) { } void GLTexture::Bind(GLSDLDevice* device, bool force) { - BLIZZARD_ASSERT(!this->IsSystemBuffer()); - BLIZZARD_ASSERT(this->m_Depth != 0); + BC_ASSERT(!this->IsSystemBuffer()); + BC_ASSERT(this->m_Depth != 0); if (!device) { device = GLSDLDevice::Get(); } - BLIZZARD_ASSERT(device != nullptr); + BC_ASSERT(device != nullptr); auto& bindings = this->GetBindings(); uint32_t deviceID = device->GetID(); @@ -152,10 +152,10 @@ TextureFormatInfo& GLTexture::GetFormatInfo() { } GLMipmap* GLTexture::GetMipmap(uint32_t level, GLEnum face) { - BLIZZARD_ASSERT(face >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); - BLIZZARD_ASSERT(level < this->m_NumMipmap); - BLIZZARD_ASSERT(this->m_Mipmaps != nullptr); - BLIZZARD_ASSERT(this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != nullptr); + BC_ASSERT(face >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); + BC_ASSERT(level < this->m_NumMipmap); + BC_ASSERT(this->m_Mipmaps != nullptr); + BC_ASSERT(this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != nullptr); return &this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X][level]; } @@ -173,7 +173,7 @@ bool GLTexture::IsValid() { } void* GLTexture::Map(uint32_t level, const GLRect* a3, uint32_t& a4, GLEnum a5) { - BLIZZARD_ASSERT(this->m_TextureType != GL_TEXTURE_3D); + BC_ASSERT(this->m_TextureType != GL_TEXTURE_3D); auto mipmap = this->GetMipmap(level, GL_TEXTURE_CUBE_MAP_POSITIVE_X); a4 = mipmap->GetPitch(); @@ -209,7 +209,7 @@ void GLTexture::RecreateGLTexture() { } void GLTexture::ResizeMipmaps() { - BLIZZARD_ASSERT(this->m_Mipmaps == nullptr); + BC_ASSERT(this->m_Mipmaps == nullptr); int32_t numFace = this->m_TextureType == GL_TEXTURE_CUBE_MAP ? 6 : 1; @@ -283,7 +283,7 @@ void GLTexture::SetBorderColor(const GLColor4f& color) { } void GLTexture::SetCompareMode(GLEnum compareMode) { - BLIZZARD_ASSERT( + BC_ASSERT( this->GetFormatInfo().m_DataFormat == GL_DEPTH_COMPONENT || this->GetFormatInfo().m_DataFormat == GL_DEPTH_STENCIL_EXT || compareMode == GL_NONE @@ -335,16 +335,16 @@ void GLTexture::SetMinFilterMode(GLEnum mode) { } void GLTexture::SetupTexture() { - BLIZZARD_ASSERT(this->m_NumMipmap == 1 || (this->m_Flags & GLTFLAG_AUTOGEN_MIPMAP) == 0); - BLIZZARD_ASSERT(!this->IsRenderTarget() || this->m_NumMipmap == 1); - BLIZZARD_ASSERT(!this->IsRenderTarget() || (this->m_Flags & GLTFLAG_READ_ACCESS) == 0); + BC_ASSERT(this->m_NumMipmap == 1 || (this->m_Flags & GLTFLAG_AUTOGEN_MIPMAP) == 0); + BC_ASSERT(!this->IsRenderTarget() || this->m_NumMipmap == 1); + BC_ASSERT(!this->IsRenderTarget() || (this->m_Flags & GLTFLAG_READ_ACCESS) == 0); GLSDLDevice* device = GLSDLDevice::Get(); if (this->GetFormatInfo().m_IsCompressed) { int32_t smallestDim = std::min(this->m_Width, this->m_Height); - BLIZZARD_ASSERT(smallestDim >= 4); + BC_ASSERT(smallestDim >= 4); if (smallestDim == 4) { this->m_NumMipmap = 1; @@ -422,7 +422,7 @@ void GLTexture::SetupTexture() { } if (!(this->m_Flags & GLTFLAG_SYSTEM_BUFFER)) { - BLIZZARD_ASSERT(this->m_RequestedNumMipmaps != 0); + BC_ASSERT(this->m_RequestedNumMipmaps != 0); this->m_NumMipmap = std::min(this->m_NumMipmap, this->m_RequestedNumMipmaps); } @@ -458,7 +458,7 @@ void GLTexture::SetupTexture() { return; } - BLIZZARD_ASSERT(this->m_Data == nullptr); + BC_ASSERT(this->m_Data == nullptr); if (!this->IsRenderTarget()) { this->m_Data = static_cast(Blizzard::Memory::Allocate(this->m_Size)); @@ -545,9 +545,9 @@ void GLTexture::SetupTexture() { void GLTexture::Unbind(GLSDLDevice* device, uint32_t stage) { auto& bindings = this->GetBindings(); - BLIZZARD_ASSERT(device->GetID() < bindings.size()); - BLIZZARD_ASSERT(bindings[device->GetID()].device == device); - BLIZZARD_ASSERT(bindings[device->GetID()].boundStages[stage]); + BC_ASSERT(device->GetID() < bindings.size()); + BC_ASSERT(bindings[device->GetID()].device == device); + BC_ASSERT(bindings[device->GetID()].boundStages[stage]); bindings[device->GetID()].boundStages[stage] = 0; } @@ -599,7 +599,7 @@ GLTexture2D::GLTexture2D() : GLTexture() { } void GLTexture2D::ReleaseObject() { - BLIZZARD_ASSERT(this->m_TextureType == GL_TEXTURE_2D); + BC_ASSERT(this->m_TextureType == GL_TEXTURE_2D); this->FreeTexture(); } diff --git a/src/gx/glsdl/GLUtil.cpp b/src/gx/glsdl/GLUtil.cpp index c57b3e4..f138dad 100644 --- a/src/gx/glsdl/GLUtil.cpp +++ b/src/gx/glsdl/GLUtil.cpp @@ -15,7 +15,7 @@ uint32_t GLSDLTextureTypeToIndex(GLEnum textureType) { } else { index = 5; - BLIZZARD_ASSERT(false); + BC_ASSERT(false); } return index; diff --git a/src/gx/glsdl/GLVertexArray.cpp b/src/gx/glsdl/GLVertexArray.cpp index d7841f8..7254c7f 100644 --- a/src/gx/glsdl/GLVertexArray.cpp +++ b/src/gx/glsdl/GLVertexArray.cpp @@ -107,7 +107,7 @@ void GLVertexArray::ApplyVertexFormat(GLSDLDevice* device) { this->m_GLStates.buffers[1] = indexBufferID; } - BLIZZARD_ASSERT(this->GetProperties().m_VertexBufferFormat != nullptr); + BC_ASSERT(this->GetProperties().m_VertexBufferFormat != nullptr); auto& properties = this->GetProperties(); bool attribEnable[16] = {}; @@ -115,12 +115,12 @@ void GLVertexArray::ApplyVertexFormat(GLSDLDevice* device) { bool useVertexShader = device->GetShader(GLShader::eVertexShader) != nullptr; for (int32_t index = 0; index < this->GetProperties().m_VertexBufferFormat->m_Size; index++) { - BLIZZARD_ASSERT(index < kMAX_VERTEX_ATTRIBS); + BC_ASSERT(index < kMAX_VERTEX_ATTRIBS); auto& attrib = this->GetProperties().m_VertexBufferFormat->m_Attribs[index]; - BLIZZARD_ASSERT(attrib.type != GLVT_INVALID); - BLIZZARD_ASSERT(attrib.type < GLVT_NUM_VERTEX_TYPES); + BC_ASSERT(attrib.type != GLVT_INVALID); + BC_ASSERT(attrib.type < GLVT_NUM_VERTEX_TYPES); auto vertexBuffer = this->GetProperties().m_VertexBuffer[attrib.stream]; diff --git a/src/gx/texture/CBLPFile.cpp b/src/gx/texture/CBLPFile.cpp index ec6899b..00e1b32 100644 --- a/src/gx/texture/CBLPFile.cpp +++ b/src/gx/texture/CBLPFile.cpp @@ -4,7 +4,7 @@ #include "util/Unimplemented.hpp" #include #include -#include +#include TSGrowableArray CBLPFile::s_blpFileLoadBuffer; @@ -259,7 +259,7 @@ int32_t CBLPFile::Lock2(const char* fileName, PIXEL_FORMAT format, uint32_t mipL switch (this->m_header.colorEncoding) { case COLOR_JPEG: - STORM_PANIC("%s: JPEG decompression not enabled", fileName); + SErrPrepareAppFatal(__FILE__, __LINE__); SErrDisplayAppFatal("%s: JPEG decompression not enabled", fileName); return 0; case COLOR_PAL: @@ -340,8 +340,9 @@ int32_t CBLPFile::LockChain2(const char* fileName, PIXEL_FORMAT format, MipBits* } int32_t CBLPFile::Open(const char* filename, int32_t a3) { - STORM_ASSERT(filename); - STORM_VALIDATE(filename, ERROR_INVALID_PARAMETER, 0); + STORM_VALIDATE_BEGIN; + STORM_VALIDATE(filename); + STORM_VALIDATE_END; this->m_inMemoryImage = nullptr; diff --git a/src/gx/texture/CTgaFile.cpp b/src/gx/texture/CTgaFile.cpp index 3680fcb..28afa8a 100644 --- a/src/gx/texture/CTgaFile.cpp +++ b/src/gx/texture/CTgaFile.cpp @@ -1,12 +1,15 @@ #include "gx/texture/CTgaFile.hpp" -#include +#include #include #include int32_t CTgaFile::Open(const char* filename, int32_t a3) { - STORM_VALIDATE_STRING(filename, ERROR_INVALID_PARAMETER, 0); + STORM_VALIDATE_BEGIN; + STORM_VALIDATE(filename); + STORM_VALIDATE(*filename); + STORM_VALIDATE_END; this->Close(); @@ -40,9 +43,15 @@ int32_t CTgaFile::Open(const char* filename, int32_t a3) { } // 3 pixels with alpha channel makes no sense - STORM_VALIDATE(!(this->m_header.bPixelDepth == 24 && this->m_header.desc.bAlphaChannelBits == 8), 0x8720012E, 0); + if (this->m_header.bPixelDepth == 24 && this->m_header.desc.bAlphaChannelBits == 8) { + SErrSetLastError(0x8720012E); + return 0; + } // 4 pixels with no alpha channel makes no sense - STORM_VALIDATE(!(this->m_header.bPixelDepth == 32 && this->m_header.desc.bAlphaChannelBits == 0), 0x8720012F, 0); + if (this->m_header.bPixelDepth == 32 && this->m_header.desc.bAlphaChannelBits == 0) { + SErrSetLastError(0x8720012F); + return 0; + } return 1; } @@ -123,7 +132,10 @@ void CTgaFile::SetTopDown(int32_t set) { return; } - STORM_VALIDATE(this->m_header.bImageType >= TGA_RLE_COLOR_MAPPED && this->m_header.bImageType <= TGA_RLE_BLACK_N_WHITE, 0xF7200083); + if (!(this->m_header.bImageType >= TGA_RLE_COLOR_MAPPED && this->m_header.bImageType <= TGA_RLE_BLACK_N_WHITE)) { + SErrSetLastError(0xF7200083); + return; + } auto newImage = static_cast(SMemAlloc(this->Bytes(), __FILE__, __LINE__, 0x0)); @@ -405,7 +417,10 @@ void CTgaFile::ConvertColorMapped(uint32_t flags) { } int32_t CTgaFile::ReadColorMappedImage(uint32_t flags) { - STORM_VALIDATE(this->m_header.bColorMapType, 0xF7200084, 0); + if (!this->m_header.bColorMapType) { + SErrSetLastError(0xF7200084); + return 0; + } int32_t status; @@ -421,8 +436,14 @@ int32_t CTgaFile::ReadColorMappedImage(uint32_t flags) { } int32_t CTgaFile::LoadImageData(uint32_t flags) { - STORM_VALIDATE(this->m_image == nullptr, ERROR_INVALID_PARAMETER, 1); - STORM_VALIDATE(this->m_file, 0xF720007E, 1); + if (this->m_image) { + SErrSetLastError(ERROR_INVALID_PARAMETER); + return 1; + } + if (!this->m_file) { + SErrSetLastError(0xF720007E); + return 1; + } this->m_imageBytes = this->Bytes(); diff --git a/src/model/CM2Cache.cpp b/src/model/CM2Cache.cpp index b4b223b..4cc1fc0 100644 --- a/src/model/CM2Cache.cpp +++ b/src/model/CM2Cache.cpp @@ -5,8 +5,7 @@ #include "util/Filesystem.hpp" #include "util/SFile.hpp" #include -#include -#include +#include #include #include @@ -36,8 +35,7 @@ CM2Shared* CM2Cache::CreateShared(const char* path, uint32_t flags) { SFile* fileptr; if (SFile::OpenEx(nullptr, convertedPath, (flags >> 2) & 1, &fileptr)) { - auto m = SMemAlloc(sizeof(CM2Shared), __FILE__, __LINE__, 0x0); - auto shared = new (m) CM2Shared(this); + auto shared = NEW(CM2Shared, this); if (shared->Load(fileptr, flags & 0x4, &v28)) { strcpy(shared->m_filePath, convertedPath); @@ -53,7 +51,7 @@ CM2Shared* CM2Cache::CreateShared(const char* path, uint32_t flags) { } SFile::Close(fileptr); - delete shared; + DEL(shared); } return nullptr; diff --git a/src/model/CMakeLists.txt b/src/model/CMakeLists.txt index 86f8a56..f34ac0f 100644 --- a/src/model/CMakeLists.txt +++ b/src/model/CMakeLists.txt @@ -16,6 +16,7 @@ target_link_libraries(model math util PUBLIC + bc common storm tempest diff --git a/src/model/Model2.cpp b/src/model/Model2.cpp index 31f012f..1d1d236 100644 --- a/src/model/Model2.cpp +++ b/src/model/Model2.cpp @@ -4,9 +4,8 @@ #include "console/CVar.hpp" #include "util/Filesystem.hpp" #include -#include #include -#include +#include #include static CVar* s_M2UseZFillVar; @@ -116,8 +115,7 @@ int32_t M2ConvertModelFileName(const char* source, char* dest, uint32_t a3, uint } CM2Scene* M2CreateScene() { - auto m = SMemAlloc(sizeof(CM2Scene), __FILE__, __LINE__, 0x0); - return new (m) CM2Scene(&CM2Cache::s_cache); + return NEW(CM2Scene, &CM2Cache::s_cache); } uint32_t M2GetCacheFlags() { diff --git a/src/net/CMakeLists.txt b/src/net/CMakeLists.txt index a3b011d..13f2a67 100644 --- a/src/net/CMakeLists.txt +++ b/src/net/CMakeLists.txt @@ -34,6 +34,7 @@ target_link_libraries(net client event PUBLIC + bc common storm ) diff --git a/src/net/connection/WowConnection.cpp b/src/net/connection/WowConnection.cpp index 85a9c50..54d5df2 100644 --- a/src/net/connection/WowConnection.cpp +++ b/src/net/connection/WowConnection.cpp @@ -2,10 +2,10 @@ #include "net/connection/WowConnectionNet.hpp" #include "net/connection/WowConnectionResponse.hpp" #include "util/HMAC.hpp" +#include #include #include #include -#include #include #include #include @@ -102,8 +102,7 @@ int32_t WowConnection::InitOsNet(bool (*fcn)(const NETADDR*), void (*threadinit) numThreads = std::min(numThreads, 32); - auto networkMem = SMemAlloc(sizeof(WowConnectionNet), __FILE__, __LINE__, 0x0); - auto network = new (networkMem) WowConnectionNet(numThreads, threadinit); + auto network = NEW(WowConnectionNet, numThreads, threadinit); WowConnection::s_network = network; WowConnection::s_network->PlatformInit(useEngine); @@ -182,8 +181,7 @@ void WowConnection::CheckAccept() { fcntl(sock, F_SETFL, O_NONBLOCK); #endif - auto connMem = SMemAlloc(sizeof(WowConnection), __FILE__, __LINE__, 0x0); - auto conn = new (connMem) WowConnection(sock, reinterpret_cast(&addr), this->m_response); + auto conn = NEW(WowConnection, sock, reinterpret_cast(&addr), this->m_response); conn->AddRef(); this->AddRef(); diff --git a/src/net/grunt/ClientLink.cpp b/src/net/grunt/ClientLink.cpp index a0182dc..fd6777d 100644 --- a/src/net/grunt/ClientLink.cpp +++ b/src/net/grunt/ClientLink.cpp @@ -4,8 +4,7 @@ #include "net/grunt/Command.hpp" #include "net/srp/SRP6_Random.hpp" #include -#include -#include +#include #include Grunt::Command Grunt::s_clientCommands[] = { @@ -381,8 +380,7 @@ void Grunt::ClientLink::Connect(const char* a2) { this->SetState(1); - auto connectionMem = SMemAlloc(sizeof(WowConnection), __FILE__, __LINE__, 0x0); - auto connection = new (connectionMem) WowConnection(this, nullptr); + auto connection = NEW(WowConnection, this, nullptr); this->m_connection = connection; this->m_connection->SetType(WOWC_TYPE_STREAM); diff --git a/src/net/login/GruntLogin.cpp b/src/net/login/GruntLogin.cpp index cdbb24c..b0b843e 100644 --- a/src/net/login/GruntLogin.cpp +++ b/src/net/login/GruntLogin.cpp @@ -2,8 +2,7 @@ #include "net/grunt/ClientLink.hpp" #include "net/login/LoginResponse.hpp" #include -#include -#include +#include #include GruntLogin::~GruntLogin() { @@ -75,7 +74,7 @@ void GruntLogin::GetLogonMethod() { auto passwordLen = SStrLen(this->m_password); memset(this->m_password, 0, passwordLen); - SMemFree(this->m_password, __FILE__, __LINE__, 0); + FREE(this->m_password); this->m_password = nullptr; } } @@ -108,8 +107,8 @@ void GruntLogin::GetVersionProof(const uint8_t* versionChallenge) { void GruntLogin::Init(LoginResponse* loginResponse) { this->m_loginResponse = loginResponse; - auto clientLinkMem = SMemAlloc(sizeof(Grunt::ClientLink), __FILE__, __LINE__, 0x0); - auto clientLink = new (clientLinkMem) Grunt::ClientLink(*this); + auto clientLink = NEW(Grunt::ClientLink, *this); + this->m_clientLink = clientLink; } diff --git a/src/net/login/Login.cpp b/src/net/login/Login.cpp index 1f3bfe2..ed5e38a 100644 --- a/src/net/login/Login.cpp +++ b/src/net/login/Login.cpp @@ -1,8 +1,8 @@ #include "net/login/Login.hpp" #include "net/login/LoginResponse.hpp" #include +#include #include -#include #include Login::~Login() { @@ -32,7 +32,7 @@ void Login::SetLogonCreds(const char* accountName, const char* password) { if (this->m_password) { memset(this->m_password, 0, SStrLen(this->m_password)); - SMemFree(this->m_password, __FILE__, __LINE__, 0x0); + FREE(this->m_password); } this->m_password = SStrDupA(password, __FILE__, __LINE__); diff --git a/src/sound/CMakeLists.txt b/src/sound/CMakeLists.txt index ada95dd..68ffe6d 100644 --- a/src/sound/CMakeLists.txt +++ b/src/sound/CMakeLists.txt @@ -13,6 +13,9 @@ target_link_libraries(sound PRIVATE ui util + PUBLIC + bc + storm ) if(WHOA_BUILD_FMOD) diff --git a/src/sound/SI2.cpp b/src/sound/SI2.cpp index 5d9974e..54d90a2 100644 --- a/src/sound/SI2.cpp +++ b/src/sound/SI2.cpp @@ -1,7 +1,7 @@ #include "sound/SI2.hpp" #include "ui/FrameScript.hpp" #include "console/CVar.hpp" -#include +#include #if defined(WHOA_BUILD_FMOD) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 9c10673..36cb404 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -23,6 +23,7 @@ target_link_libraries(ui net util PUBLIC + bc common storm tempest diff --git a/src/ui/CSimpleModelFFX.cpp b/src/ui/CSimpleModelFFX.cpp index 95b3f62..e9ed305 100644 --- a/src/ui/CSimpleModelFFX.cpp +++ b/src/ui/CSimpleModelFFX.cpp @@ -2,15 +2,14 @@ #include "gx/Draw.hpp" #include "ui/CRenderBatch.hpp" #include "ui/CSimpleModelFFXScript.hpp" -#include +#include int32_t CSimpleModelFFX::s_metatable; CSimpleFrame* CSimpleModelFFX::Create(CSimpleFrame* parent) { // TODO // auto m = CDataAllocator::GetData(CSimpleModelFFX::s_simpleModelFFXHeap, 0, __FILE__, __LINE__); - auto m = SMemAlloc(sizeof(CSimpleModelFFX), __FILE__, __LINE__, 0x0); - return new (m) CSimpleModelFFX(parent); + return NEW(CSimpleModelFFX, parent); } void CSimpleModelFFX::Render(void* arg) { diff --git a/src/ui/LuaMemory.cpp b/src/ui/LuaMemory.cpp index d9c6c69..5687078 100644 --- a/src/ui/LuaMemory.cpp +++ b/src/ui/LuaMemory.cpp @@ -1,9 +1,8 @@ #include "ui/LuaMemory.hpp" #include "ui/FrameScript.hpp" #include -#include #include -#include +#include void* luaM_initPool() { void* m = SMemAlloc(sizeof(MemPool*) * 9, __FILE__, __LINE__, 0x0); diff --git a/src/util/SFile.cpp b/src/util/SFile.cpp index 5cc0d76..fdac653 100644 --- a/src/util/SFile.cpp +++ b/src/util/SFile.cpp @@ -1,11 +1,11 @@ #include "util/SFile.hpp" #include #include +#include #include #include -#include #include -#include +#include #include "util/Filesystem.hpp" static char s_basepath[STORM_MAX_PATH] = { 0 }; @@ -25,7 +25,7 @@ int32_t SFile::Close(SFile* file) { STORM_ASSERT(0); } - delete file; + DEL(file); return 1; } @@ -150,7 +150,9 @@ int32_t SFile::OpenEx(SArchive* archive, const char* filename, uint32_t flags, S void* filehandle; HANDLE handle; - uint32_t openflags = BC_FILE_OPEN_MUST_EXIST | BC_FILE_OPEN_SHARE_READ | BC_FILE_OPEN_READ; + + using Mode = Blizzard::File::Mode; + uint32_t openflags = Mode::mustexist | Mode::shareread | Mode::read; Blizzard::File::StreamRecord* stream; // Attempt to open plain file first @@ -167,7 +169,7 @@ int32_t SFile::OpenEx(SArchive* archive, const char* filename, uint32_t flags, S return 0; } - *file = new SFile; + *file = NEW(SFile); (*file)->m_handle = filehandle; (*file)->m_type = filetype; @@ -212,7 +214,9 @@ int32_t SFile::Read(SFile* file, void* buffer, size_t bytestoread, size_t* bytes switch (file->m_type) { case SFILE_PLAIN: { auto stream = reinterpret_cast(file->m_handle); - Blizzard::File::Read(stream, buffer, bytestoread, bytesread); + auto count = static_cast(bytestoread); + Blizzard::File::Read(stream, buffer, &count); + *bytesread = static_cast(count); return 1; } case SFILE_PAQ: {