From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: Modernize project codebase (#906) * Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR --- Minecraft.Client/Tesselator.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'Minecraft.Client/Tesselator.cpp') diff --git a/Minecraft.Client/Tesselator.cpp b/Minecraft.Client/Tesselator.cpp index 7bae7aca..b70ec983 100644 --- a/Minecraft.Client/Tesselator.cpp +++ b/Minecraft.Client/Tesselator.cpp @@ -28,7 +28,7 @@ DWORD Tesselator::tlsIdx = TlsAlloc(); Tesselator *Tesselator::getInstance() { - return (Tesselator *)TlsGetValue(tlsIdx); + return static_cast(TlsGetValue(tlsIdx)); } void Tesselator::CreateNewThreadStorage(int bytes) @@ -179,18 +179,18 @@ void Tesselator::end() } #else - RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_COMPRESSED, C4JRender::PIXEL_SHADER_TYPE_STANDARD); + RenderManager.DrawVertices(static_cast(mode),vertexCount,_array->data,C4JRender::VERTEX_TYPE_COMPRESSED, C4JRender::PIXEL_SHADER_TYPE_STANDARD); #endif } else { if( useProjectedTexturePixelShader ) { - RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, C4JRender::PIXEL_SHADER_TYPE_PROJECTION); + RenderManager.DrawVertices(static_cast(mode),vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, C4JRender::PIXEL_SHADER_TYPE_PROJECTION); } else { - RenderManager.DrawVertices((C4JRender::ePrimitiveType)mode,vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, C4JRender::PIXEL_SHADER_TYPE_STANDARD); + RenderManager.DrawVertices(static_cast(mode),vertexCount,_array->data,C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, C4JRender::PIXEL_SHADER_TYPE_STANDARD); } } #endif @@ -295,12 +295,12 @@ void Tesselator::tex2(int tex2) void Tesselator::color(float r, float g, float b) { - color((int) (r * 255), (int) (g * 255), (int) (b * 255)); + color(static_cast(r * 255), static_cast(g * 255), static_cast(b * 255)); } void Tesselator::color(float r, float g, float b, float a) { - color((int) (r * 255), (int) (g * 255), (int) (b * 255), (int) (a * 255)); + color(static_cast(r * 255), static_cast(g * 255), static_cast(b * 255), static_cast(a * 255)); } void Tesselator::color(int r, int g, int b) @@ -749,7 +749,7 @@ void Tesselator::vertex(float x, float y, float z) // see comments in packCompactQuad() for exact format if( useCompactFormat360 ) { - unsigned int ucol = (unsigned int)col; + unsigned int ucol = static_cast(col); #ifdef _XBOX // Pack as 4:4:4 RGB_ @@ -774,7 +774,7 @@ void Tesselator::vertex(float x, float y, float z) unsigned short packedcol = ((col & 0xf8000000 ) >> 16 ) | ((col & 0x00fc0000 ) >> 13 ) | ((col & 0x0000f800 ) >> 11 ); - int ipackedcol = ((int)packedcol) & 0xffff; // 0 to 65535 range + int ipackedcol = static_cast(packedcol) & 0xffff; // 0 to 65535 range ipackedcol -= 32768; // -32768 to 32767 range ipackedcol &= 0xffff; @@ -824,12 +824,12 @@ void Tesselator::vertex(float x, float y, float z) p += 4; #else - pShortData[0] = (((int)((x + xo ) * 1024.0f))&0xffff); - pShortData[1] = (((int)((y + yo ) * 1024.0f))&0xffff); - pShortData[2] = (((int)((z + zo ) * 1024.0f))&0xffff); + pShortData[0] = (static_cast((x + xo) * 1024.0f)&0xffff); + pShortData[1] = (static_cast((y + yo) * 1024.0f)&0xffff); + pShortData[2] = (static_cast((z + zo) * 1024.0f)&0xffff); pShortData[3] = ipackedcol; - pShortData[4] = (((int)(uu * 8192.0f))&0xffff); - pShortData[5] = (((int)(v * 8192.0f))&0xffff); + pShortData[4] = (static_cast(uu * 8192.0f)&0xffff); + pShortData[5] = (static_cast(v * 8192.0f)&0xffff); int16_t u2 = ((int16_t*)&_tex2)[0]; int16_t v2 = ((int16_t*)&_tex2)[1]; #if defined _XBOX_ONE || defined __ORBIS__ @@ -1040,9 +1040,9 @@ void Tesselator::normal(float x, float y, float z) int8_t zz = (int8_t) (z * 127); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); #else - byte xx = (byte) (x * 127); - byte yy = (byte) (y * 127); - byte zz = (byte) (z * 127); + byte xx = static_cast(x * 127); + byte yy = static_cast(y * 127); + byte zz = static_cast(z * 127); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); #endif } -- cgit v1.2.3