Merge pull request #260 from MatthewBeshay/chore/cpp26

Upgrade the project default to C++26
This commit is contained in:
MatthewBeshay 2026-03-17 00:13:28 +11:00 committed by GitHub
commit 7a9565feef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 103 additions and 54 deletions

View file

@ -1981,6 +1981,8 @@ void Minecraft::run_middle() {
// capture the save thumbnail // capture the save thumbnail
app.CaptureSaveThumbnail(); app.CaptureSaveThumbnail();
break; break;
default:
break;
} }
} }
} }

View file

@ -153,7 +153,8 @@ private:
C4JThread *m_openStreamThread; C4JThread *m_openStreamThread;
static int OpenStreamThreadProc( void* lpParameter ); static int OpenStreamThreadProc( void* lpParameter );
char m_szStreamName[255]; char m_szStreamName[255];
int CurrentSoundsPlaying[eSoundType_MAX+eSFX_MAX]; int CurrentSoundsPlaying[static_cast<int>(eSoundType_MAX) +
static_cast<int>(eSFX_MAX)];
// streaming music files - will be different for mash-up packs // streaming music files - will be different for mash-up packs
int m_iStream_Overworld_Min,m_iStream_Overworld_Max; int m_iStream_Overworld_Min,m_iStream_Overworld_Max;

View file

@ -1330,6 +1330,8 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal)
case eGameSetting_PSVita_NetworkModeAdhoc: case eGameSetting_PSVita_NetworkModeAdhoc:
//nothing to do here //nothing to do here
break; break;
default:
break;
} }
} }
@ -3810,6 +3812,8 @@ void CMinecraftApp::HandleXuiActions(void)
SetAction(i,eAppAction_Idle); SetAction(i,eAppAction_Idle);
} }
break;
default:
break; break;
} }
} }
@ -3994,6 +3998,8 @@ void CMinecraftApp::HandleXuiActions(void)
// app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_MultiGameJoinLoad); // app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_MultiGameJoinLoad);
// } // }
break; break;
default:
break;
} }
} }
@ -7512,6 +7518,8 @@ void CMinecraftApp::SetGameHostOption(unsigned int &uiHostSettings, eGameHostOpt
case eGameHostOption_All: case eGameHostOption_All:
uiHostSettings=uiVal; uiHostSettings=uiVal;
break; break;
default:
break;
} }
} }
@ -7586,6 +7594,8 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame
case eGameHostOption_DisableSaving: case eGameHostOption_DisableSaving:
return (uiHostSettings&GAME_HOST_OPTION_BITMASK_DISABLESAVE); return (uiHostSettings&GAME_HOST_OPTION_BITMASK_DISABLESAVE);
break; break;
default:
return 0;
} }
return false; return false;
@ -7918,6 +7928,8 @@ std::wstring CMinecraftApp::getEntityName(eINSTANCEOF type)
// 4J-PB - fix for #107167 - Customer Encountered: TU12: Content: UI: There is no information what killed Player after being slain by Iron Golem. // 4J-PB - fix for #107167 - Customer Encountered: TU12: Content: UI: There is no information what killed Player after being slain by Iron Golem.
case eTYPE_VILLAGERGOLEM: case eTYPE_VILLAGERGOLEM:
return app.GetString(IDS_IRONGOLEM); return app.GetString(IDS_IRONGOLEM);
default:
break;
}; };

View file

@ -113,7 +113,8 @@ public:
static void write(DataOutputStream *dos, ConsoleGameRules::EGameRuleAttr eAttr) static void write(DataOutputStream *dos, ConsoleGameRules::EGameRuleAttr eAttr)
{ {
dos->writeInt( eGameRuleType_Count + eAttr ); dos->writeInt(static_cast<int>(eGameRuleType_Count) +
static_cast<int>(eAttr));
} }
}; };

View file

@ -341,7 +341,8 @@ void GameRuleManager::writeRuleFile(DataOutputStream *dos)
for (int i=0; i<8; i++) dos->writeBoolean(false); // Padding. for (int i=0; i<8; i++) dos->writeBoolean(false); // Padding.
// Write string lookup. // Write string lookup.
int numStrings = ConsoleGameRules::eGameRuleType_Count + ConsoleGameRules::eGameRuleAttr_Count; int numStrings = static_cast<int>(ConsoleGameRules::eGameRuleType_Count) +
static_cast<int>(ConsoleGameRules::eGameRuleAttr_Count);
dos->writeInt(numStrings); dos->writeInt(numStrings);
for (int i = 0; i < ConsoleGameRules::eGameRuleType_Count; i++) dos->writeUTF( wchTagNameA[i] ); for (int i = 0; i < ConsoleGameRules::eGameRuleType_Count; i++) dos->writeUTF( wchTagNameA[i] );
for (int i = 0; i < ConsoleGameRules::eGameRuleAttr_Count; i++) dos->writeUTF( wchAttrNameA[i] ); for (int i = 0; i < ConsoleGameRules::eGameRuleAttr_Count; i++) dos->writeUTF( wchAttrNameA[i] );

View file

@ -1171,6 +1171,8 @@ void UIController::setupRenderPosition(C4JRender::eViewportType viewport)
xPos = (S32)(getScreenWidth() / 2); xPos = (S32)(getScreenWidth() / 2);
yPos = (S32)(getScreenHeight() / 2); yPos = (S32)(getScreenHeight() / 2);
break; break;
default:
break;
} }
m_tileOriginX = xPos; m_tileOriginX = xPos;
m_tileOriginY = yPos; m_tileOriginY = yPos;
@ -1433,6 +1435,8 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI
app.DebugPrintf("IGNORING NAVIGATE - we're trying to navigate to a user selected scene when there's already a scene up: pad:%d, scene:%d\n", iPad, scene); app.DebugPrintf("IGNORING NAVIGATE - we're trying to navigate to a user selected scene when there's already a scene up: pad:%d, scene:%d\n", iPad, scene);
return false; return false;
break; break;
default:
break;
} }
} }
@ -1458,6 +1462,8 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI
layer = eUILayer_Scene; layer = eUILayer_Scene;
} }
break; break;
default:
break;
}; };
int menuDisplayedPad = XUSER_INDEX_ANY; int menuDisplayedPad = XUSER_INDEX_ANY;
if(group == eUIGroup_PAD) if(group == eUIGroup_PAD)

View file

@ -155,6 +155,8 @@ void UIScene_CreativeMenu::handleOtherClicked(int iPad, ESceneSection eSection,
case eSectionInventoryCreativeSlider: case eSectionInventoryCreativeSlider:
ScrollBar(this->m_pointerPos); ScrollBar(this->m_pointerPos);
break; break;
default:
break;
} }
} }

View file

@ -208,6 +208,8 @@ int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(void *lpParam,bool bR
pClass->m_data->endZ = iVal; pClass->m_data->endZ = iVal;
} }
break; break;
default:
break;
} }
} }

View file

@ -350,6 +350,8 @@ void UIScene_LeaderboardsMenu::handleInput(int iPad, int key, bool repeat, bool
m_labelFilter.setLabel(filterBuffer); m_labelFilter.setLabel(filterBuffer);
} }
break; break;
default:
break;
} }
ReadStats(-1); ReadStats(-1);
@ -484,6 +486,8 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex)
); );
} }
break; break;
default:
break;
} }
//Show the loading message //Show the loading message

View file

@ -936,8 +936,8 @@ struct XMFLOAT3X3 {
} }
#if (__cplusplus >= 202002L) #if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT3X3&) const = default; bool operator==(const XMFLOAT3X3&) const = delete;
auto operator<=>(const XMFLOAT3X3&) const = default; auto operator<=>(const XMFLOAT3X3&) const = delete;
#endif #endif
}; };
@ -988,8 +988,8 @@ struct XMFLOAT4X3 {
} }
#if (__cplusplus >= 202002L) #if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT4X3&) const = default; bool operator==(const XMFLOAT4X3&) const = delete;
auto operator<=>(const XMFLOAT4X3&) const = default; auto operator<=>(const XMFLOAT4X3&) const = delete;
#endif #endif
}; };
@ -1045,8 +1045,8 @@ struct XMFLOAT3X4 {
} }
#if (__cplusplus >= 202002L) #if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT3X4&) const = default; bool operator==(const XMFLOAT3X4&) const = delete;
auto operator<=>(const XMFLOAT3X4&) const = default; auto operator<=>(const XMFLOAT3X4&) const = delete;
#endif #endif
}; };
@ -1107,8 +1107,8 @@ struct XMFLOAT4X4 {
} }
#if (__cplusplus >= 202002L) #if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT4X4&) const = default; bool operator==(const XMFLOAT4X4&) const = delete;
auto operator<=>(const XMFLOAT4X4&) const = default; auto operator<=>(const XMFLOAT4X4&) const = delete;
#endif #endif
}; };

View file

@ -6,6 +6,19 @@
#include "winapi_stubs.h" #include "winapi_stubs.h"
#include "DirectXMath/DirectXMath.h" #include "DirectXMath/DirectXMath.h"
// The DirectXMath SAL shim defines a few reserved identifiers such as
// `__valid`. Newer libstdc++ headers also use those internal names, so keep
// the shim's macros from leaking past the DirectXMath include.
#ifdef __valid
#undef __valid
#endif
#ifdef __notvalid
#undef __notvalid
#endif
#ifdef __maybevalid
#undef __maybevalid
#endif
using namespace DirectX; using namespace DirectX;
typedef struct _RECT { typedef struct _RECT {

View file

@ -703,6 +703,8 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, int dmg) {
m_lastDamageSource = m_lastDamageSource =
eTelemetryPlayerDeathSource_Player_Arrow; eTelemetryPlayerDeathSource_Player_Arrow;
break; break;
default:
break;
} }
} }
} }
@ -710,6 +712,8 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, int dmg) {
case eTYPE_FIREBALL: case eTYPE_FIREBALL:
m_lastDamageSource = eTelemetryPlayerDeathSource_Ghast; m_lastDamageSource = eTelemetryPlayerDeathSource_Ghast;
break; break;
default:
break;
}; };
} }
}; };

View file

@ -34,7 +34,7 @@ void Screen::keyPressed(wchar_t eventCharacter, int eventKey) {
std::wstring Screen::getClipboard() { std::wstring Screen::getClipboard() {
// 4J - removed // 4J - removed
return NULL; return std::wstring();
} }
void Screen::setClipboard(const std::wstring& str) { void Screen::setClipboard(const std::wstring& str) {

View file

@ -31,11 +31,11 @@ namespace fs = std::filesystem;
fs::path ToFilesystemPath(const std::wstring& path) { fs::path ToFilesystemPath(const std::wstring& path) {
const std::string nativePath = wstringtofilename(path); const std::string nativePath = wstringtofilename(path);
return fs::u8path(nativePath); return fs::path(nativePath);
} }
std::wstring ToFilename(const fs::path& path) { std::wstring ToFilename(const fs::path& path) {
const std::string filename = path.filename().u8string(); const std::string filename = path.filename().string();
return filenametowstring(filename.c_str()); return filenametowstring(filename.c_str());
} }

View file

@ -124,9 +124,9 @@ const ItemInstance* ArmorDyeRecipe::getResultItem() { return NULL; }
const int ArmorDyeRecipe::getGroup() { return ShapedRecipy::eGroupType_Armour; } const int ArmorDyeRecipe::getGroup() { return ShapedRecipy::eGroupType_Armour; }
// 4J-PB // 4J-PB
bool ArmorDyeRecipe::requires(int iRecipe) { return false; } bool ArmorDyeRecipe::requiresRecipe(int iRecipe) { return false; }
void ArmorDyeRecipe::requires(INGREDIENTS_REQUIRED* pIngReq) { void ArmorDyeRecipe::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) {
// int iCount=0; // int iCount=0;
// bool bFound; // bool bFound;
// int j; // int j;

View file

@ -20,7 +20,7 @@ public:
// 4J-PB // 4J-PB
virtual bool virtual bool
requires(int iRecipe); requiresRecipe(int iRecipe);
virtual void virtual void
requires(INGREDIENTS_REQUIRED* pIngReq); collectRequirements(INGREDIENTS_REQUIRED* pIngReq);
}; };

View file

@ -1092,7 +1092,7 @@ void Recipes::buildRecipeIngredientsArray(void) {
Recipy* recipe = *it; Recipy* recipe = *it;
// wprintf(L"RECIPE - [%d] is // wprintf(L"RECIPE - [%d] is
// %w\n",iCount,recipe->getResultItem()->getItem()->getName()); // %w\n",iCount,recipe->getResultItem()->getItem()->getName());
recipe->requires(&m_pRecipeIngredientsRequired[iCount++]); recipe->collectRequirements(&m_pRecipeIngredientsRequired[iCount++]);
} }
// printf("Total recipes in buildRecipeIngredientsArray - %d",iCount); // printf("Total recipes in buildRecipeIngredientsArray - %d",iCount);

View file

@ -52,9 +52,9 @@ public:
// 4J-PB // 4J-PB
virtual bool virtual bool
requires(int iRecipe) requiresRecipe(int iRecipe)
= 0; = 0;
virtual void virtual void
requires(INGREDIENTS_REQUIRED* pIngReq) collectRequirements(INGREDIENTS_REQUIRED* pIngReq)
= 0; = 0;
}; };

View file

@ -92,7 +92,7 @@ std::shared_ptr<ItemInstance> ShapedRecipy::assemble(
int ShapedRecipy::size() { return width * height; } int ShapedRecipy::size() { return width * height; }
// 4J-PB // 4J-PB
bool ShapedRecipy::requires(int iRecipe) { bool ShapedRecipy::requiresRecipe(int iRecipe) {
app.DebugPrintf("ShapedRecipy %d\n", iRecipe); app.DebugPrintf("ShapedRecipy %d\n", iRecipe);
int iCount = 0; int iCount = 0;
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
@ -109,7 +109,7 @@ bool ShapedRecipy::requires(int iRecipe) {
return false; return false;
} }
void ShapedRecipy::requires(INGREDIENTS_REQUIRED* pIngReq) { void ShapedRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) {
// printf("ShapedRecipy %d\n",iRecipe); // printf("ShapedRecipy %d\n",iRecipe);
int iCount = 0; int iCount = 0;

View file

@ -32,7 +32,7 @@ public:
// 4J-PB - to return the items required to make a recipe // 4J-PB - to return the items required to make a recipe
virtual bool virtual bool
requires(int iRecipe); requiresRecipe(int iRecipe);
virtual void virtual void
requires(INGREDIENTS_REQUIRED* pIngReq); collectRequirements(INGREDIENTS_REQUIRED* pIngReq);
}; };

View file

@ -65,7 +65,7 @@ std::shared_ptr<ItemInstance> ShapelessRecipy::assemble(
int ShapelessRecipy::size() { return (int)ingredients->size(); } int ShapelessRecipy::size() { return (int)ingredients->size(); }
// 4J-PB // 4J-PB
bool ShapelessRecipy::requires(int iRecipe) { bool ShapelessRecipy::requiresRecipe(int iRecipe) {
std::vector<ItemInstance*>* tempList = new std::vector<ItemInstance*>; std::vector<ItemInstance*>* tempList = new std::vector<ItemInstance*>;
*tempList = *ingredients; *tempList = *ingredients;
@ -87,7 +87,7 @@ bool ShapelessRecipy::requires(int iRecipe) {
return false; return false;
} }
void ShapelessRecipy::requires(INGREDIENTS_REQUIRED* pIngReq) { void ShapelessRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) {
int iCount = 0; int iCount = 0;
bool bFound; bool bFound;
int j; int j;

View file

@ -21,7 +21,7 @@ public:
// 4J-PB - to return the items required to make a recipe // 4J-PB - to return the items required to make a recipe
virtual bool virtual bool
requires(int iRecipe); requiresRecipe(int iRecipe);
virtual void virtual void
requires(INGREDIENTS_REQUIRED* pIngReq); collectRequirements(INGREDIENTS_REQUIRED* pIngReq);
}; };

View file

@ -40,10 +40,10 @@ void Achievement::_init() {
* @param x X position in the achievement tree * @param x X position in the achievement tree
* @param y Y position in the achievement tree * @param y Y position in the achievement tree
* @param icon Item used as the achievement icon * @param icon Item used as the achievement icon
* @param requires Achievement object that is required to unlock this one * @param prerequisite Achievement object that is required to unlock this one
*/ */
Achievement::Achievement(int id, const std::wstring& name, int x, int y, Achievement::Achievement(int id, const std::wstring& name, int x, int y,
Item* icon, Achievement* requires) Item* icon, Achievement* prerequisite)
: Stat(Achievements::ACHIEVEMENT_OFFSET + id, : Stat(Achievements::ACHIEVEMENT_OFFSET + id,
I18n::get(std::wstring(L"achievement.").append(name))), I18n::get(std::wstring(L"achievement.").append(name))),
desc(I18n::get( desc(I18n::get(
@ -51,10 +51,10 @@ Achievement::Achievement(int id, const std::wstring& name, int x, int y,
icon(new ItemInstance(icon)), icon(new ItemInstance(icon)),
x(x), x(x),
y(y), y(y),
requires(requires) {} prerequisite(prerequisite) {}
Achievement::Achievement(int id, const std::wstring& name, int x, int y, Achievement::Achievement(int id, const std::wstring& name, int x, int y,
Tile* icon, Achievement* requires) Tile* icon, Achievement* prerequisite)
: Stat(Achievements::ACHIEVEMENT_OFFSET + id, : Stat(Achievements::ACHIEVEMENT_OFFSET + id,
I18n::get(std::wstring(L"achievement.").append(name))), I18n::get(std::wstring(L"achievement.").append(name))),
desc(I18n::get( desc(I18n::get(
@ -62,11 +62,11 @@ Achievement::Achievement(int id, const std::wstring& name, int x, int y,
icon(new ItemInstance(icon)), icon(new ItemInstance(icon)),
x(x), x(x),
y(y), y(y),
requires(requires) {} prerequisite(prerequisite) {}
Achievement::Achievement(int id, const std::wstring& name, int x, int y, Achievement::Achievement(int id, const std::wstring& name, int x, int y,
std::shared_ptr<ItemInstance> icon, std::shared_ptr<ItemInstance> icon,
Achievement* requires) Achievement* prerequisite)
: Stat(Achievements::ACHIEVEMENT_OFFSET + id, : Stat(Achievements::ACHIEVEMENT_OFFSET + id,
I18n::get(std::wstring(L"achievement.").append(name))), I18n::get(std::wstring(L"achievement.").append(name))),
desc(I18n::get( desc(I18n::get(
@ -74,7 +74,7 @@ Achievement::Achievement(int id, const std::wstring& name, int x, int y,
icon(icon), icon(icon),
x(x), x(x),
y(y), y(y),
requires(requires) {} prerequisite(prerequisite) {}
/** /**
* @brief Sets the decription formatter (DescFormatter) * @brief Sets the decription formatter (DescFormatter)

View file

@ -7,8 +7,7 @@ class DescFormatter;
class Achievement : public Stat { class Achievement : public Stat {
public: public:
const int x, y; const int x, y;
Achievement* Achievement* prerequisite;
requires;
private: private:
const std::wstring desc; const std::wstring desc;
@ -23,11 +22,12 @@ private:
public: public:
Achievement(int id, const std::wstring& name, int x, int y, Item* icon, Achievement(int id, const std::wstring& name, int x, int y, Item* icon,
Achievement* requires); Achievement* prerequisite);
Achievement(int id, const std::wstring& name, int x, int y, Tile* icon, Achievement(int id, const std::wstring& name, int x, int y, Tile* icon,
Achievement* requires); Achievement* prerequisite);
Achievement(int id, const std::wstring& name, int x, int y, Achievement(int id, const std::wstring& name, int x, int y,
std::shared_ptr<ItemInstance> icon, Achievement* requires); std::shared_ptr<ItemInstance> icon,
Achievement* prerequisite);
Achievement* setAwardLocallyOnly(); Achievement* setAwardLocallyOnly();
Achievement* setGolden(); Achievement* setGolden();

View file

@ -2,6 +2,7 @@ project('4jcraft-chucklegrounds', ['cpp', 'c'],
version : '0.1.0', version : '0.1.0',
meson_version: '>= 1.1', meson_version: '>= 1.1',
default_options : [ default_options : [
'cpp_std=c++26',
'warning_level=0', 'warning_level=0',
'buildtype=debug', # for now 'buildtype=debug', # for now
'unity=on', # merge source files per target 'unity=on', # merge source files per target