From e247d49bd20fbbf6c2b275c86370300b0f36bb39 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 13 Feb 2009 13:36:28 -0500 Subject: Fix more valgrind errors in sigmod --- sigmod/Badge.cpp | 14 +++++++------- sigmod/Macros.h | 3 ++- sigmod/Nature.cpp | 12 ++++++------ 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'sigmod') diff --git a/sigmod/Badge.cpp b/sigmod/Badge.cpp index ef6a58f4..1fec4bee 100644 --- a/sigmod/Badge.cpp +++ b/sigmod/Badge.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007-2008 Ben Boeckel + * Copyright 2007-2009 Ben Boeckel * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,16 +72,16 @@ void Sigmod::Badge::validate() if (m_face == m_badge) emit(error("Face and badge sprites are the same")); TEST(obey); - TEST_ARRAY_INDEX(stat, ST_Attack); - TEST_ARRAY_INDEX(stat, ST_Defense); - TEST_ARRAY_INDEX(stat, ST_Speed); + TEST_ARRAY_INDEX_OFF(stat, ST_Attack, ST_Attack); + TEST_ARRAY_INDEX_OFF(stat, ST_Defense, ST_Attack); + TEST_ARRAY_INDEX_OFF(stat, ST_Speed, ST_Attack); if (sigmod()->rules()->specialSplit()) { - TEST_ARRAY_INDEX(stat, ST_SpecialAttack); - TEST_ARRAY_INDEX(stat, ST_SpecialDefense); + TEST_ARRAY_INDEX_OFF(stat, ST_SpecialAttack, ST_Attack); + TEST_ARRAY_INDEX_OFF(stat, ST_SpecialDefense, ST_Attack); } else - TEST_ARRAY_INDEX(stat, ST_Special); + TEST_ARRAY_INDEX_OFF(stat, ST_Special, ST_Attack); TEST_END(); } diff --git a/sigmod/Macros.h b/sigmod/Macros.h index 14a2c39f..53a27d8b 100644 --- a/sigmod/Macros.h +++ b/sigmod/Macros.h @@ -75,6 +75,7 @@ disconnect(this, SIGNAL(error(QString)), this, SIGNAL(valError(QString))) #define TEST(variable) variable##Check(m_##variable) #define TEST_ARRAY_INDEX(variable, index) variable##Check(index, m_##variable[index]) +#define TEST_ARRAY_INDEX_OFF(variable, index, offset) variable##Check(index, m_##variable[index - offset]) #define TEST_LIST(variable) \ foreach (int variable, m_##variable) \ variable##Check(variable) @@ -226,7 +227,7 @@ type Sigmod::class::variable() const \ #define GETTER_ARRAY(class, type, variable, valueName, indexType, indexName, offset) \ type Sigmod::class::variable(const indexType indexName) const \ { \ - if (variable##Check(indexName, m_##variable[indexName])) \ + if (variable##Check(indexName, m_##variable[indexName - offset])) \ return m_##variable[indexName - offset]; \ return type(); \ } diff --git a/sigmod/Nature.cpp b/sigmod/Nature.cpp index fe268b74..487bbfdc 100644 --- a/sigmod/Nature.cpp +++ b/sigmod/Nature.cpp @@ -64,16 +64,16 @@ void Sigmod::Nature::validate() TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); - TEST_ARRAY_INDEX(stat, ST_Attack); - TEST_ARRAY_INDEX(stat, ST_Defense); - TEST_ARRAY_INDEX(stat, ST_Speed); + TEST_ARRAY_INDEX_OFF(stat, ST_Attack, ST_Attack); + TEST_ARRAY_INDEX_OFF(stat, ST_Defense, ST_Attack); + TEST_ARRAY_INDEX_OFF(stat, ST_Speed, ST_Attack); if (sigmod()->rules()->specialSplit()) { - TEST_ARRAY_INDEX(stat, ST_SpecialAttack); - TEST_ARRAY_INDEX(stat, ST_SpecialDefense); + TEST_ARRAY_INDEX_OFF(stat, ST_SpecialAttack, ST_Attack); + TEST_ARRAY_INDEX_OFF(stat, ST_SpecialDefense, ST_Attack); } else - TEST_ARRAY_INDEX(stat, ST_Special); + TEST_ARRAY_INDEX_OFF(stat, ST_Special, ST_Attack); TEST(weight); TEST_END(); } -- cgit