]> jfr.im git - irc/gameservirc.git/commitdiff
Fixed up Modifiers for items
authorkainazzzo <redacted>
Mon, 14 Sep 2009 17:53:40 +0000 (17:53 +0000)
committerkainazzzo <redacted>
Mon, 14 Sep 2009 17:53:40 +0000 (17:53 +0000)
Completed the existing ItemTypes functionality
Changed shared_ptr include to be direct
Did a lot of work on the FileArmorDAO

git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@517 bc333340-6410-0410-a689-9d09f3c113fa

24 files changed:
gameserv-2.0/libgameservcore/include/GameServ/Types.h
gameserv-2.0/libgameservcore/src/Types.cpp
gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/DataAccess.h
gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FileDAOFactory.h
gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FileId.h
gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/File/FilePlayerDAO.h
gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/IDAOFactory.h
gameserv-2.0/libgameservgldl/include/GameServ/DataLayer/IPlayerDAO.h
gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/GameObject.h
gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/ItemGO.h
gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/PlayerGO.h
gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/PlayerGL.h
gameserv-2.0/libgameservgldl/libgameservgldl.vcproj
gameserv-2.0/libgameservgldl/src/DataLayer/DataAccess.cpp
gameserv-2.0/libgameservgldl/src/DataLayer/File/FileArmorDAO.cpp
gameserv-2.0/libgameservgldl/src/DataLayer/File/FileDAOFactory.cpp
gameserv-2.0/libgameservgldl/src/DataLayer/File/FileId.cpp
gameserv-2.0/libgameservgldl/src/DataLayer/File/FilePlayerDAO.cpp
gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/ArmorGO.cpp
gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/GameObject.cpp
gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/ItemGO.cpp
gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/PlayerGO.cpp
gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/WeaponGO.cpp
gameserv-2.0/testdriver/testdriver.vcproj

index 4554ba50aaac99169cdeb425185a47b177eb1203..ce7efa2950c7bb822dc599fbd06899f077f6a55d 100644 (file)
@@ -44,12 +44,35 @@ namespace GameServ
                        typedef struct itemtypeinfo\r
                        {\r
                                ItemTypes::ItemType itemtype;   //!< The ItemType enumeration value\r
-                               const char *name;                               //!< The Name of the type\r
+                               string name;                            //!< The Name of the type\r
                        } itemtypeinfo;\r
 \r
                        static const itemtypeinfo mItemTypeInfoTable[];\r
 \r
                }; // ItemTypes class\r
-       }\r
+\r
+               class Modifiers\r
+               {\r
+               public:\r
+                       //! Logical Modifer enumerator\r
+                       enum Modifier\r
+                       {\r
+                               strength, defense, maxhp, hp, forestfights, playerfights, gold, bank\r
+                       };\r
+\r
+                       //! Get the name of a modifier\r
+                       static string GetName(Modifier modifier);\r
+\r
+                       //! Parse the name and return the modifier enumeration value\r
+                       static Modifier Parse(const string &modifier);\r
+               private:\r
+                       typedef struct modifierinfo\r
+                       {\r
+                               Modifiers::Modifier modifier; //!< The modifier enumeration value\r
+                               string name; //!< The name of the modifier\r
+                       } modifierinfo;\r
+                       static const modifierinfo mModifierInfoTable[];\r
+               }; // Modifiers class\r
+       } \r
 }\r
 #endif
\ No newline at end of file
index 42fd3d29b011e13062c25ddd3448314e697d7a0f..bf11953f3875519b8d144ff03cb0f9c1732335c9 100644 (file)
@@ -1,5 +1,6 @@
 #include <GameServ/Types.h>\r
 using GameServ::Types::ItemTypes;\r
+using GameServ::Types::Modifiers;\r
 using GameServ::Types::Exceptions::TypeException;\r
 \r
 #include <string>\r
@@ -13,17 +14,17 @@ using std::exception;
 using boost::format;\r
 using boost::str;\r
 \r
-TypeException::TypeException(const string &ErrorMsg, const char *pFilename, int SourceLine)
-: GameServException(ErrorMsg, pFilename, SourceLine)
-{ }
-
-TypeException::TypeException(const string &ErrorMsg)
-: GameServException(ErrorMsg)
-{ }
-                               
-TypeException::TypeException(void)
-: GameServException("Type Exception occurred either do to conversion or improper type usage.", __FILE__, __LINE__)
-{ }
+TypeException::TypeException(const string &ErrorMsg, const char *pFilename, int SourceLine)\r
+: GameServException(ErrorMsg, pFilename, SourceLine)\r
+{ }\r
+\r
+TypeException::TypeException(const string &ErrorMsg)\r
+: GameServException(ErrorMsg)\r
+{ }\r
+                               \r
+TypeException::TypeException(void)\r
+: GameServException("Type Exception occurred either do to conversion or improper type usage.", __FILE__, __LINE__)\r
+{ }\r
 \r
 const ItemTypes::itemtypeinfo ItemTypes::mItemTypeInfoTable[] =\r
 {\r
@@ -36,11 +37,57 @@ string ItemTypes::GetName(ItemTypes::ItemType itemtype)
        {\r
                if (mItemTypeInfoTable[i].itemtype == itemtype)\r
                {\r
-                       return string(mItemTypeInfoTable[i].name);\r
+                       return mItemTypeInfoTable[i].name;\r
                }\r
        }\r
 \r
        // This should never happen because an enumeration is passed, but in the case where a user\r
        // may attempt an invalid integer cast, it provides protection\r
        throw TypeException(str(format("No item type found for %1% enumeration value") % itemtype).c_str());\r
+}\r
+\r
+ItemTypes::ItemType ItemTypes::Parse(const string &itemtype)\r
+{\r
+       for (unsigned int i = 0; i < sizeof(mItemTypeInfoTable) / sizeof(itemtypeinfo); i++)\r
+       {\r
+               if (mItemTypeInfoTable[i].name == itemtype)\r
+               {\r
+                       return mItemTypeInfoTable[i].itemtype;\r
+               }\r
+       }\r
+       return ItemTypes::NOTYPE;\r
+}\r
+\r
+const Modifiers::modifierinfo Modifiers::mModifierInfoTable[] =\r
+{\r
+       { strength, "Strength"}, { defense, "Defense" }, { maxhp, "MaxHP" }, { hp, "HP" }, { forestfights, "Forest Fights" },\r
+       { playerfights, "Player Fights" }, { gold, "Gold" }, { bank, "Bank" }\r
+};\r
+\r
+string Modifiers::GetName(Modifiers::Modifier modifier)\r
+{\r
+       for (unsigned int i = 0; i < sizeof(mModifierInfoTable) / sizeof(modifierinfo); i++)\r
+       {\r
+               if (mModifierInfoTable[i].modifier == modifier)\r
+               {\r
+                       return mModifierInfoTable[i].name;\r
+               }\r
+       }\r
+\r
+       // This should never happen because an enumeration is passed, but in the case where a user\r
+       // may attempt an invalid integer cast, it provides protection\r
+       throw TypeException(str(format("No item type found for %1% enumeration value") % modifier).c_str());\r
+}\r
+\r
+Modifiers::Modifier Modifiers::Parse(const string &modifier)\r
+{\r
+       for (unsigned int i = 0; i < sizeof(mModifierInfoTable) / sizeof(modifierinfo); i++)\r
+       {\r
+               if (mModifierInfoTable[i].name == modifier)\r
+               {\r
+                       return mModifierInfoTable[i].modifier;\r
+               }\r
+       }\r
+\r
+       throw TypeException(str(format("No modifier enumeration found for %1%") % modifier), __FILE__, __LINE__);\r
 }
\ No newline at end of file
index f2e051eda7d4ec41fa1c52407e66012dd7bfc735..8c11f0fbf31acb60d3a1be7796e64d0e4f5021bb 100644 (file)
@@ -4,7 +4,7 @@
 #include <GameServ/DataLayer/IDAOFactory.h>\r
 using GameServ::DataLayer::IDAOFactory;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 namespace GameServ { namespace DataLayer\r
index 535678a7ab8e4b69147c932af1629ba8f7f1e9a0..25e6b199126277322c40903660767fcb6c478c25 100644 (file)
@@ -10,7 +10,7 @@ using GameServ::DataLayer::DataAccessObjects::IPlayerDAO;
 #include <GameServ/DataLayer/IArmorDAO.h>\r
 using GameServ::DataLayer::DataAccessObjects::IArmorDAO;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 namespace GameServ { namespace DataLayer { namespace File\r
index 8454c8874dffb4d681ec16d46833ca772f20fbd6..f7d3ac55bd759010f87d4a14ca85bf126a9ac7be 100644 (file)
@@ -4,12 +4,19 @@
 #include <string>\r
 using std::string;\r
 \r
+#include <GameServ/Types.h>\r
+using GameServ::Types::ItemTypes;\r
+\r
 namespace GameServ { namespace DataLayer { namespace File {\r
        class FileId\r
        {\r
        public:\r
                static string CreatePlayerId(const string &Name);\r
                static string GetNameFromPlayerId(const string &Id);\r
+\r
+               static string CreateItemId(ItemTypes::ItemType type, const string &Number);\r
+               static ItemTypes::ItemType GetItemTypeFromId(const string &Id);\r
+               static string GetItemNumberFromId(const string &Id);\r
        private:\r
                FileId();\r
                ~FileId();\r
index f81d771c86217dd8fcbdae740aff1047af48e040..f7dba6eabc9adece4b7bf9580b9fe5727dbf3acc 100644 (file)
@@ -6,7 +6,7 @@
 using GameServ::GameLayer::GameObjects::PlayerGO;\r
 using GameServ::DataLayer::DataAccessObjects::IPlayerDAO;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 #include <string>\r
index a7c1427f91a6be7d9dbc073fa3f467cca05a74f9..28ae8c086f26057411762d11a7a8542fdc3c01d4 100644 (file)
@@ -6,7 +6,7 @@ using GameServ::DataLayer::DataAccessObjects::IPlayerDAO;
 #include <GameServ/DataLayer/IArmorDAO.h>\r
 using GameServ::DataLayer::DataAccessObjects::IArmorDAO;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 namespace GameServ { namespace DataLayer \r
index d71fcd0e320e9f96a44bd4a36f1e9650c948b6e5..2d82a68af15c7e1d8260e14a85042a2894dc445f 100644 (file)
@@ -4,7 +4,7 @@
 #include <GameServ/GameLayer/GameObjects/PlayerGO.h>\r
 using GameServ::GameLayer::GameObjects::PlayerGO;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 #include <list>\r
index ba634ad4ff20242f196728273c3afc0c23ba7ff3..2bf44427490787125f9af74d425a7338cb547e04 100644 (file)
@@ -5,7 +5,7 @@
 using std::string;\r
 using std::unary_function;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 namespace GameServ { namespace GameLayer { namespace GameObjects\r
index 7c48fcbb42b259ad1180b6fa178bdfe682889fb0..9370fcb316c714ec363f65238512128713557a02 100644 (file)
@@ -4,11 +4,12 @@
 using GameServ::GameLayer::GameObjects::GameObject;\r
 #include <GameServ/Types.h>\r
 using GameServ::Types::ItemTypes;\r
+using GameServ::Types::Modifiers;\r
 \r
 #include <string>\r
 using std::string;\r
-#include <vector>\r
-using std::vector;\r
+#include <map>\r
+using std::map;\r
 \r
 namespace GameServ { namespace GameLayer { namespace GameObjects {\r
 \r
@@ -16,7 +17,6 @@ namespace GameServ { namespace GameLayer { namespace GameObjects {
        {\r
        public:\r
                ItemGO();\r
-               ItemGO(const string &name, const unsigned long int &price, const int &uses, const vector<string> &modifiers);\r
                virtual ~ItemGO();\r
 \r
                //! Property get - Name\r
@@ -41,9 +41,10 @@ namespace GameServ { namespace GameLayer { namespace GameObjects {
                void Type(const ItemTypes::ItemType &value);\r
 \r
                //! Property get - Modifiers\r
-               vector<string> Modifiers(void) const;\r
+               map<Modifiers::Modifier, int> Modifiers(void) const;\r
+\r
                //! Property set - Modifiers\r
-               void Modifiers(const vector<string> &value);\r
+               void Modifiers(const map<Modifiers::Modifier, int> &modifiers);\r
 \r
                virtual ItemGO *Clone(void) const;\r
 \r
@@ -52,7 +53,7 @@ namespace GameServ { namespace GameLayer { namespace GameObjects {
                unsigned long int mPrice;\r
                int mUses;\r
                ItemTypes::ItemType mType;\r
-               vector<string> mModifiers;\r
+               map<Modifiers::Modifier, int> mModifiers;\r
        };\r
 }}}\r
 #endif
\ No newline at end of file
index 2022f712169dac316f65d68c2f8a1767b5144aca..6bac5cfd094a4eb3fe7983e3e51676a327024bba 100644 (file)
@@ -11,7 +11,7 @@ using GameServ::GameLayer::GameObjects::ArmorGO;
 #include <GameServ/GameLayer/GameObjects/WeaponGO.h>\r
 using GameServ::GameLayer::GameObjects::WeaponGO;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 #include <string>\r
index 60e74cb2f65c5acc9d19efb6689b7243621c033e..562255e8da781a8dcdbf601558d21b7428dfbe2b 100644 (file)
@@ -4,7 +4,7 @@
 #include <GameServ/DataLayer/IPlayerDAO.h>\r
 using GameServ::DataLayer::DataAccessObjects::IPlayerDAO;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 #include <list>\r
index 2643caecb8fadb750aa5f51a604a8adf16c28bfd..29b6799ca6d8958186e63dc39fe187b0d10c14ea 100644 (file)
@@ -44,7 +44,7 @@
                                PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS ;_SCL_SECURE_NO_WARNINGS"\r
                                MinimalRebuild="true"\r
                                BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="3"\r
+                               RuntimeLibrary="1"\r
                                WarningLevel="3"\r
                                Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="4"\r
index a65542bfc75a295a84348365516f02fd93c4816d..dce5cad75790f427c5c8214c57762dab867cef43 100644 (file)
@@ -6,7 +6,7 @@ using GameServ::DataLayer::DataAccess;
 using GameServ::DataLayer::Exceptions::DataLayerException;\r
 using GameServ::DataLayer::File::FileDAOFactory;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 #include <boost/format.hpp>\r
 using boost::shared_ptr;\r
 using boost::format;\r
index d148fbb8a1bce6706d523eef5bda867f62b086ed..af1179c8b1ccb008f2f83039de507896d8f6b9aa 100644 (file)
@@ -10,6 +10,10 @@ using GameServ::DataLayer::Exceptions::DataLayerException;
 #include <GameServ/DataLayer/File/FileId.h>\r
 using GameServ::DataLayer::File::FileId;\r
 \r
+#include <GameServ/Types.h>\r
+using GameServ::Types::ItemTypes;\r
+using GameServ::Types::Modifiers;\r
+\r
 #include <boost/shared_ptr.hpp>\r
 #include <boost/format.hpp>\r
 #include <boost/algorithm/string.hpp>\r
@@ -88,12 +92,39 @@ shared_ptr<ArmorGO> FileArmorDAO::CreateArmorFromLine(const string &line) const
 {\r
        assert(!line.empty());\r
        shared_ptr<ArmorGO> spArmor;\r
+       map<Modifiers::Modifier, int> modifiers;\r
        spArmor = shared_ptr<ArmorGO>(new ArmorGO());\r
-       boost::char_separator<char> sep(" ", 0, boost::keep_empty_tokens);\r
+       boost::char_separator<char> sep("~", 0, boost::keep_empty_tokens);\r
        tokenizer tokens(line, sep);\r
        tokenizer::iterator tok_iter = tokens.begin();\r
-\r
-\r
+       if ((*tok_iter) != "2")\r
+               return shared_ptr<ArmorGO>();\r
+       tok_iter++;\r
+       spArmor->Id(FileId::CreateItemId(ItemTypes::Armor, (*tok_iter)));\r
+\r
+       tok_iter++;\r
+       spArmor->Name((*tok_iter));\r
+       tok_iter++;\r
+       spArmor->Price(lexical_cast<unsigned long int>((*tok_iter)));\r
+       tok_iter++;\r
+       spArmor->Uses(lexical_cast<int>((*tok_iter)));\r
+       tok_iter++;\r
+       modifiers[Modifiers::strength] = lexical_cast<int>((*tok_iter));\r
+       tok_iter++;\r
+       modifiers[Modifiers::defense] = lexical_cast<int>((*tok_iter));\r
+       tok_iter++;\r
+       modifiers[Modifiers::maxhp] = lexical_cast<int>((*tok_iter));\r
+       tok_iter++;\r
+       modifiers[Modifiers::hp] = lexical_cast<int>((*tok_iter));\r
+       tok_iter++;\r
+       modifiers[Modifiers::forestfights] = lexical_cast<int>((*tok_iter));\r
+       tok_iter++;\r
+       modifiers[Modifiers::playerfights] = lexical_cast<int>((*tok_iter));\r
+       tok_iter++;\r
+       modifiers[Modifiers::gold] = lexical_cast<int>((*tok_iter));\r
+       tok_iter++;\r
+       modifiers[Modifiers::bank] = lexical_cast<int>((*tok_iter));\r
+       spArmor->Modifiers(modifiers);\r
 \r
        return spArmor;\r
 }\r
@@ -106,4 +137,29 @@ bool FileArmorDAO::IdExists(const string &Id) const
 \r
 void FileArmorDAO::LoadArmorCache(void)\r
 {\r
+       ifstream infile;\r
+       infile.open(mFilename.c_str());\r
+\r
+       if (infile.fail())\r
+       {\r
+               throw DataLayerException(str(format("Unable to open %1% for reading") % mFilename), __FILE__, __LINE__);\r
+       }\r
+       string line;\r
+       while (getline(infile, line))\r
+       {\r
+               if (line.length() == 0)\r
+               {\r
+                       continue;\r
+               }\r
+               if (line[0] == '#')\r
+               {\r
+                       continue;\r
+               }\r
+               shared_ptr<ArmorGO> spArmor = CreateArmorFromLine(line);\r
+               if (spArmor != 0)\r
+               {\r
+                       spArmorCache[spArmor->Id()] = spArmor;\r
+               }\r
+       }\r
+       infile.close();\r
 }
\ No newline at end of file
index ef66a60f0be1808a8088ac97b5923e6fcd7e938a..a825849df62ec3209629b8e22bfe04f1193788d2 100644 (file)
@@ -6,7 +6,7 @@ using GameServ::DataLayer::File::FileDAOFactory;
 using GameServ::DataLayer::File::FilePlayerDAO;\r
 using GameServ::DataLayer::File::FileArmorDAO;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 FileDAOFactory::FileDAOFactory(void)\r
index fb1f737e75351d529e763421a82cc71a0c48f6f8..5030de31ec8427a56d1207529f5ca76cc1b6cdb4 100644 (file)
@@ -4,6 +4,19 @@ using GameServ::DataLayer::File::FileId;
 #include <string>\r
 using std::string;\r
 \r
+#include <GameServ/Types.h>\r
+using GameServ::Types::ItemTypes;\r
+\r
+#include <GameServ/GameServException.h>\r
+using GameServ::Exceptions::GameServException;\r
+\r
+#include <boost/format.hpp>\r
+#include <boost/algorithm/string.hpp>\r
+#include <boost/lexical_cast.hpp>\r
+using boost::str;\r
+using boost::format;\r
+using boost::lexical_cast;\r
+\r
 FileId::FileId()\r
 {\r
 }\r
@@ -21,3 +34,26 @@ string FileId::GetNameFromPlayerId(const string &Id)
 {\r
        return Id;\r
 }\r
+\r
+string FileId::CreateItemId(ItemTypes::ItemType type, const string &Number)\r
+{\r
+       string id = ItemTypes::GetName(type) + ":" + Number;\r
+       return id;\r
+}\r
+\r
+ItemTypes::ItemType FileId::GetItemTypeFromId(const string &Id)\r
+{\r
+       size_t colon = Id.find_first_of(":");\r
+       if (colon == string::npos)\r
+               throw GameServException(str(format("Invalid Item ID %1%") % Id), __FILE__, __LINE__);\r
+       \r
+       return ItemTypes::Parse(Id.substr(0, colon));\r
+}\r
+\r
+string FileId::GetItemNumberFromId(const string &Id)\r
+{\r
+       size_t colon = Id.find_first_of(":");\r
+       if (colon == string::npos)\r
+               throw GameServException(str(format("Invalid Item ID %1%") % Id), __FILE__, __LINE__);\r
+       return Id.substr(colon + 1);\r
+}
\ No newline at end of file
index f0a3880ea60795348764e3fba4cc3c32de52d99c..e85195a4b90de5f506b982769fb7226f32ca8721 100644 (file)
@@ -10,7 +10,7 @@ using GameServ::DataLayer::Exceptions::DataLayerException;
 #include <GameServ/DataLayer/File/FileId.h>\r
 using GameServ::DataLayer::File::FileId;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 #include <boost/format.hpp>\r
 #include <boost/algorithm/string.hpp>\r
 #include <boost/lexical_cast.hpp>\r
index a94fc1a10bd8cf1266c5575dc1d47a9465075b1c..311a889dc8eb252f70f8e9fdca8902fd111a8369 100644 (file)
@@ -1,10 +1,14 @@
 #include <GameServ/GameLayer/GameObjects/ArmorGO.h>\r
 using GameServ::GameLayer::GameObjects::ArmorGO;\r
 \r
+#include <GameServ/Types.h>\r
+using GameServ::Types::Modifiers;\r
+using GameServ::Types::ItemTypes;\r
+\r
 #include <string>\r
 using std::string;\r
-#include <vector>\r
-using std::vector;\r
+#include <map>\r
+using std::map;\r
 \r
 #include <boost/format.hpp>\r
 #include <boost/algorithm/string.hpp>\r
@@ -23,9 +27,9 @@ ItemGO()
        mPrice = price;\r
        mUses = uses;\r
        mModifiers.clear();\r
-       mModifiers.push_back(str(format("STRENGTH + %d") % strength));\r
-       mModifiers.push_back(str(format("DEFENSE + %d") % defense));\r
-       mModifiers.push_back(str(format("MAXHP + %d") % maxhp));\r
+       mModifiers[Modifiers::strength] = strength;\r
+       mModifiers[Modifiers::defense] = defense;\r
+       mModifiers[Modifiers::maxhp] = maxhp;\r
 }\r
 \r
 ArmorGO::~ArmorGO()\r
index 93daa5c1b1205d5256a70cc788533362366e6d72..8041cc91aaa04103b50f571a27b7ca3c5053a5d1 100644 (file)
@@ -5,7 +5,7 @@ using GameServ::GameLayer::GameObjects::GameObjectIds_Eq;
 #include <string>\r
 using std::string;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 GameObject::GameObject(void) : mId()\r
index 7c045ca0243b691ff645ec84821ff45ee0416338..b2309d26613032dfc4e99735c323cacdcd71ec12 100644 (file)
@@ -3,25 +3,18 @@ using GameServ::GameLayer::GameObjects::ItemGO;
 \r
 #include <GameServ/Types.h>\r
 using GameServ::Types::ItemTypes;\r
+using GameServ::Types::Modifiers;\r
 \r
 #include <string>\r
 using std::string;\r
-#include <vector>\r
-using std::vector;\r
+#include <map>\r
+using std::map;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 ItemGO::ItemGO() : GameObject(), mName(""), mPrice(0), mUses(1), mType(ItemTypes::NOTYPE)\r
 {\r
-       mModifiers.resize(8);\r
-}\r
-\r
-ItemGO::ItemGO(const string &name, const unsigned long &price, const int &uses, const vector<string> &modifiers) : GameObject(),\r
-mName(name), mPrice(price), mUses(uses), mType(ItemTypes::NOTYPE)\r
-{\r
-       mModifiers.clear();\r
-       mModifiers.insert(mModifiers.begin(), modifiers.begin(), modifiers.end());\r
 }\r
 \r
 ItemGO::~ItemGO()\r
@@ -68,15 +61,15 @@ void ItemGO::Type(const ItemTypes::ItemType &value)
        mType = value;\r
 }\r
 \r
-vector<string> ItemGO::Modifiers(void) const\r
+map<Modifiers::Modifier, int> ItemGO::Modifiers(void) const\r
 {\r
        return mModifiers;\r
 }\r
 \r
-void ItemGO::Modifiers(const vector<string> &value)\r
+void ItemGO::Modifiers(const map<Modifiers::Modifier, int> &modifiers)\r
 {\r
        mModifiers.clear();\r
-       mModifiers.insert(mModifiers.begin(), value.begin(), value.end());\r
+       mModifiers.insert(modifiers.begin(), modifiers.end());\r
 }\r
 \r
 ItemGO *ItemGO::Clone(void) const\r
index 7d9520f8f8fb199922d1017aa91052e7115671e5..efe34fc128a3b0fc87c628f177c5712d8d4ceebf 100644 (file)
@@ -5,7 +5,7 @@ using GameServ::GameLayer::GameObjects::ArmorGO;
 #include <GameServ/GameLayer/GameObjects/WeaponGO.h>\r
 using GameServ::GameLayer::GameObjects::WeaponGO;\r
 \r
-#include <boost/shared_ptr.hpp>\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
 using boost::shared_ptr;\r
 \r
 #include <GameServ/GameServException.h>\r
index 40edef53e69a5612b91858ecee68ee72d9bb31af..2f482961960136c9f137446deb238c1d0a5d9ed2 100644 (file)
@@ -3,10 +3,13 @@ using GameServ::GameLayer::GameObjects::ItemGO;
 #include <GameServ/GameLayer/GameObjects/WeaponGO.h>\r
 using GameServ::GameLayer::GameObjects::WeaponGO;\r
 \r
+#include <GameServ/Types.h>\r
+using GameServ::Types::Modifiers;\r
+\r
 #include <string>\r
 using std::string;\r
-#include <vector>\r
-using std::vector;\r
+#include <map>\r
+using std::map;\r
 \r
 #include <boost/format.hpp>\r
 #include <boost/algorithm/string.hpp>\r
@@ -24,9 +27,9 @@ ItemGO()
        mPrice = price;\r
        mUses = uses;\r
        mModifiers.clear();\r
-       mModifiers.push_back(str(format("STRENGTH + %d") % strength));\r
-       mModifiers.push_back(str(format("DEFENSE + %d") % defense));\r
-       mModifiers.push_back(str(format("MAXHP + %d") % maxhp));\r
+       mModifiers[Modifiers::strength] = strength;\r
+       mModifiers[Modifiers::defense] = defense;\r
+       mModifiers[Modifiers::maxhp] = maxhp;\r
 }\r
 \r
 WeaponGO::~WeaponGO()\r
index 0a2ba01f5157cacce760f72f2dca36efb7819c76..ac7c9869caa306d11580d34e23952434fa03960a 100644 (file)
@@ -43,7 +43,7 @@
                                AdditionalIncludeDirectories="$(SolutionDir)/libgameservgldl/include;$(SolutionDir)/libgameservcore/include"\r
                                MinimalRebuild="true"\r
                                BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="3"\r
+                               RuntimeLibrary="1"\r
                                WarningLevel="3"\r
                                DebugInformationFormat="4"\r
                        />\r