summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-18 19:20:57 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-18 19:20:57 +0300
commit4de24231be93c6194801c8962d7bf00ed6c339ff (patch)
tree59e622c6e59a71a976d558f16d454ddce2af85e5
parent30a2658b93cebebeddf9aa9e7d9d37cc4fc80d3c (diff)
downloadplus-4de24231be93c6194801c8962d7bf00ed6c339ff.tar.gz
plus-4de24231be93c6194801c8962d7bf00ed6c339ff.tar.bz2
plus-4de24231be93c6194801c8962d7bf00ed6c339ff.tar.xz
plus-4de24231be93c6194801c8962d7bf00ed6c339ff.zip
move shared code for reading being info attributes to separate class.
Also fix name offsets for pets.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/resources/beingcommon.cpp44
-rw-r--r--src/resources/beingcommon.h38
-rw-r--r--src/resources/monsterdb.cpp22
-rw-r--r--src/resources/npcdb.cpp22
-rw-r--r--src/resources/petdb.cpp16
7 files changed, 92 insertions, 54 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4ed28c69b..b1935f3b1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -432,6 +432,8 @@ SET(SRCS
resources/atlasmanager.h
resources/avatardb.cpp
resources/avatardb.h
+ resources/beingcommon.cpp
+ resources/beingcommon.h
resources/beinginfo.cpp
resources/beinginfo.h
resources/chardb.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 8147ed384..2d5453955 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -433,6 +433,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
resources/atlasmanager.h \
resources/avatardb.cpp \
resources/avatardb.h \
+ resources/beingcommon.cpp \
+ resources/beingcommon.h \
resources/beinginfo.cpp \
resources/beinginfo.h \
resources/chardb.cpp \
diff --git a/src/resources/beingcommon.cpp b/src/resources/beingcommon.cpp
new file mode 100644
index 000000000..fc58dbbc7
--- /dev/null
+++ b/src/resources/beingcommon.cpp
@@ -0,0 +1,44 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2013 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "resources/beingcommon.h"
+
+#include "logger.h"
+
+#include "resources/beinginfo.h"
+
+#include "debug.h"
+
+
+void BeingCommon::readBasicAttributes(BeingInfo *const info, XmlNodePtr node,
+ const std::string &hoverCursor)
+{
+ info->setTargetCursorSize(XML::getProperty(node,
+ "targetCursor", "medium"));
+
+ info->setHoverCursor(XML::getProperty(node, "hoverCursor", hoverCursor));
+
+ info->setTargetOffsetX(XML::getProperty(node, "targetOffsetX", 0));
+ info->setTargetOffsetY(XML::getProperty(node, "targetOffsetY", 0));
+
+ info->setNameOffsetX(XML::getProperty(node, "nameOffsetX", 0));
+ info->setNameOffsetY(XML::getProperty(node, "nameOffsetY", 0));
+ info->setSortOffsetY(XML::getProperty(node, "sortOffsetY", 0));
+}
diff --git a/src/resources/beingcommon.h b/src/resources/beingcommon.h
new file mode 100644
index 000000000..a8d3a5b8f
--- /dev/null
+++ b/src/resources/beingcommon.h
@@ -0,0 +1,38 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2013 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RESOURCES_BEINGCOMMON_H
+#define RESOURCES_BEINGCOMMON_H
+
+#include <stdint.h>
+
+#include "utils/xml.h"
+
+#include "localconsts.h"
+
+class BeingInfo;
+
+namespace BeingCommon
+{
+ void readBasicAttributes(BeingInfo *const info, XmlNodePtr node,
+ const std::string &hoverCursor);
+}
+
+#endif // RESOURCES_BEINGCOMMON_H
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index f3c81d52d..769678ca6 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -26,6 +26,7 @@
#include "net/net.h"
+#include "resources/beingcommon.h"
#include "resources/beinginfo.h"
#include "utils/dtor.h"
@@ -98,29 +99,10 @@ void MonsterDB::loadXmlFile(const std::string &fileName)
// TRANSLATORS: unknown info name
monsterNode, "name", _("unnamed")));
- currentInfo->setTargetCursorSize(XML::getProperty(monsterNode,
- "targetCursor", "medium"));
-
- currentInfo->setHoverCursor(XML::getProperty(monsterNode,
- "hoverCursor", "attack"));
-
- currentInfo->setTargetOffsetX(XML::getProperty(monsterNode,
- "targetOffsetX", 0));
-
- currentInfo->setTargetOffsetY(XML::getProperty(monsterNode,
- "targetOffsetY", 0));
-
- currentInfo->setNameOffsetX(XML::getProperty(monsterNode,
- "nameOffsetX", 0));
-
- currentInfo->setNameOffsetY(XML::getProperty(monsterNode,
- "nameOffsetY", 0));
+ BeingCommon::readBasicAttributes(currentInfo, monsterNode, "attack");
currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0));
- currentInfo->setSortOffsetY(XML::getProperty(
- monsterNode, "sortOffsetY", 0));
-
currentInfo->setDeadSortOffsetY(XML::getProperty(
monsterNode, "deadSortOffsetY", 31));
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index 103bbb805..f9d9295d6 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -24,6 +24,7 @@
#include "logger.h"
+#include "resources/beingcommon.h"
#include "resources/beinginfo.h"
#include "utils/dtor.h"
@@ -90,26 +91,7 @@ void NPCDB::loadXmlFile(const std::string &fileName)
currentInfo->setTargetSelection(XML::getBoolProperty(npcNode,
"targetSelection", true));
- currentInfo->setTargetCursorSize(XML::getProperty(npcNode,
- "targetCursor", "medium"));
-
- currentInfo->setHoverCursor(XML::getProperty(npcNode,
- "hoverCursor", "talk"));
-
- currentInfo->setTargetOffsetX(XML::getProperty(npcNode,
- "targetOffsetX", 0));
-
- currentInfo->setTargetOffsetY(XML::getProperty(npcNode,
- "targetOffsetY", 0));
-
- currentInfo->setNameOffsetX(XML::getProperty(npcNode,
- "nameOffsetX", 0));
-
- currentInfo->setNameOffsetY(XML::getProperty(npcNode,
- "nameOffsetY", 0));
-
- currentInfo->setSortOffsetY(XML::getProperty(npcNode,
- "sortOffsetY", 0));
+ BeingCommon::readBasicAttributes(currentInfo, npcNode, "talk");
currentInfo->setDeadSortOffsetY(XML::getProperty(npcNode,
"deadSortOffsetY", 31));
diff --git a/src/resources/petdb.cpp b/src/resources/petdb.cpp
index 806e20e72..a85480e7b 100644
--- a/src/resources/petdb.cpp
+++ b/src/resources/petdb.cpp
@@ -24,6 +24,7 @@
#include "logger.h"
+#include "resources/beingcommon.h"
#include "resources/beinginfo.h"
#include "utils/dtor.h"
@@ -76,20 +77,7 @@ void PETDB::load()
currentInfo->setTargetSelection(XML::getBoolProperty(petNode,
"targetSelection", false));
- currentInfo->setTargetCursorSize(XML::getProperty(petNode,
- "targetCursor", "medium"));
-
- currentInfo->setHoverCursor(XML::getProperty(petNode,
- "hoverCursor", "talk"));
-
- currentInfo->setTargetOffsetX(XML::getProperty(petNode,
- "targetOffsetX", 0));
-
- currentInfo->setTargetOffsetY(XML::getProperty(petNode,
- "targetOffsetY", 0));
-
- currentInfo->setSortOffsetY(XML::getProperty(petNode,
- "sortOffsetY", 0));
+ BeingCommon::readBasicAttributes(currentInfo, petNode, "talk");
currentInfo->setDeadSortOffsetY(XML::getProperty(petNode,
"deadSortOffsetY", 31));