summaryrefslogtreecommitdiffstats
path: root/sigmod
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-02-13 13:36:28 -0500
committerBen Boeckel <MathStuf@gmail.com>2009-02-13 13:36:28 -0500
commite247d49bd20fbbf6c2b275c86370300b0f36bb39 (patch)
tree201679c3d6579cb24fe6270d09dc5975e517ae7e /sigmod
parent27d630aaea5f0e1b9b63c75a06be332a67861cc3 (diff)
downloadsigen-e247d49bd20fbbf6c2b275c86370300b0f36bb39.tar.gz
sigen-e247d49bd20fbbf6c2b275c86370300b0f36bb39.tar.xz
sigen-e247d49bd20fbbf6c2b275c86370300b0f36bb39.zip
Fix more valgrind errors in sigmod
Diffstat (limited to 'sigmod')
-rw-r--r--sigmod/Badge.cpp14
-rw-r--r--sigmod/Macros.h3
-rw-r--r--sigmod/Nature.cpp12
3 files changed, 15 insertions, 14 deletions
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 <MathStuf@gmail.com>
+ * Copyright 2007-2009 Ben Boeckel <MathStuf@gmail.com>
*
* 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();
}