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.World/DataInputStream.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Minecraft.World/DataInputStream.cpp') diff --git a/Minecraft.World/DataInputStream.cpp b/Minecraft.World/DataInputStream.cpp index 18deed39..4e4f5cd1 100644 --- a/Minecraft.World/DataInputStream.cpp +++ b/Minecraft.World/DataInputStream.cpp @@ -92,12 +92,12 @@ bool DataInputStream::readBoolean() //the 8-bit value read. byte DataInputStream::readByte() { - return (byte) stream->read(); + return static_cast(stream->read()); } unsigned char DataInputStream::readUnsignedByte() { - return (unsigned char) stream->read(); + return static_cast(stream->read()); } //Reads two input bytes and returns a char value. Let a be the first byte read and b be the second byte. The value returned is: @@ -110,7 +110,7 @@ wchar_t DataInputStream::readChar() { int a = stream->read(); int b = stream->read(); - return (wchar_t)((a << 8) | (b & 0xff)); + return static_cast((a << 8) | (b & 0xff)); } //Reads some bytes from an input stream and stores them into the buffer array b. The number of bytes read is equal to the length of b. @@ -254,14 +254,14 @@ short DataInputStream::readShort() { int a = stream->read(); int b = stream->read(); - return (short)((a << 8) | (b & 0xff)); + return static_cast((a << 8) | (b & 0xff)); } unsigned short DataInputStream::readUnsignedShort() { int a = stream->read(); int b = stream->read(); - return (unsigned short)((a << 8) | (b & 0xff)); + return static_cast((a << 8) | (b & 0xff)); } //Reads in a string that has been encoded using a modified UTF-8 format. The general contract of readUTF is that it reads a representation @@ -301,7 +301,7 @@ wstring DataInputStream::readUTF() wstring outputString; int a = stream->read(); int b = stream->read(); - unsigned short UTFLength = (unsigned short) (((a & 0xff) << 8) | (b & 0xff)); + unsigned short UTFLength = static_cast(((a & 0xff) << 8) | (b & 0xff)); //// 4J Stu - I decided while writing DataOutputStream that we didn't need to bother using the UTF8 format //// used in the java libs, and just write in/out as wchar_t all the time @@ -343,7 +343,7 @@ wstring DataInputStream::readUTF() else if( (firstByte & 0x80) == 0x00 ) { // One byte UTF - wchar_t readChar = (wchar_t)firstByte; + wchar_t readChar = static_cast(firstByte); outputString.push_back( readChar ); continue; } @@ -374,7 +374,7 @@ wstring DataInputStream::readUTF() break; } - wchar_t readChar = (wchar_t)( ((firstByte& 0x1F) << 6) | (secondByte & 0x3F) ); + wchar_t readChar = static_cast(((firstByte & 0x1F) << 6) | (secondByte & 0x3F)); outputString.push_back( readChar ); continue; } @@ -422,7 +422,7 @@ wstring DataInputStream::readUTF() break; } - wchar_t readChar = (wchar_t)(((firstByte & 0x0F) << 12) | ((secondByte & 0x3F) << 6) | (thirdByte & 0x3F)); + wchar_t readChar = static_cast(((firstByte & 0x0F) << 12) | ((secondByte & 0x3F) << 6) | (thirdByte & 0x3F)); outputString.push_back( readChar ); continue; } -- cgit v1.2.3