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
app.CaptureSaveThumbnail();
break;
default:
break;
}
}
}

View file

@ -153,7 +153,8 @@ private:
C4JThread *m_openStreamThread;
static int OpenStreamThreadProc( void* lpParameter );
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
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:
//nothing to do here
break;
default:
break;
}
}
@ -3810,6 +3812,8 @@ void CMinecraftApp::HandleXuiActions(void)
SetAction(i,eAppAction_Idle);
}
break;
default:
break;
}
}
@ -3994,6 +3998,8 @@ void CMinecraftApp::HandleXuiActions(void)
// app.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_MultiGameJoinLoad);
// }
break;
default:
break;
}
}
@ -7512,6 +7518,8 @@ void CMinecraftApp::SetGameHostOption(unsigned int &uiHostSettings, eGameHostOpt
case eGameHostOption_All:
uiHostSettings=uiVal;
break;
default:
break;
}
}
@ -7585,7 +7593,9 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame
break;
case eGameHostOption_DisableSaving:
return (uiHostSettings&GAME_HOST_OPTION_BITMASK_DISABLESAVE);
break;
break;
default:
return 0;
}
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.
case eTYPE_VILLAGERGOLEM:
return app.GetString(IDS_IRONGOLEM);
default:
break;
};

View file

@ -113,7 +113,8 @@ public:
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.
// 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);
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] );

View file

@ -1171,6 +1171,8 @@ void UIController::setupRenderPosition(C4JRender::eViewportType viewport)
xPos = (S32)(getScreenWidth() / 2);
yPos = (S32)(getScreenHeight() / 2);
break;
default:
break;
}
m_tileOriginX = xPos;
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);
return false;
break;
default:
break;
}
}
@ -1458,6 +1462,8 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void *initData, EUI
layer = eUILayer_Scene;
}
break;
default:
break;
};
int menuDisplayedPad = XUSER_INDEX_ANY;
if(group == eUIGroup_PAD)

View file

@ -155,6 +155,8 @@ void UIScene_CreativeMenu::handleOtherClicked(int iPad, ESceneSection eSection,
case eSectionInventoryCreativeSlider:
ScrollBar(this->m_pointerPos);
break;
default:
break;
}
}
@ -490,4 +492,4 @@ void UIScene_CreativeMenu::updateScrollCurrentPage(int currentPage, int pageCoun
value[1].number = (F64)currentPage - 1;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ) , m_funcSetScrollBar , 2 , value );
}
}

View file

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

View file

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

View file

@ -935,10 +935,10 @@ struct XMFLOAT3X3 {
return m[Row][Column];
}
#if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT3X3&) const = default;
auto operator<=>(const XMFLOAT3X3&) const = default;
#endif
#if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT3X3&) const = delete;
auto operator<=>(const XMFLOAT3X3&) const = delete;
#endif
};
//------------------------------------------------------------------------------
@ -987,10 +987,10 @@ struct XMFLOAT4X3 {
return m[Row][Column];
}
#if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT4X3&) const = default;
auto operator<=>(const XMFLOAT4X3&) const = default;
#endif
#if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT4X3&) const = delete;
auto operator<=>(const XMFLOAT4X3&) const = delete;
#endif
};
// 4x3 Row-major Matrix: 32 bit floating point components aligned on a 16 byte
@ -1044,10 +1044,10 @@ struct XMFLOAT3X4 {
return m[Row][Column];
}
#if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT3X4&) const = default;
auto operator<=>(const XMFLOAT3X4&) const = default;
#endif
#if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT3X4&) const = delete;
auto operator<=>(const XMFLOAT3X4&) const = delete;
#endif
};
// 3x4 Column-major Matrix: 32 bit floating point components aligned on a 16
@ -1106,10 +1106,10 @@ struct XMFLOAT4X4 {
return m[Row][Column];
}
#if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT4X4&) const = default;
auto operator<=>(const XMFLOAT4X4&) const = default;
#endif
#if (__cplusplus >= 202002L)
bool operator==(const XMFLOAT4X4&) const = delete;
auto operator<=>(const XMFLOAT4X4&) const = delete;
#endif
};
// 4x4 Matrix: 32 bit floating point components aligned on a 16 byte boundary

View file

@ -6,6 +6,19 @@
#include "winapi_stubs.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;
typedef struct _RECT {
@ -64,4 +77,4 @@ enum D3D11_COMPARISON_FUNC {
D3D11_COMPARISON_ALWAYS = 8
};
#endif // D3D11STUBS_H
#endif // D3D11STUBS_H

View file

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

View file

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

View file

@ -31,11 +31,11 @@ namespace fs = std::filesystem;
fs::path ToFilesystemPath(const std::wstring& path) {
const std::string nativePath = wstringtofilename(path);
return fs::u8path(nativePath);
return fs::path(nativePath);
}
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());
}

View file

@ -124,9 +124,9 @@ const ItemInstance* ArmorDyeRecipe::getResultItem() { return NULL; }
const int ArmorDyeRecipe::getGroup() { return ShapedRecipy::eGroupType_Armour; }
// 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;
// bool bFound;
// int j;

View file

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

View file

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

View file

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

View file

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

View file

@ -32,7 +32,7 @@ public:
// 4J-PB - to return the items required to make a recipe
virtual bool
requires(int iRecipe);
requiresRecipe(int iRecipe);
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(); }
// 4J-PB
bool ShapelessRecipy::requires(int iRecipe) {
bool ShapelessRecipy::requiresRecipe(int iRecipe) {
std::vector<ItemInstance*>* tempList = new std::vector<ItemInstance*>;
*tempList = *ingredients;
@ -87,7 +87,7 @@ bool ShapelessRecipy::requires(int iRecipe) {
return false;
}
void ShapelessRecipy::requires(INGREDIENTS_REQUIRED* pIngReq) {
void ShapelessRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) {
int iCount = 0;
bool bFound;
int j;

View file

@ -21,7 +21,7 @@ public:
// 4J-PB - to return the items required to make a recipe
virtual bool
requires(int iRecipe);
requiresRecipe(int iRecipe);
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 y Y position in the achievement tree
* @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,
Item* icon, Achievement* requires)
Item* icon, Achievement* prerequisite)
: Stat(Achievements::ACHIEVEMENT_OFFSET + id,
I18n::get(std::wstring(L"achievement.").append(name))),
desc(I18n::get(
@ -51,10 +51,10 @@ Achievement::Achievement(int id, const std::wstring& name, int x, int y,
icon(new ItemInstance(icon)),
x(x),
y(y),
requires(requires) {}
prerequisite(prerequisite) {}
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,
I18n::get(std::wstring(L"achievement.").append(name))),
desc(I18n::get(
@ -62,11 +62,11 @@ Achievement::Achievement(int id, const std::wstring& name, int x, int y,
icon(new ItemInstance(icon)),
x(x),
y(y),
requires(requires) {}
prerequisite(prerequisite) {}
Achievement::Achievement(int id, const std::wstring& name, int x, int y,
std::shared_ptr<ItemInstance> icon,
Achievement* requires)
Achievement* prerequisite)
: Stat(Achievements::ACHIEVEMENT_OFFSET + id,
I18n::get(std::wstring(L"achievement.").append(name))),
desc(I18n::get(
@ -74,7 +74,7 @@ Achievement::Achievement(int id, const std::wstring& name, int x, int y,
icon(icon),
x(x),
y(y),
requires(requires) {}
prerequisite(prerequisite) {}
/**
* @brief Sets the decription formatter (DescFormatter)

View file

@ -7,8 +7,7 @@ class DescFormatter;
class Achievement : public Stat {
public:
const int x, y;
Achievement*
requires;
Achievement* prerequisite;
private:
const std::wstring desc;
@ -23,11 +22,12 @@ private:
public:
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* requires);
Achievement* prerequisite);
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* setGolden();

View file

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