mirror of
https://github.com/GerbilSoft/rvthtool.git
synced 2025-06-18 11:35:33 -04:00
Use std::array<> in more places.
This lets us get rid of a few NULL terminators, too.
This commit is contained in:
parent
cb09464faa
commit
76746231ca
@ -19,19 +19,23 @@
|
||||
#include "libwiicrypto/gcn_structs.h"
|
||||
#include "libwiicrypto/wii_structs.h"
|
||||
|
||||
// C includes.
|
||||
// C includes
|
||||
#include <stdlib.h>
|
||||
|
||||
// C includes. (C++ namespace)
|
||||
// C includes (C++ namespace)
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
// C++ STL classes
|
||||
#include <array>
|
||||
using std::array;
|
||||
|
||||
// NDDEMO header.
|
||||
// Used in early GameCube tech demos.
|
||||
// Note the lack of a GameCube magic number.
|
||||
static const uint8_t nddemo_header[64] = {
|
||||
static const array<uint8_t, 64> nddemo_header = {{
|
||||
0x30, 0x30, 0x00, 0x45, 0x30, 0x31, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@ -40,7 +44,7 @@ static const uint8_t nddemo_header[64] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
}};
|
||||
|
||||
// Volume group and partition table.
|
||||
// NOTE: Only reading the first partition table,
|
||||
@ -84,7 +88,7 @@ int rvth_disc_header_identify(const GCN_DiscHeader *discHeader)
|
||||
}
|
||||
|
||||
// Check for GameCube NDDEMO.
|
||||
if (!memcmp(discHeader, nddemo_header, sizeof(nddemo_header))) {
|
||||
if (!memcmp(discHeader, nddemo_header.data(), nddemo_header.size())) {
|
||||
// NDDEMO header found.
|
||||
return RVTH_BankType_GCN;
|
||||
}
|
||||
|
@ -101,7 +101,6 @@ CisoReader::CisoReader(const RefFilePtr &file, uint32_t lba_start, uint32_t lba_
|
||||
int ret;
|
||||
int err = 0;
|
||||
size_t size;
|
||||
unsigned int i;
|
||||
uint16_t physBlockIdx = 0;
|
||||
uint16_t maxLogicalBlockUsed = 0;
|
||||
|
||||
@ -163,10 +162,10 @@ CisoReader::CisoReader(const RefFilePtr &file, uint32_t lba_start, uint32_t lba_
|
||||
m_block_size_lba = BYTES_TO_LBA(le32_to_cpu(cisoHeader->block_size));
|
||||
|
||||
// Clear the CISO block map initially.
|
||||
memset(m_blockMap, 0xFF, sizeof(m_blockMap));
|
||||
m_blockMap.fill(0xFF);
|
||||
|
||||
// Parse the CISO block map.
|
||||
for (i = 0; i < ARRAY_SIZE(m_blockMap); i++) {
|
||||
for (unsigned int i = 0; i < static_cast<unsigned int>(m_blockMap.size()); i++) {
|
||||
switch (cisoHeader->map[i]) {
|
||||
case 0:
|
||||
// Empty block.
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include "Reader.hpp"
|
||||
|
||||
// C++ STL classes
|
||||
#include <array>
|
||||
|
||||
class CisoReader : public Reader
|
||||
{
|
||||
public:
|
||||
@ -70,5 +73,5 @@ private:
|
||||
// Block map.
|
||||
// 0x0000 == first block after CISO header.
|
||||
// 0xFFFF == empty block.
|
||||
uint16_t m_blockMap[CISO_MAP_SIZE];
|
||||
std::array<uint16_t, CISO_MAP_SIZE> m_blockMap;
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ private:
|
||||
|
||||
// Icons for COL_TYPE.
|
||||
// TODO: QMutexLocker?
|
||||
static QIcon ms_icons[RvtHModel::ICON_MAX];
|
||||
static array<QIcon, RvtHModel::ICON_MAX> ms_icons;
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -94,7 +94,7 @@ public:
|
||||
|
||||
/** RvtHModelPrivate **/
|
||||
|
||||
QIcon RvtHModelPrivate::ms_icons[RvtHModel::ICON_MAX];
|
||||
array<QIcon, RvtHModel::ICON_MAX> RvtHModelPrivate::ms_icons;
|
||||
|
||||
RvtHModelPrivate::RvtHModelPrivate(RvtHModel *q)
|
||||
: q_ptr(q)
|
||||
|
@ -15,6 +15,10 @@
|
||||
// C includes
|
||||
#include <string.h>
|
||||
|
||||
// C++ STl classes
|
||||
#include <array>
|
||||
using std::array;
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
@ -182,24 +186,20 @@ void AboutDialogPrivate::initCreditsTab(void)
|
||||
};
|
||||
|
||||
// Credits data.
|
||||
static const CreditsData_t CreditsData[] = {
|
||||
static const array<CreditsData_t, 2> CreditsData = {{
|
||||
{CT_TRANSLATORS, "crediar", nullptr, "de"},
|
||||
{CT_CONTINUE, "Moddimation", nullptr, "de"},
|
||||
|
||||
{CT_MAX, nullptr, nullptr, nullptr}
|
||||
};
|
||||
}};
|
||||
|
||||
CreditType_t lastCreditType = CT_CONTINUE;
|
||||
for (const CreditsData_t *creditsData = &CreditsData[0];
|
||||
creditsData->type < CT_MAX; creditsData++)
|
||||
{
|
||||
if (creditsData->type != CT_CONTINUE &&
|
||||
creditsData->type != lastCreditType)
|
||||
for (const CreditsData_t &p : CreditsData) {
|
||||
if (p.type != CT_CONTINUE &&
|
||||
p.type != lastCreditType)
|
||||
{
|
||||
// New credit type.
|
||||
QString creditType;
|
||||
|
||||
switch (creditsData->type) {
|
||||
switch (p.type) {
|
||||
case CT_TESTERS:
|
||||
creditType = AboutDialog::tr("Testers:");
|
||||
break;
|
||||
@ -215,17 +215,17 @@ void AboutDialogPrivate::initCreditsTab(void)
|
||||
|
||||
// Append the contributor's name.
|
||||
credits += ql1BR + sIndent + chrBullet + QChar(L' ');
|
||||
if (creditsData->url) {
|
||||
if (p.url) {
|
||||
credits += QStringLiteral("<a href='%1'>")
|
||||
.arg(QLatin1String(creditsData->url));
|
||||
.arg(QLatin1String(p.url));
|
||||
}
|
||||
credits += QString::fromUtf8(creditsData->name);
|
||||
if (creditsData->url) {
|
||||
credits += QString::fromUtf8(p.name);
|
||||
if (p.url) {
|
||||
credits += QStringLiteral("</a>");
|
||||
}
|
||||
if (creditsData->sub) {
|
||||
if (p.sub) {
|
||||
credits += QStringLiteral(" (%1)")
|
||||
.arg(QLatin1String(creditsData->sub));
|
||||
.arg(QLatin1String(p.sub));
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,16 +346,13 @@ void AboutDialogPrivate::initSupportTab(void)
|
||||
|
||||
// Support sites.
|
||||
// TODO: Other sites?
|
||||
static const supportSite_t supportSites[] = {
|
||||
static const array<supportSite_t, 1> supportSites = {{
|
||||
{"GitHub", "https://github.com/GerbilSoft/rvthtool"},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
}};
|
||||
|
||||
for (const supportSite_t *supportSite = &supportSites[0];
|
||||
supportSite->name != nullptr; supportSite++)
|
||||
{
|
||||
for (const supportSite_t &p : supportSites) {
|
||||
QString siteUrlHtml = QStringLiteral("<a href=\"%1\">%2</a>")
|
||||
.arg(QLatin1String(supportSite->url), QLatin1String(supportSite->name));
|
||||
.arg(QLatin1String(p.url), QLatin1String(p.name));
|
||||
|
||||
sSupport += chrBullet + QChar(L' ') + siteUrlHtml + ql1BR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user