win cpp23 compat: Minecraft.Client

This commit is contained in:
VivyaCC
2026-03-06 23:25:57 +01:00
committed by void_17
parent 6dfdd90328
commit 52b1882f13
20 changed files with 96 additions and 91 deletions

View File

@@ -103,7 +103,7 @@ char SoundEngine::m_szRedistName[]={"redist"};
#endif #endif
char *SoundEngine::m_szStreamFileA[eStream_Max]= const char *SoundEngine::m_szStreamFileA[eStream_Max]=
{ {
"calm1", "calm1",
"calm2", "calm2",

View File

@@ -151,7 +151,7 @@ private:
static char m_szSoundPath[]; static char m_szSoundPath[];
static char m_szMusicPath[]; static char m_szMusicPath[];
static char m_szRedistName[]; static char m_szRedistName[];
static char *m_szStreamFileA[eStream_Max]; static const char *m_szStreamFileA[eStream_Max];
AUDIO_LISTENER m_ListenerA[MAX_LOCAL_PLAYERS]; AUDIO_LISTENER m_ListenerA[MAX_LOCAL_PLAYERS];
int m_validListenerCount; int m_validListenerCount;

View File

@@ -4,7 +4,7 @@
unordered_map<wstring,eMinecraftColour> ColourTable::s_colourNamesMap; unordered_map<wstring,eMinecraftColour> ColourTable::s_colourNamesMap;
wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] = const wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] =
{ {
L"NOTSET", L"NOTSET",

View File

@@ -5,7 +5,7 @@ class ColourTable
private: private:
unsigned int m_colourValues[eMinecraftColour_COUNT]; unsigned int m_colourValues[eMinecraftColour_COUNT];
static wchar_t *ColourTableElements[eMinecraftColour_COUNT]; static const wchar_t *ColourTableElements[eMinecraftColour_COUNT];
static unordered_map<wstring,eMinecraftColour> s_colourNamesMap; static unordered_map<wstring,eMinecraftColour> s_colourNamesMap;
public: public:

View File

@@ -26,7 +26,7 @@ PBYTE DLCAudioFile::getData(DWORD &dwBytes)
return m_pbData; return m_pbData;
} }
WCHAR *DLCAudioFile::wchTypeNamesA[]= const WCHAR *DLCAudioFile::wchTypeNamesA[]=
{ {
L"CUENAME", L"CUENAME",
L"CREDIT", L"CREDIT",

View File

@@ -28,7 +28,7 @@ public:
e_AudioParamType_Max, e_AudioParamType_Max,
}; };
static WCHAR *wchTypeNamesA[e_AudioParamType_Max]; static const WCHAR *wchTypeNamesA[e_AudioParamType_Max];
DLCAudioFile(const wstring &path); DLCAudioFile(const wstring &path);

View File

@@ -7,7 +7,7 @@
#include "..\..\Minecraft.h" #include "..\..\Minecraft.h"
#include "..\..\TexturePackRepository.h" #include "..\..\TexturePackRepository.h"
WCHAR *DLCManager::wchTypeNamesA[]= const WCHAR *DLCManager::wchTypeNamesA[]=
{ {
L"DISPLAYNAME", L"DISPLAYNAME",
L"THEMENAME", L"THEMENAME",

View File

@@ -48,7 +48,7 @@ public:
e_DLCParamType_Max, e_DLCParamType_Max,
}; };
static WCHAR *wchTypeNamesA[e_DLCParamType_Max]; static const WCHAR *wchTypeNamesA[e_DLCParamType_Max];
private: private:
vector<DLCPack *> m_packs; vector<DLCPack *> m_packs;

View File

@@ -12,7 +12,7 @@
#include "ConsoleGameRules.h" #include "ConsoleGameRules.h"
#include "GameRuleManager.h" #include "GameRuleManager.h"
WCHAR *GameRuleManager::wchTagNameA[] = const WCHAR *GameRuleManager::wchTagNameA[] =
{ {
L"", // eGameRuleType_Root L"", // eGameRuleType_Root
L"MapOptions", // eGameRuleType_LevelGenerationOptions L"MapOptions", // eGameRuleType_LevelGenerationOptions
@@ -34,7 +34,7 @@ WCHAR *GameRuleManager::wchTagNameA[] =
L"UpdatePlayer", // eGameRuleType_UpdatePlayerRule L"UpdatePlayer", // eGameRuleType_UpdatePlayerRule
}; };
WCHAR *GameRuleManager::wchAttrNameA[] = const WCHAR *GameRuleManager::wchAttrNameA[] =
{ {
L"descriptionName", // eGameRuleAttr_descriptionName L"descriptionName", // eGameRuleAttr_descriptionName
L"promptName", // eGameRuleAttr_promptName L"promptName", // eGameRuleAttr_promptName

View File

@@ -24,8 +24,8 @@ class WstringLookup;
class GameRuleManager class GameRuleManager
{ {
public: public:
static WCHAR *wchTagNameA[ConsoleGameRules::eGameRuleType_Count]; static const WCHAR *wchTagNameA[ConsoleGameRules::eGameRuleType_Count];
static WCHAR *wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count]; static const WCHAR *wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count];
static const short version_number = 2; static const short version_number = 2;

View File

@@ -1051,7 +1051,8 @@ void UIScene_LoadOrJoinMenu::GetSaveInfo()
m_pSaveDetails=StorageManager.ReturnSavesInfo(); m_pSaveDetails=StorageManager.ReturnSavesInfo();
if(m_pSaveDetails==NULL) if(m_pSaveDetails==NULL)
{ {
C4JStorage::ESaveGameState eSGIStatus= StorageManager.GetSavesInfo(m_iPad,NULL,this,"save"); char savename[] = "save";
C4JStorage::ESaveGameState eSGIStatus = StorageManager.GetSavesInfo(m_iPad, NULL, this, savename);
} }
#if TO_BE_IMPLEMENTED #if TO_BE_IMPLEMENTED

View File

@@ -13,7 +13,7 @@
//#define SKIN_SELECT_PACK_PLAYER_CUSTOM 1 //#define SKIN_SELECT_PACK_PLAYER_CUSTOM 1
#define SKIN_SELECT_MAX_DEFAULTS 2 #define SKIN_SELECT_MAX_DEFAULTS 2
WCHAR *UIScene_SkinSelectMenu::wchDefaultNamesA[]= const WCHAR *UIScene_SkinSelectMenu::wchDefaultNamesA[]=
{ {
L"USE LOCALISED VERSION", // Server selected L"USE LOCALISED VERSION", // Server selected
L"Steve", L"Steve",

View File

@@ -6,7 +6,7 @@
class UIScene_SkinSelectMenu : public UIScene class UIScene_SkinSelectMenu : public UIScene
{ {
private: private:
static WCHAR *wchDefaultNamesA[eDefaultSkins_Count]; static const WCHAR *wchDefaultNamesA[eDefaultSkins_Count];
// 4J Stu - How many to show on each side of the main control // 4J Stu - How many to show on each side of the main control
static const BYTE sidePreviewControls = 4; static const BYTE sidePreviewControls = 4;

View File

@@ -2,7 +2,7 @@
class Chunk; class Chunk;
class Mob; class Mob;
class DirtyChunkSorter : public std::binary_function<const Chunk *,const Chunk *,bool> class DirtyChunkSorter
{ {
private: private:
shared_ptr<LivingEntity> cameraEntity; shared_ptr<LivingEntity> cameraEntity;

View File

@@ -2,7 +2,7 @@
class Entity; class Entity;
class Chunk; class Chunk;
class DistanceChunkSorter : public std::binary_function<const Chunk *,const Chunk *,bool> class DistanceChunkSorter
{ {
private: private:
double ix, iy, iz; double ix, iy, iz;

View File

@@ -24,7 +24,7 @@ bool Textures::MIPMAP = true;
C4JRender::eTextureFormat Textures::TEXTURE_FORMAT = C4JRender::TEXTURE_FORMAT_RxGyBzAw; C4JRender::eTextureFormat Textures::TEXTURE_FORMAT = C4JRender::TEXTURE_FORMAT_RxGyBzAw;
int Textures::preLoadedIdx[TN_COUNT]; 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/pumpkinblur",
// L"%blur%/misc/vignette", // Not currently used // L"%blur%/misc/vignette", // Not currently used
@@ -1520,7 +1520,7 @@ TEXTURE_NAME TUImages[] =
}; };
// This is for any TU textures that aren't part of our enum indexed preload set // This is for any TU textures that aren't part of our enum indexed preload set
wchar_t *TUImagePaths[] = const wchar_t *TUImagePaths[] =
{ {
L"font/Default", L"font/Default",
L"font/Mojangles_7", L"font/Mojangles_7",
@@ -1579,7 +1579,7 @@ TEXTURE_NAME OriginalImages[] =
TN_COUNT TN_COUNT
}; };
wchar_t *OriginalImagesPaths[] = const wchar_t *OriginalImagesPaths[] =
{ {
L"misc/watercolor.png", L"misc/watercolor.png",

View File

@@ -243,7 +243,7 @@ public:
static C4JRender::eTextureFormat TEXTURE_FORMAT; static C4JRender::eTextureFormat TEXTURE_FORMAT;
private: private:
static wchar_t *preLoaded[TN_COUNT]; static const wchar_t *preLoaded[TN_COUNT];
static int preLoadedIdx[TN_COUNT]; static int preLoadedIdx[TN_COUNT];
unordered_map<wstring, int> idMap; unordered_map<wstring, int> idMap;

View File

@@ -56,7 +56,7 @@ typedef ID3D11DeviceContext ID3D1XContext;
typedef F32 ViewCoord; typedef F32 ViewCoord;
typedef gdraw_d3d11_resourcetype gdraw_resourcetype; typedef gdraw_d3d11_resourcetype gdraw_resourcetype;
static void report_d3d_error(HRESULT hr, char *call, char *context); static void report_d3d_error(HRESULT hr, const char *call, const char *context);
static void *map_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf, bool discard) static void *map_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf, bool discard)
{ {

View File

@@ -200,7 +200,7 @@ static void safe_release(T *&p)
} }
} }
static void report_d3d_error(HRESULT hr, char *call, char *context) static void report_d3d_error(HRESULT hr, const char *call, const char *context)
{ {
if (hr == E_OUTOFMEMORY) if (hr == E_OUTOFMEMORY)
IggyGDrawSendWarning(NULL, "GDraw D3D out of memory in %s%s", call, context); IggyGDrawSendWarning(NULL, "GDraw D3D out of memory in %s%s", call, context);
@@ -478,7 +478,7 @@ static GDrawTexture * RADLINK gdraw_MakeTextureEnd(GDraw_MakeTexture_ProcessingI
D3D1X_(SUBRESOURCE_DATA) mipdata[24]; D3D1X_(SUBRESOURCE_DATA) mipdata[24];
S32 i, w, h, nmips, bpp; S32 i, w, h, nmips, bpp;
HRESULT hr = S_OK; HRESULT hr = S_OK;
char *failed_call; const char *failed_call;
U8 *ptr; U8 *ptr;
// generate mip maps and set up descriptors for them // generate mip maps and set up descriptors for them
@@ -700,7 +700,7 @@ static void RADLINK gdraw_DescribeVertexBuffer(GDrawVertexBuffer *vbuf, GDraw_Ve
static GDrawHandle *get_color_rendertarget(GDrawStats *stats) static GDrawHandle *get_color_rendertarget(GDrawStats *stats)
{ {
char *failed_call; const char *failed_call;
// try to recycle LRU rendertarget // try to recycle LRU rendertarget
GDrawHandle *t = gdraw_HandleCacheGetLRU(&gdraw->rendertargets); GDrawHandle *t = gdraw_HandleCacheGetLRU(&gdraw->rendertargets);
@@ -762,7 +762,7 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats)
static ID3D1X(DepthStencilView) *get_rendertarget_depthbuffer(GDrawStats *stats) static ID3D1X(DepthStencilView) *get_rendertarget_depthbuffer(GDrawStats *stats)
{ {
if (!gdraw->depth_buffer[1]) { if (!gdraw->depth_buffer[1]) {
char *failed_call; const char *failed_call;
assert(!gdraw->rt_depth_buffer); assert(!gdraw->rt_depth_buffer);
D3D1X_(TEXTURE2D_DESC) desc = { static_cast<U32>(gdraw->frametex_width), static_cast<U32>(gdraw->frametex_height), 1U, 1U, DXGI_FORMAT_D24_UNORM_S8_UINT, { 1, 0 }, D3D1X_(TEXTURE2D_DESC) desc = { static_cast<U32>(gdraw->frametex_width), static_cast<U32>(gdraw->frametex_height), 1U, 1U, DXGI_FORMAT_D24_UNORM_S8_UINT, { 1, 0 },
@@ -2384,7 +2384,7 @@ static S32 num_pixels(S32 w, S32 h, S32 mipmaps)
GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, S32 /*len*/, IggyFileTextureRaw *texture) GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file, S32 /*len*/, IggyFileTextureRaw *texture)
{ {
char *failed_call=""; const char *failed_call="";
U8 *free_data = 0; U8 *free_data = 0;
GDrawTexture *t=0; GDrawTexture *t=0;
S32 width, height, mipmaps, size, blk; S32 width, height, mipmaps, size, blk;
@@ -2405,6 +2405,8 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file,
D3D1X_(TEXTURE2D_DESC) desc = { static_cast<U32>(width), static_cast<U32>(height), static_cast<U32>(mipmaps), 1U, DXGI_FORMAT_UNKNOWN, { 1, 0 }, D3D1X_(TEXTURE2D_DESC) desc = { static_cast<U32>(width), static_cast<U32>(height), static_cast<U32>(mipmaps), 1U, DXGI_FORMAT_UNKNOWN, { 1, 0 },
D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_SHADER_RESOURCE), 0U, 0U }; D3D1X_(USAGE_IMMUTABLE), D3D1X_(BIND_SHADER_RESOURCE), 0U, 0U };
bool done = false;
switch (texture->format) { switch (texture->format) {
case IFT_FORMAT_rgba_8888 : size= 4; d3dfmt = DXGI_FORMAT_R8G8B8A8_UNORM; break; case IFT_FORMAT_rgba_8888 : size= 4; d3dfmt = DXGI_FORMAT_R8G8B8A8_UNORM; break;
case IFT_FORMAT_DXT1 : size= 8; d3dfmt = DXGI_FORMAT_BC1_UNORM; blk = 4; break; case IFT_FORMAT_DXT1 : size= 8; d3dfmt = DXGI_FORMAT_BC1_UNORM; blk = 4; break;
@@ -2412,60 +2414,62 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file,
case IFT_FORMAT_DXT5 : size=16; d3dfmt = DXGI_FORMAT_BC3_UNORM; blk = 4; break; case IFT_FORMAT_DXT5 : size=16; d3dfmt = DXGI_FORMAT_BC3_UNORM; blk = 4; break;
default: { default: {
IggyGDrawSendWarning(NULL, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format); IggyGDrawSendWarning(NULL, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format);
goto done; done = true;
} }
} }
desc.Format = d3dfmt; if (!done) {
desc.Format = d3dfmt;
U8 *data = resource_file + texture->file_offset;
U8 *data = resource_file + texture->file_offset;
if (texture->format == IFT_FORMAT_i_8 || texture->format == IFT_FORMAT_i_4) {
// convert from intensity to luma+alpha if (texture->format == IFT_FORMAT_i_8 || texture->format == IFT_FORMAT_i_4) {
S32 i; // convert from intensity to luma+alpha
S32 total_size = 2 * num_pixels(width,height,mipmaps); S32 i;
S32 total_size = 2 * num_pixels(width,height,mipmaps);
free_data = (U8 *) IggyGDrawMalloc(total_size);
if (!free_data) { free_data = (U8 *) IggyGDrawMalloc(total_size);
IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height); if (!free_data) {
goto done; IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height);
} done = true;
} else {
U8 *cur = free_data; U8 *cur = free_data;
for (k=0; k < mipmaps; ++k) { for (k=0; k < mipmaps; ++k) {
S32 w = RR_MAX(width >> k, 1); S32 w = RR_MAX(width >> k, 1);
S32 h = RR_MAX(height >> k, 1); S32 h = RR_MAX(height >> k, 1);
for (i=0; i < w*h; ++i) { for (i=0; i < w*h; ++i) {
cur[0] = cur[1] = *data++; cur[0] = cur[1] = *data++;
cur += 2; cur += 2;
}
}
data = free_data;
}
}
if (!done) {
for (k=0; k < mipmaps; ++k) {
S32 w = RR_MAX(width >> k, 1);
S32 h = RR_MAX(height >> k, 1);
S32 blkw = (w + blk-1) / blk;
S32 blkh = (h + blk-1) / blk;
mipdata[k].pSysMem = data;
mipdata[k].SysMemPitch = blkw * size;
data += blkw * blkh * size;
}
failed_call = "CreateTexture2D";
hr = gdraw->d3d_device->CreateTexture2D(&desc, mipdata, &tex);
if (!FAILED(hr)) {
failed_call = "CreateShaderResourceView for texture creation";
hr = gdraw->d3d_device->CreateShaderResourceView(tex, NULL, &view);
if (!FAILED(hr))
t = gdraw_D3D1X_(WrappedTextureCreate)(view);
} }
} }
data = free_data;
} }
for (k=0; k < mipmaps; ++k) {
S32 w = RR_MAX(width >> k, 1);
S32 h = RR_MAX(height >> k, 1);
S32 blkw = (w + blk-1) / blk;
S32 blkh = (h + blk-1) / blk;
mipdata[k].pSysMem = data;
mipdata[k].SysMemPitch = blkw * size;
data += blkw * blkh * size;
}
failed_call = "CreateTexture2D";
hr = gdraw->d3d_device->CreateTexture2D(&desc, mipdata, &tex);
if (FAILED(hr)) goto done;
failed_call = "CreateShaderResourceView for texture creation";
hr = gdraw->d3d_device->CreateShaderResourceView(tex, NULL, &view);
if (FAILED(hr)) goto done;
t = gdraw_D3D1X_(WrappedTextureCreate)(view);
done:
if (FAILED(hr)) { if (FAILED(hr)) {
report_d3d_error(hr, failed_call, ""); report_d3d_error(hr, failed_call, "");
} }

View File

@@ -20,6 +20,23 @@
// #endif // #endif
// #endif // #endif
#ifdef _WINDOWS64
#define _HAS_STD_BYTE 0 // solve (std::)'byte' ambiguity with windows headers
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <malloc.h>
#include <tchar.h>
#include <windows.h>
#include <windowsx.h>
// TODO: reference additional headers your program requires here
#include <DirectXMath.h>
#include <d3d11.h>
using namespace DirectX;
#define HRESULT_SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
#endif
#ifdef __PS3__ #ifdef __PS3__
#include "Ps3Types.h" #include "Ps3Types.h"
@@ -59,23 +76,6 @@
#include <vector> #include <vector>
#endif #endif
#ifdef _WINDOWS64
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <windowsx.h>
#include <malloc.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
#include <d3d11.h>
#include <DirectXMath.h>
using namespace DirectX;
#define HRESULT_SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
#endif
#ifdef _DURANGO #ifdef _DURANGO
#include <xdk.h> #include <xdk.h>