Upgrade the project default to C++26

This commit is contained in:
notmatthewbeshay 2026-03-16 18:18:52 +11:00
parent 9748827f72
commit 591dd48cf6
17 changed files with 55 additions and 51 deletions

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

@ -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

@ -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

@ -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