From b3fb42d3225282bc146847488a74536953a2d726 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Sat, 28 Feb 2015 21:19:19 +0300
Subject: Build mailhandler only if eathena enabled.

---
 src/CMakeLists.txt              | 6 +++---
 src/Makefile.am                 | 8 ++++----
 src/net/mailhandler.h           | 3 +++
 src/net/net.cpp                 | 4 ++--
 src/net/tmwa/generalhandler.cpp | 4 ++--
 src/net/tmwa/generalhandler.h   | 2 +-
 src/net/tmwa/mailhandler.h      | 3 +++
 7 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 25deb17d6..38d74913d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -539,7 +539,6 @@ SET(SRCS
     net/ea/inventoryitem.h
     net/logindata.h
     net/loginhandler.h
-    net/mailhandler.h
     net/markethandler.h
     net/mercenaryhandler.h
     net/messagehandler.h
@@ -1338,8 +1337,6 @@ SET(SRCS_TMWA
     net/tmwa/itemhandler.h
     net/tmwa/loginhandler.cpp
     net/tmwa/loginhandler.h
-    net/tmwa/mailhandler.cpp
-    net/tmwa/mailhandler.h
     net/tmwa/markethandler.cpp
     net/tmwa/markethandler.h
     net/tmwa/mercenaryhandler.cpp
@@ -1394,6 +1391,8 @@ SET(SRCS_TMWAEATHENA
     net/tmwa/friendshandler.h
     net/tmwa/homunculushandler.cpp
     net/tmwa/homunculushandler.h
+    net/tmwa/mailhandler.cpp
+    net/tmwa/mailhandler.h
     )
 
 SET(SRCS_EATHENA
@@ -1425,6 +1424,7 @@ SET(SRCS_EATHENA
     net/familyhandler.h
     net/friendshandler.h
     net/homunculushandler.h
+    net/mailhandler.h
     net/eathena/adminhandler.cpp
     net/eathena/adminhandler.h
     net/eathena/auctionhandler.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index efc993a16..72c23b5a1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -665,7 +665,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
 	      net/ea/inventoryitem.h \
 	      net/logindata.h \
 	      net/loginhandler.h \
-	      net/mailhandler.h \
 	      net/mercenaryhandler.h \
 	      net/markethandler.h \
 	      net/messagehandler.h \
@@ -1269,8 +1268,6 @@ manaplus_SOURCES += \
 	      net/tmwa/itemhandler.h \
 	      net/tmwa/loginhandler.cpp \
 	      net/tmwa/loginhandler.h \
-	      net/tmwa/mailhandler.cpp \
-	      net/tmwa/mailhandler.h \
 	      net/tmwa/markethandler.cpp \
 	      net/tmwa/markethandler.h \
 	      net/tmwa/mercenaryhandler.cpp \
@@ -1325,7 +1322,9 @@ manaplus_SOURCES += net/tmwa/auctionhandler.cpp \
 	      net/tmwa/friendshandler.cpp \
 	      net/tmwa/friendshandler.h \
 	      net/tmwa/homunculushandler.cpp \
-	      net/tmwa/homunculushandler.h
+	      net/tmwa/homunculushandler.h \
+	      net/tmwa/mailhandler.cpp \
+	      net/tmwa/mailhandler.h
 endif
 
 manaplus_CXXFLAGS += -DEATHENA_SUPPORT
@@ -1357,6 +1356,7 @@ manaplus_SOURCES += gui/windows/bankwindow.cpp \
 	      net/familyhandler.h \
 	      net/friendshandler.h \
 	      net/homunculushandler.h \
+	      net/mailhandler.h \
 	      net/eathena/adminhandler.cpp \
 	      net/eathena/adminhandler.h \
 	      net/eathena/auctionhandler.cpp \
diff --git a/src/net/mailhandler.h b/src/net/mailhandler.h
index f21eb0f2c..f277392ec 100644
--- a/src/net/mailhandler.h
+++ b/src/net/mailhandler.h
@@ -21,6 +21,8 @@
 #ifndef NET_MAILHANDLER_H
 #define NET_MAILHANDLER_H
 
+#ifdef EATHENA_SUPPORT
+
 #include <string>
 
 #include "localconsts.h"
@@ -57,4 +59,5 @@ class MailHandler notfinal
 
 extern Net::MailHandler *mailHandler;
 
+#endif  // EATHENA_SUPPORT
 #endif  // NET_MAILHANDLER_H
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 5a6156653..9c6d7df07 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -49,6 +49,7 @@ namespace Net
     class FamilyHandler;
     class FriendsHandler;
     class HomunculusHandler;
+    class MailHandler;
 #endif
     class AdminHandler;
     class BeingHandler;
@@ -59,7 +60,6 @@ namespace Net
     class GeneralHandler;
     class GuildHandler;
     class InventoryHandler;
-    class MailHandler;
     class MarketHandler;
     class MercenaryHandler;
     class NpcHandler;
@@ -91,7 +91,6 @@ Net::TradeHandler *tradeHandler = nullptr;
 Net::BeingHandler *beingHandler = nullptr;
 Net::BuySellHandler *buySellHandler = nullptr;
 Net::ServerFeatures *serverFeatures = nullptr;
-Net::MailHandler *mailHandler = nullptr;
 Net::MercenaryHandler *mercenaryHandler = nullptr;
 #ifdef EATHENA_SUPPORT
 Net::AuctionHandler *auctionHandler = nullptr;
@@ -102,6 +101,7 @@ Net::ElementalHandler *elementalHandler = nullptr;
 Net::FamilyHandler *familyHandler = nullptr;
 Net::FriendsHandler *friendsHandler = nullptr;
 Net::HomunculusHandler *homunculusHandler = nullptr;
+Net::MailHandler *mailHandler = nullptr;
 #endif
 Net::QuestHandler *questHandler = nullptr;
 Net::MarketHandler *marketHandler = nullptr;
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 2a353df80..a1b1f45bc 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -105,7 +105,6 @@ GeneralHandler::GeneralHandler() :
     mTradeHandler(new TradeHandler),
     mQuestHandler(new QuestHandler),
     mServerFeatures(new ServerFeatures),
-    mMailHandler(new MailHandler),
 #ifdef EATHENA_SUPPORT
     mAuctionHandler(new AuctionHandler),
     mBankHandler(new BankHandler),
@@ -115,6 +114,7 @@ GeneralHandler::GeneralHandler() :
     mFamilyHandler(new FamilyHandler),
     mFriendsHandler(new FriendsHandler),
     mHomunculusHandler(new HomunculusHandler),
+    mMailHandler(new MailHandler),
 #endif
     mMercenaryHandler(new MercenaryHandler),
     mMarketHandler(new MarketHandler),
@@ -235,7 +235,6 @@ void GeneralHandler::load()
     mNetwork->registerHandler(mPartyHandler);
     mNetwork->registerHandler(mPetHandler);
     mNetwork->registerHandler(mQuestHandler);
-    mNetwork->registerHandler(mMailHandler);
 #ifdef EATHENA_SUPPORT
     mNetwork->registerHandler(mAuctionHandler);
     mNetwork->registerHandler(mBankHandler);
@@ -245,6 +244,7 @@ void GeneralHandler::load()
     mNetwork->registerHandler(mFamilyHandler);
     mNetwork->registerHandler(mFriendsHandler);
     mNetwork->registerHandler(mHomunculusHandler);
+    mNetwork->registerHandler(mMailHandler);
 #endif
     mNetwork->registerHandler(mMercenaryHandler);
     mNetwork->registerHandler(mMarketHandler);
diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h
index 746df8460..dcd717b70 100644
--- a/src/net/tmwa/generalhandler.h
+++ b/src/net/tmwa/generalhandler.h
@@ -81,7 +81,6 @@ class GeneralHandler final : public MessageHandler,
         MessageHandlerPtr mTradeHandler;
         MessageHandlerPtr mQuestHandler;
         ServerFeatures *mServerFeatures;
-        MessageHandlerPtr mMailHandler;
 #ifdef EATHENA_SUPPORT
         MessageHandlerPtr mAuctionHandler;
         MessageHandlerPtr mBankHandler;
@@ -91,6 +90,7 @@ class GeneralHandler final : public MessageHandler,
         MessageHandlerPtr mFamilyHandler;
         MessageHandlerPtr mFriendsHandler;
         MessageHandlerPtr mHomunculusHandler;
+        MessageHandlerPtr mMailHandler;
 #endif
         MessageHandlerPtr mMercenaryHandler;
         MessageHandlerPtr mMarketHandler;
diff --git a/src/net/tmwa/mailhandler.h b/src/net/tmwa/mailhandler.h
index c891f484f..26e50eafb 100644
--- a/src/net/tmwa/mailhandler.h
+++ b/src/net/tmwa/mailhandler.h
@@ -21,6 +21,8 @@
 #ifndef NET_TMWA_MAILHANDLER_H
 #define NET_TMWA_MAILHANDLER_H
 
+#ifdef EATHENA_SUPPORT
+
 #include "net/mailhandler.h"
 
 #include "net/tmwa/messagehandler.h"
@@ -58,4 +60,5 @@ class MailHandler final : public MessageHandler, public Net::MailHandler
 
 }  // namespace TmwAthena
 
+#endif  // EATHENA_SUPPORT
 #endif  // NET_TMWA_MAILHANDLER_H
-- 
cgit v1.2.3-70-g09d2