summaryrefslogtreecommitdiffstats
path: root/pokemod/MapEffect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/MapEffect.cpp')
-rw-r--r--pokemod/MapEffect.cpp129
1 files changed, 56 insertions, 73 deletions
diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp
index e11e5ec0..a8a6b5f1 100644
--- a/pokemod/MapEffect.cpp
+++ b/pokemod/MapEffect.cpp
@@ -63,62 +63,18 @@ MapEffect::MapEffect(const QDomElement& xml, const Object* parent, const int id)
load(xml, id);
}
-bool MapEffect::validate() const
+void MapEffect::validate(QTextStream& stream)
{
- // TODO: validate
-// bool valid = true;
-// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Effect \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
-// if (m_name == "")
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
-// valid = false;
-// }
-// if (Flag::End <= m_existFlag.status())
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid existence flag status");
-// valid = false;
-// }
-// if (m_effect < E_End)
-// {
-// bool ok = true;
-// switch (m_effect)
-// {
-// case E_Item:
-// if (static_cast<const Pokemod*>(pokemod())->itemIndex(m_value2) == INT_MAX)
-// ok = false;
-// break;
-// case E_PC:
-// if (PC_End <= m_value2)
-// ok = false;
-// break;
-// case E_StrengthBlock:
-// case E_Button:
-// if (Flag::End <= m_value2)
-// ok = false;
-// break;
-// }
-// if (!ok)
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid val2");
-// valid = false;
-// }
-// }
-// else
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid effect");
-// valid = false;
-// }
-// if (Pokemod::D_End_None <= m_direction)
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid driection");
-// valid = false;
-// }
-// if (static_cast<const Pokemod*>(pokemod())->dialogIndex(m_dialog) == INT_MAX)
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid dialog");
-// valid = false;
-// }
-// return valid;
+ TEST_SETUP();
+ if (m_name.isEmpty())
+ error(stream, "Name is empty");
+ TEST(setCoordinate, coordinate);
+ TEST(setSkin, skin);
+ TEST(setEffect, effect);
+ TEST(setValue1, value1);
+ TEST(setValue2, value2);
+ TEST(setDirection, direction);
+ TEST(setDialog, dialog);
}
void MapEffect::load(const QDomElement& xml, int id)
@@ -159,10 +115,13 @@ void MapEffect::setName(const QString& name)
m_name = name;
}
-void MapEffect::setCoordinate(const Point& coordinate) throw(BoundsException)
+void MapEffect::setCoordinate(const Point& coordinate)
{
if ((static_cast<const Map*>(parent())->width() <= coordinate.x()) || (static_cast<const Map*>(parent())->height() <= coordinate.y()))
- error<BoundsException>("coordinate");
+ {
+ boundsError("coordinate");
+ return;
+ }
m_coordinate = coordinate;
}
@@ -171,57 +130,78 @@ void MapEffect::setExistFlag(const Flag& existFlag)
m_existFlag = existFlag;
}
-void MapEffect::setSkin(const QPixmap& skin) throw(SizeException)
+void MapEffect::setSkin(const QPixmap& skin)
{
if (skin.size() != QSize(192, 128))
- error<SizeException>("skin");
+ {
+ sizeError("skin");
+ return;
+ }
m_skin = skin;
}
-void MapEffect::setEffect(const int effect) throw(BoundsException)
+void MapEffect::setEffect(const int effect)
{
if (E_End <= effect)
- error<BoundsException>("effect");
+ {
+ boundsError("effect");
+ return;
+ }
m_effect = effect;
m_value1 = INT_MAX;
m_value2 = INT_MAX;
}
-void MapEffect::setValue1(const int value1) throw(UnusedException)
+void MapEffect::setValue1(const int value1)
{
if ((m_effect != E_StrengthBlock) && (m_effect != E_Button))
- error<UnusedException>("val1");
+ {
+ unusedError("val1");
+ return;
+ }
m_value1 = value1;
}
-void MapEffect::setValue2(const int value2) throw(Exception)
+void MapEffect::setValue2(const int value2)
{
switch (m_effect)
{
case E_Item:
if (static_cast<const Pokemod*>(pokemod())->itemIndex(value2) == INT_MAX)
- error<BoundsException>("val2");
+ {
+ boundsError("val2");
+ return;
+ }
break;
case E_PC:
if (PC_End <= value2)
- error<BoundsException>("val2");
+ {
+ boundsError("val2");
+ return;
+ }
break;
case E_StrengthBlock:
case E_Button:
if (Flag::End <= value2)
- error<BoundsException>("val2");
+ {
+ boundsError("val2");
+ return;
+ }
break;
default:
- error<UnusedException>("val2");
- break;
+ unusedError("val2");
+ return;
}
m_value2 = value2;
}
-void MapEffect::setDirection(const int direction) throw(BoundsException)
+void MapEffect::setDirection(const int direction)
{
if (Pokemod::D_End_None <= direction)
- error<BoundsException>("direction");
+ {
+ boundsError("direction");
+ return;
+ }
m_direction = direction;
}
@@ -235,10 +215,13 @@ void MapEffect::setCanMove(const bool canMove)
m_canMove = canMove;
}
-void MapEffect::setDialog(const int dialog) throw(BoundsException)
+void MapEffect::setDialog(const int dialog)
{
if (static_cast<const Pokemod*>(pokemod())->dialogIndex(dialog) == INT_MAX)
- error<BoundsException>("dialog");
+ {
+ boundsError("dialog");
+ return;
+ }
m_dialog = dialog;
}