mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-11 12:54:10 -07:00
[Fix-Warnings] Local variable can be made const
This commit is contained in:
parent
8abd04dab1
commit
f2d3e81331
214 changed files with 1375 additions and 1355 deletions
|
|
@ -14,10 +14,10 @@ bool AbstractDecklistCardNode::compare(AbstractDecklistNode *other) const
|
|||
|
||||
bool AbstractDecklistCardNode::compareNumber(AbstractDecklistNode *other) const
|
||||
{
|
||||
auto *other2 = dynamic_cast<AbstractDecklistCardNode *>(other);
|
||||
const auto *other2 = dynamic_cast<AbstractDecklistCardNode *>(other);
|
||||
if (other2) {
|
||||
int n1 = getNumber();
|
||||
int n2 = other2->getNumber();
|
||||
const int n1 = getNumber();
|
||||
const int n2 = other2->getNumber();
|
||||
return (n1 != n2) ? (n1 > n2) : compareName(other);
|
||||
} else {
|
||||
return true;
|
||||
|
|
@ -26,7 +26,7 @@ bool AbstractDecklistCardNode::compareNumber(AbstractDecklistNode *other) const
|
|||
|
||||
bool AbstractDecklistCardNode::compareName(AbstractDecklistNode *other) const
|
||||
{
|
||||
auto *other2 = dynamic_cast<AbstractDecklistCardNode *>(other);
|
||||
const auto *other2 = dynamic_cast<AbstractDecklistCardNode *>(other);
|
||||
if (other2) {
|
||||
return (getName() > other2->getName());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ DeckList::~DeckList()
|
|||
|
||||
QList<MoveCard_ToZone> DeckList::getCurrentSideboardPlan()
|
||||
{
|
||||
SideboardPlan *current = sideboardPlans.value(QString(), 0);
|
||||
const SideboardPlan *current = sideboardPlans.value(QString(), 0);
|
||||
if (!current)
|
||||
return QList<MoveCard_ToZone>();
|
||||
else
|
||||
|
|
@ -127,8 +127,8 @@ bool DeckList::readElement(QXmlStreamReader *xml)
|
|||
} else if (childName == "comments") {
|
||||
comments = xml->readElementText();
|
||||
} else if (childName == "bannerCard") {
|
||||
QString providerId = xml->attributes().value("providerId").toString();
|
||||
QString cardName = xml->readElementText();
|
||||
const QString providerId = xml->attributes().value("providerId").toString();
|
||||
const QString cardName = xml->readElementText();
|
||||
bannerCard = {cardName, providerId};
|
||||
} else if (childName == "tags") {
|
||||
tags.clear(); // Clear existing tags
|
||||
|
|
@ -513,7 +513,7 @@ void DeckList::cleanList(bool preserveMetadata)
|
|||
void DeckList::getCardListHelper(InnerDecklistNode *item, QSet<QString> &result)
|
||||
{
|
||||
for (int i = 0; i < item->size(); ++i) {
|
||||
auto *node = dynamic_cast<DecklistCardNode *>(item->at(i));
|
||||
const auto *node = dynamic_cast<DecklistCardNode *>(item->at(i));
|
||||
|
||||
if (node) {
|
||||
result.insert(node->getName());
|
||||
|
|
@ -526,7 +526,7 @@ void DeckList::getCardListHelper(InnerDecklistNode *item, QSet<QString> &result)
|
|||
void DeckList::getCardRefListHelper(InnerDecklistNode *item, QList<CardRef> &result)
|
||||
{
|
||||
for (int i = 0; i < item->size(); ++i) {
|
||||
auto *node = dynamic_cast<DecklistCardNode *>(item->at(i));
|
||||
const auto *node = dynamic_cast<DecklistCardNode *>(item->at(i));
|
||||
|
||||
if (node) {
|
||||
result.append(node->toCardRef());
|
||||
|
|
@ -577,13 +577,13 @@ int DeckList::getSideboardSize() const
|
|||
{
|
||||
int size = 0;
|
||||
for (int i = 0; i < root->size(); ++i) {
|
||||
auto *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
|
||||
const auto *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
|
||||
if (node->getName() != DECK_ZONE_SIDE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < node->size(); j++) {
|
||||
auto *card = dynamic_cast<DecklistCardNode *>(node->at(j));
|
||||
const auto *card = dynamic_cast<DecklistCardNode *>(node->at(j));
|
||||
size += card->getNumber();
|
||||
}
|
||||
}
|
||||
|
|
@ -621,7 +621,7 @@ bool DeckList::deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNod
|
|||
updateHash = true;
|
||||
}
|
||||
|
||||
int index = rootNode->indexOf(node);
|
||||
const int index = rootNode->indexOf(node);
|
||||
if (index != -1) {
|
||||
delete rootNode->takeAt(index);
|
||||
|
||||
|
|
@ -661,11 +661,11 @@ static QString computeDeckHash(const InnerDecklistNode *root)
|
|||
optionalZones << DECK_ZONE_TOKENS; // Optional zones in deck not included in hashing process
|
||||
|
||||
for (int i = 0; i < root->size(); i++) {
|
||||
auto *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
|
||||
const auto *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
|
||||
for (int j = 0; j < node->size(); j++) {
|
||||
if (hashZones.contains(node->getName())) // Mainboard or Sideboard
|
||||
{
|
||||
auto *card = dynamic_cast<DecklistCardNode *>(node->at(j));
|
||||
const auto *card = dynamic_cast<DecklistCardNode *>(node->at(j));
|
||||
for (int k = 0; k < card->getNumber(); ++k) {
|
||||
cardList.append((node->getName() == DECK_ZONE_SIDE ? "SB:" : "") + card->getName().toLower());
|
||||
}
|
||||
|
|
@ -674,10 +674,10 @@ static QString computeDeckHash(const InnerDecklistNode *root)
|
|||
}
|
||||
cardList.sort();
|
||||
QByteArray deckHashArray = QCryptographicHash::hash(cardList.join(";").toUtf8(), QCryptographicHash::Sha1);
|
||||
quint64 number = (((quint64)(unsigned char)deckHashArray[0]) << 32) +
|
||||
(((quint64)(unsigned char)deckHashArray[1]) << 24) +
|
||||
(((quint64)(unsigned char)deckHashArray[2] << 16)) +
|
||||
(((quint64)(unsigned char)deckHashArray[3]) << 8) + (quint64)(unsigned char)deckHashArray[4];
|
||||
const quint64 number = (((quint64)(unsigned char)deckHashArray[0]) << 32) +
|
||||
(((quint64)(unsigned char)deckHashArray[1]) << 24) +
|
||||
(((quint64)(unsigned char)deckHashArray[2] << 16)) +
|
||||
(((quint64)(unsigned char)deckHashArray[3]) << 8) + (quint64)(unsigned char)deckHashArray[4];
|
||||
return QString::number(number, 32).rightJustified(8, '0');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ void DeckListHistoryManager::undo(DeckList *deck)
|
|||
const DeckListMemento &mementoToRestore = undoStack.top();
|
||||
|
||||
// Save current state for redo
|
||||
DeckListMemento currentState = deck->createMemento(mementoToRestore.getReason());
|
||||
const DeckListMemento currentState = deck->createMemento(mementoToRestore.getReason());
|
||||
redoStack.push(currentState);
|
||||
|
||||
// Pop the last state from undo stack and restore it
|
||||
DeckListMemento memento = undoStack.pop();
|
||||
const DeckListMemento memento = undoStack.pop();
|
||||
deck->restoreMemento(memento);
|
||||
|
||||
emit undoRedoStateChanged();
|
||||
|
|
@ -42,11 +42,11 @@ void DeckListHistoryManager::redo(DeckList *deck)
|
|||
const DeckListMemento &mementoToRestore = redoStack.top();
|
||||
|
||||
// Save current state for undo
|
||||
DeckListMemento currentState = deck->createMemento(mementoToRestore.getReason());
|
||||
const DeckListMemento currentState = deck->createMemento(mementoToRestore.getReason());
|
||||
undoStack.push(currentState);
|
||||
|
||||
// Pop the next state from redo stack and restore it
|
||||
DeckListMemento memento = redoStack.pop();
|
||||
const DeckListMemento memento = redoStack.pop();
|
||||
deck->restoreMemento(memento);
|
||||
|
||||
emit undoRedoStateChanged();
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ int InnerDecklistNode::recursiveCount(bool countTotalCards) const
|
|||
{
|
||||
int result = 0;
|
||||
for (int i = 0; i < size(); i++) {
|
||||
auto *node = dynamic_cast<InnerDecklistNode *>(at(i));
|
||||
const auto *node = dynamic_cast<InnerDecklistNode *>(at(i));
|
||||
|
||||
if (node) {
|
||||
result += node->recursiveCount(countTotalCards);
|
||||
|
|
@ -118,10 +118,10 @@ bool InnerDecklistNode::compare(AbstractDecklistNode *other) const
|
|||
|
||||
bool InnerDecklistNode::compareNumber(AbstractDecklistNode *other) const
|
||||
{
|
||||
auto *other2 = dynamic_cast<InnerDecklistNode *>(other);
|
||||
const auto *other2 = dynamic_cast<InnerDecklistNode *>(other);
|
||||
if (other2) {
|
||||
int n1 = recursiveCount(true);
|
||||
int n2 = other2->recursiveCount(true);
|
||||
const int n1 = recursiveCount(true);
|
||||
const int n2 = other2->recursiveCount(true);
|
||||
return (n1 != n2) ? (n1 > n2) : compareName(other);
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -130,7 +130,7 @@ bool InnerDecklistNode::compareNumber(AbstractDecklistNode *other) const
|
|||
|
||||
bool InnerDecklistNode::compareName(AbstractDecklistNode *other) const
|
||||
{
|
||||
auto *other2 = dynamic_cast<InnerDecklistNode *>(other);
|
||||
const auto *other2 = dynamic_cast<InnerDecklistNode *>(other);
|
||||
if (other2) {
|
||||
return (getName() > other2->getName());
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue