From d79b1ba555a32d6f0616374afc032d196e4096e9 Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Tue, 3 Mar 2026 19:33:12 -0600 Subject: [PATCH] fix: resolve a lot of conversion warnings --- .../Common/Colours/ColourTable.cpp | 2 +- Minecraft.Client/Common/Colours/ColourTable.h | 2 +- Minecraft.Client/Common/DLC/DLCManager.cpp | 2 +- Minecraft.Client/Common/DLC/DLCManager.h | 2 +- .../Common/GameRules/GameRuleManager.cpp | 2 +- .../Common/GameRules/GameRuleManager.h | 4 +- Minecraft.Client/Extrax64Stubs.cpp | 4 +- Minecraft.Client/Linux/Stubs/winapi_stubs.h | 10 ++++ Minecraft.Client/Textures.cpp | 2 +- Minecraft.Client/Textures.h | 2 +- Minecraft.World/CompoundTag.h | 52 +++++++++---------- Minecraft.World/Recipes.cpp | 6 +-- Minecraft.World/Socket.cpp | 9 ++-- Minecraft.World/Tag.cpp | 2 +- Minecraft.World/Tag.h | 2 +- Minecraft.World/x64headers/extraX64.h | 6 +-- 16 files changed, 60 insertions(+), 49 deletions(-) diff --git a/Minecraft.Client/Common/Colours/ColourTable.cpp b/Minecraft.Client/Common/Colours/ColourTable.cpp index 1901bf9ed..57bbeb9d4 100644 --- a/Minecraft.Client/Common/Colours/ColourTable.cpp +++ b/Minecraft.Client/Common/Colours/ColourTable.cpp @@ -4,7 +4,7 @@ unordered_map ColourTable::s_colourNamesMap; -wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] = +const wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] = { L"NOTSET", diff --git a/Minecraft.Client/Common/Colours/ColourTable.h b/Minecraft.Client/Common/Colours/ColourTable.h index 8e0a348c0..af99a8ed5 100644 --- a/Minecraft.Client/Common/Colours/ColourTable.h +++ b/Minecraft.Client/Common/Colours/ColourTable.h @@ -5,7 +5,7 @@ class ColourTable private: unsigned int m_colourValues[eMinecraftColour_COUNT]; - static wchar_t *ColourTableElements[eMinecraftColour_COUNT]; + static const wchar_t *ColourTableElements[eMinecraftColour_COUNT]; static unordered_map s_colourNamesMap; public: diff --git a/Minecraft.Client/Common/DLC/DLCManager.cpp b/Minecraft.Client/Common/DLC/DLCManager.cpp index 553ddd6e9..2dfb0d45a 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Common/DLC/DLCManager.cpp @@ -7,7 +7,7 @@ #include "../../Minecraft.h" #include "../../TexturePackRepository.h" -WCHAR *DLCManager::wchTypeNamesA[]= +const WCHAR *DLCManager::wchTypeNamesA[]= { L"DISPLAYNAME", L"THEMENAME", diff --git a/Minecraft.Client/Common/DLC/DLCManager.h b/Minecraft.Client/Common/DLC/DLCManager.h index 55a62312b..1021b6641 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.h +++ b/Minecraft.Client/Common/DLC/DLCManager.h @@ -48,7 +48,7 @@ public: e_DLCParamType_Max, }; - static WCHAR *wchTypeNamesA[e_DLCParamType_Max]; + const static WCHAR *wchTypeNamesA[e_DLCParamType_Max]; private: vector m_packs; diff --git a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp index 347fe9ec1..0f2bc6dab 100644 --- a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp +++ b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp @@ -12,7 +12,7 @@ #include "ConsoleGameRules.h" #include "GameRuleManager.h" -WCHAR *GameRuleManager::wchTagNameA[] = +const WCHAR *GameRuleManager::wchTagNameA[] = { L"", // eGameRuleType_Root L"MapOptions", // eGameRuleType_LevelGenerationOptions diff --git a/Minecraft.Client/Common/GameRules/GameRuleManager.h b/Minecraft.Client/Common/GameRules/GameRuleManager.h index e9e983b85..3f446e842 100644 --- a/Minecraft.Client/Common/GameRules/GameRuleManager.h +++ b/Minecraft.Client/Common/GameRules/GameRuleManager.h @@ -24,8 +24,8 @@ class WstringLookup; class GameRuleManager { public: - static WCHAR *wchTagNameA[ConsoleGameRules::eGameRuleType_Count]; - static WCHAR *wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count]; + static const WCHAR *wchTagNameA[ConsoleGameRules::eGameRuleType_Count]; + static const WCHAR *wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count]; static const short version_number = 2; diff --git a/Minecraft.Client/Extrax64Stubs.cpp b/Minecraft.Client/Extrax64Stubs.cpp index 1bb6c3d53..befb42557 100644 --- a/Minecraft.Client/Extrax64Stubs.cpp +++ b/Minecraft.Client/Extrax64Stubs.cpp @@ -67,10 +67,10 @@ void XShowAchievementsUI(int i) {} DWORD XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE Mode) { return 0; } #ifndef _DURANGO -void PIXAddNamedCounter(int a, char *b, ...) {} +void PIXAddNamedCounter(int a, const char *b, ...) {} //#define PS3_USE_PIX_EVENTS //#define PS4_USE_PIX_EVENTS -void PIXBeginNamedEvent(int a, char *b, ...) +void PIXBeginNamedEvent(int a, const char *b, ...) { #ifdef PS4_USE_PIX_EVENTS char buf[512]; diff --git a/Minecraft.Client/Linux/Stubs/winapi_stubs.h b/Minecraft.Client/Linux/Stubs/winapi_stubs.h index 93d0428c3..c6a792882 100644 --- a/Minecraft.Client/Linux/Stubs/winapi_stubs.h +++ b/Minecraft.Client/Linux/Stubs/winapi_stubs.h @@ -3,6 +3,8 @@ #pragma once +#include + #define TRUE true #define FALSE false #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length)) @@ -731,5 +733,13 @@ static inline HANDLE CreateEvent(int manual_reset, int initial_state) { static inline HMODULE GetModuleHandle(LPCSTR lpModuleName) { return 0; } +static inline LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) { + assert(0 && "FIXME: implement VirtualAlloc"); +} + +static inline BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) { + assert(0 && "FIXME: implement VirtualFree"); +} + #endif // WINAPISTUBS_H diff --git a/Minecraft.Client/Textures.cpp b/Minecraft.Client/Textures.cpp index e0b05bfb5..cf4542833 100644 --- a/Minecraft.Client/Textures.cpp +++ b/Minecraft.Client/Textures.cpp @@ -21,7 +21,7 @@ bool Textures::MIPMAP = true; C4JRender::eTextureFormat Textures::TEXTURE_FORMAT = C4JRender::TEXTURE_FORMAT_RxGyBzAw; int Textures::preLoadedIdx[TN_COUNT]; -wchar_t *Textures::preLoaded[TN_COUNT] = +const wchar_t *Textures::preLoaded[TN_COUNT] = { L"%blur%misc/pumpkinblur", // L"%blur%/misc/vignette", // Not currently used diff --git a/Minecraft.Client/Textures.h b/Minecraft.Client/Textures.h index 730b09f01..fcd47f907 100644 --- a/Minecraft.Client/Textures.h +++ b/Minecraft.Client/Textures.h @@ -205,7 +205,7 @@ public: static C4JRender::eTextureFormat TEXTURE_FORMAT; private: - static wchar_t *preLoaded[TN_COUNT]; + static const wchar_t *preLoaded[TN_COUNT]; static int preLoadedIdx[TN_COUNT]; unordered_map idMap; diff --git a/Minecraft.World/CompoundTag.h b/Minecraft.World/CompoundTag.h index ebc4a8ecb..e03ac2e83 100644 --- a/Minecraft.World/CompoundTag.h +++ b/Minecraft.World/CompoundTag.h @@ -60,145 +60,145 @@ public: return TAG_Compound; } - void put(wchar_t *name, Tag *tag) + void put(const wchar_t *name, Tag *tag) { tags[name] = tag->setName(wstring( name )); } - void putByte(wchar_t * name, byte value) + void putByte(const wchar_t * name, byte value) { tags[name] = (new ByteTag(name,value)); } - void putShort(wchar_t * name, short value) + void putShort(const wchar_t * name, short value) { tags[name] = (new ShortTag(name,value)); } - void putInt(wchar_t * name, int value) + void putInt(const wchar_t * name, int value) { tags[name] = (new IntTag(name,value)); } - void putLong(wchar_t * name, __int64 value) + void putLong(const wchar_t * name, __int64 value) { tags[name] = (new LongTag(name,value)); } - void putFloat(wchar_t * name, float value) + void putFloat(const wchar_t * name, float value) { tags[name] = (new FloatTag(name,value)); } - void putDouble(wchar_t * name, double value) + void putDouble(const wchar_t * name, double value) { tags[name] = (new DoubleTag(name,value)); } - void putString(wchar_t *name, const wstring& value) + void putString(const wchar_t *name, const wstring& value) { tags[name] = (new StringTag(name,value)); } - void putByteArray(wchar_t * name, byteArray value) + void putByteArray(const wchar_t * name, byteArray value) { tags[name] = (new ByteArrayTag(name,value)); } - void putIntArray(wchar_t * name, intArray value) + void putIntArray(const wchar_t * name, intArray value) { tags[name] = (new IntArrayTag(name, value)); } - void putCompound(wchar_t * name, CompoundTag *value) + void putCompound(const wchar_t * name, CompoundTag *value) { tags[name] = value->setName( wstring( name ) ); } - void putBoolean(wchar_t * string, bool val) + void putBoolean(const wchar_t * string, bool val) { putByte(string, val?static_cast(1):static_cast(0)); } - Tag *get(wchar_t *name) + Tag *get(const wchar_t *name) { AUTO_VAR(it, tags.find(name)); if(it != tags.end()) return it->second; return NULL; } - bool contains(wchar_t * name) + bool contains(const wchar_t * name) { return tags.find(name) != tags.end(); } - byte getByte(wchar_t * name) + byte getByte(const wchar_t * name) { if (tags.find(name) == tags.end()) return (byte)0; return ((ByteTag *) tags[name])->data; } - short getShort(wchar_t * name) + short getShort(const wchar_t * name) { if (tags.find(name) == tags.end()) return (short)0; return ((ShortTag *) tags[name])->data; } - int getInt(wchar_t * name) + int getInt(const wchar_t * name) { if (tags.find(name) == tags.end()) return (int)0; return ((IntTag *) tags[name])->data; } - __int64 getLong(wchar_t * name) + __int64 getLong(const wchar_t * name) { if (tags.find(name) == tags.end()) return (__int64)0; return ((LongTag *) tags[name])->data; } - float getFloat(wchar_t * name) + float getFloat(const wchar_t * name) { if (tags.find(name) == tags.end()) return (float)0; return ((FloatTag *) tags[name])->data; } - double getDouble(wchar_t * name) + double getDouble(const wchar_t * name) { if (tags.find(name) == tags.end()) return (double)0; return ((DoubleTag *) tags[name])->data; } - wstring getString(wchar_t * name) + wstring getString(const wchar_t * name) { if (tags.find(name) == tags.end()) return wstring( L"" ); return ((StringTag *) tags[name])->data; } - byteArray getByteArray(wchar_t * name) + byteArray getByteArray(const wchar_t * name) { if (tags.find(name) == tags.end()) return byteArray(); return ((ByteArrayTag *) tags[name])->data; } - intArray getIntArray(wchar_t * name) + intArray getIntArray(const wchar_t * name) { if (tags.find(name) == tags.end()) return intArray(0); return ((IntArrayTag *) tags[name])->data; } - CompoundTag *getCompound(wchar_t * name) + CompoundTag *getCompound(const wchar_t * name) { if (tags.find(name) == tags.end()) return new CompoundTag(name); return (CompoundTag *) tags[name]; } - ListTag *getList(wchar_t * name) + ListTag *getList(const wchar_t * name) { if (tags.find(name) == tags.end()) return new ListTag(name); return (ListTag *) tags[name]; } - bool getBoolean(wchar_t *string) + bool getBoolean(const wchar_t *string) { return getByte(string) != static_cast(0); } diff --git a/Minecraft.World/Recipes.cpp b/Minecraft.World/Recipes.cpp index 93be1dfb9..0e65bd26d 100644 --- a/Minecraft.World/Recipes.cpp +++ b/Minecraft.World/Recipes.cpp @@ -997,7 +997,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...) break; case L'c': - wchFrom=va_arg(vl,wchar_t); + wchFrom=(wchar_t)va_arg(vl,int); break; case L'z': pItemInstance=va_arg(vl,ItemInstance *); @@ -1014,7 +1014,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...) mappings->insert(myMap::value_type(wchFrom,pItemInstance)); break; case L'g': - wchFrom=va_arg(vl,wchar_t); + wchFrom=(wchar_t)va_arg(vl,int); switch(wchFrom) { // case L'W': @@ -1112,7 +1112,7 @@ void Recipes::addShapelessRecipy(ItemInstance *result,... ) ingredients->push_back(new ItemInstance(pTile)); break; case L'g': - wchFrom=va_arg(vl,wchar_t); + wchFrom=(wchar_t)va_arg(vl,int); switch(wchFrom) { diff --git a/Minecraft.World/Socket.cpp b/Minecraft.World/Socket.cpp index f0b05208a..3dfe6cd0b 100644 --- a/Minecraft.World/Socket.cpp +++ b/Minecraft.World/Socket.cpp @@ -6,9 +6,6 @@ #include "../Minecraft.Client/ServerConnection.h" #include #include "../Minecraft.Client/PS3/PS3Extras/ShutdownManager.h" -#include "../Minecraft.Client/Windows64/Windows64_App.h" - -extern CConsoleMinecraftApp app; // This current socket implementation is for the creation of a single local link. 2 sockets can be created, one for either end of this local // link, the end (0 or 1) is passed as a parameter to the ctor. @@ -277,6 +274,7 @@ int Socket::SocketInputStreamLocal::read() } Sleep(1); } + return -1; } // Try and get an input array of bytes, blocking until enough bytes are available @@ -306,6 +304,7 @@ int Socket::SocketInputStreamLocal::read(byteArray b, unsigned int offset, unsig } Sleep(1); } + return -1; } void Socket::SocketInputStreamLocal::close() @@ -391,6 +390,7 @@ int Socket::SocketInputStreamNetwork::read() } Sleep(1); } + return -1; } // Try and get an input array of bytes, blocking until enough bytes are available @@ -420,6 +420,7 @@ int Socket::SocketInputStreamNetwork::read(byteArray b, unsigned int offset, uns } Sleep(1); } + return -1; } void Socket::SocketInputStreamNetwork::close() @@ -530,4 +531,4 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(byteArray b, unsigned int void Socket::SocketOutputStreamNetwork::close() { m_streamOpen = false; -} +} \ No newline at end of file diff --git a/Minecraft.World/Tag.cpp b/Minecraft.World/Tag.cpp index 975d27089..2f8edf225 100644 --- a/Minecraft.World/Tag.cpp +++ b/Minecraft.World/Tag.cpp @@ -149,7 +149,7 @@ Tag *Tag::newTag(byte type, const wstring &name) return NULL; } -wchar_t *Tag::getTagName(byte type) +const wchar_t *Tag::getTagName(byte type) { switch (type) { diff --git a/Minecraft.World/Tag.h b/Minecraft.World/Tag.h index 7b4ec38e8..503657461 100644 --- a/Minecraft.World/Tag.h +++ b/Minecraft.World/Tag.h @@ -38,7 +38,7 @@ public: static Tag *readNamedTag(DataInput *dis); static void writeNamedTag(Tag *tag, DataOutput *dos); static Tag *newTag(byte type, const wstring &name); - static wchar_t *getTagName(byte type); + static const wchar_t *getTagName(byte type); virtual ~Tag() {} virtual bool equals(Tag *obj); // 4J Brought forward from 1.2 virtual Tag *copy() = 0; // 4J Brought foward from 1.2 diff --git a/Minecraft.World/x64headers/extraX64.h b/Minecraft.World/x64headers/extraX64.h index c4051728c..2b5925749 100644 --- a/Minecraft.World/x64headers/extraX64.h +++ b/Minecraft.World/x64headers/extraX64.h @@ -318,10 +318,10 @@ public: #define PIXSetMarkerDeprecated(a, b, ...) PIXSetMarker(a, L ## b, __VA_ARGS__) #define PIXAddNamedCounter(a, b) PIXReportCounter( L ## b, a) #else -void PIXAddNamedCounter(int a, char *b, ...); -void PIXBeginNamedEvent(int a, char *b, ...); +void PIXAddNamedCounter(int a, const char *b, ...); +void PIXBeginNamedEvent(int a, const char *b, ...); void PIXEndNamedEvent(); -void PIXSetMarkerDeprecated(int a, char *b, ...); +void PIXSetMarkerDeprecated(int a, const char *b, ...); #endif void XSetThreadProcessor(HANDLE a, int b);