]> jfr.im git - irc/gameservirc.git/commitdiff
A little bit more work on testing and minor modifications
authorkainazzzo <redacted>
Fri, 11 Sep 2009 03:03:49 +0000 (03:03 +0000)
committerkainazzzo <redacted>
Fri, 11 Sep 2009 03:03:49 +0000 (03:03 +0000)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@513 bc333340-6410-0410-a689-9d09f3c113fa

gameserv-2.0/libgameservcore/include/GameServ/GameServException.h
gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/PlayerGO.h
gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/PlayerGO.cpp
gameserv-2.0/testdriver/main.cpp

index 2660efe777dc989f1920cac09c6013f76cdc1528..d2469c58f0458c5094f644d8301c8877a9ed273c 100644 (file)
@@ -4,81 +4,81 @@
 #include <string>\r
 using std::string;\r
 \r
-namespace GameServ 
-{ 
-       //! GameServ generic exceptions
-       namespace Exceptions
-       {
-               //! Generic base exception for all GameServ related exceptions that occur
-               /*!
-                       These generic exception allows applications and services to catch
-                       all exceptions in a generic way, and even pass them off to log files, 
-                       etc.  It's recommended that developers make use of the standard macros
-                       __FILE__ and __LINE__.  You can compose exception error message strings 
-                       using boost's format function coupled with boost::str like so:
-                       \code
-                       // Make a string
-                       str(format("Failed to jump rope at time of %1%:%2%") % hour % minute));
-                       \endcode
-
-                       Developers should use caution when adding exceptions.  Exceptions are great
-                       for finding errors cross boundries, they shouldn't be used as interrupt handlers
-                       or methods to localize handling of error conditions.
-               */
-               class GameServException
-               {
-               public:
-                       //! Fully composed exception
-                       /*!
-                               Recommended construction for a GameServ exception that helps developers and
-                               support the most.
-                               \param ErrorMsg The custom error message to associated with the 
-                               exception. Even though this is a reference, it's copied locally to 
-                               the class.
-                               \param Filename The name of the source file, use the standard macro
-                               __FILE__
-                               \param SourceLine The line number that the error occurred on, use
-                               __LINE__
-                       */
-                       GameServException(const string &ErrorMsg, const char *Filename, int SourceLine);
-
-                       //! Partially composed exception
-                       /*!
-                               Generic message
-                               \param ErrorMsg The custom error message to associated with the 
-                               exception. Even though this is a reference, it's copied locally to 
-                               the class.
-                       */
-                       GameServException(const string &ErrorMsg);
-
-                       //! Generic exception
-                       /*!
-                               This is a generic GameServ exception constructor
-                       */
-                       GameServException(void);
-
-                       // Properties /////////////////////////////////////////////////////////////
-                       
-                       //! Property get: Error Message
-                       const string ErrorMessage(void) const;
-
-                       //! Property get: Source Filename
-                       const char *Filename(void) const;
-
-                       //! Property get: Source Line Number
-                       const int LineNumber(void) const;
-
-                       //! Property get: Builds a full error string
-                       const string VerboseError(void) const;
-                       
-               private:
-                       
-                       string mErrorMsg;
-                       const char *mpFilename;
-                       int mLineNumber;
-               
-               };
-       } 
+namespace GameServ \r
+{ \r
+       //! GameServ generic exceptions\r
+       namespace Exceptions\r
+       {\r
+               //! Generic base exception for all GameServ related exceptions that occur\r
+               /*!\r
+                       These generic exception allows applications and services to catch\r
+                       all exceptions in a generic way, and even pass them off to log files, \r
+                       etc.  It's recommended that developers make use of the standard macros\r
+                       __FILE__ and __LINE__.  You can compose exception error message strings \r
+                       using boost's format function coupled with boost::str like so:\r
+                       \code\r
+                       // Make a string\r
+                       str(format("Failed to jump rope at time of %1%:%2%") % hour % minute));\r
+                       \endcode\r
+\r
+                       Developers should use caution when adding exceptions.  Exceptions are great\r
+                       for finding errors cross boundries, they shouldn't be used as interrupt handlers\r
+                       or methods to localize handling of error conditions.\r
+               */\r
+               class GameServException\r
+               {\r
+               public:\r
+                       //! Fully composed exception\r
+                       /*!\r
+                               Recommended construction for a GameServ exception that helps developers and\r
+                               support the most.\r
+                               \param ErrorMsg The custom error message to associated with the \r
+                               exception. Even though this is a reference, it's copied locally to \r
+                               the class.\r
+                               \param Filename The name of the source file, use the standard macro\r
+                               __FILE__\r
+                               \param SourceLine The line number that the error occurred on, use\r
+                               __LINE__\r
+                       */\r
+                       GameServException(const string &ErrorMsg, const char *Filename, int SourceLine);\r
+\r
+                       //! Partially composed exception\r
+                       /*!\r
+                               Generic message\r
+                               \param ErrorMsg The custom error message to associated with the \r
+                               exception. Even though this is a reference, it's copied locally to \r
+                               the class.\r
+                       */\r
+                       GameServException(const string &ErrorMsg);\r
+\r
+                       //! Generic exception\r
+                       /*!\r
+                               This is a generic GameServ exception constructor\r
+                       */\r
+                       GameServException(void);\r
+\r
+                       // Properties /////////////////////////////////////////////////////////////\r
+                       \r
+                       //! Property get: Error Message\r
+                       const string ErrorMessage(void) const;\r
+\r
+                       //! Property get: Source Filename\r
+                       const char *Filename(void) const;\r
+\r
+                       //! Property get: Source Line Number\r
+                       const int LineNumber(void) const;\r
+\r
+                       //! Property get: Builds a full error string\r
+                       const string VerboseError(void) const;\r
+                       \r
+               private:\r
+                       \r
+                       string mErrorMsg;\r
+                       const char *mpFilename;\r
+                       int mLineNumber;\r
+               \r
+               };\r
+       } \r
 }\r
 \r
 #endif\r
index 2c168851ce0372e6f443e1d12a2452aa3bf5f03f..cbc2aee4ffd9d2eb68f09eb57824b1271a1991e3 100644 (file)
@@ -19,6 +19,10 @@ using std::string;
 #include <vector>\r
 using std::vector;\r
 \r
+\r
+#include <boost/date_time/posix_time/posix_time.hpp>\r
+using boost::posix_time::ptime;\r
+\r
 namespace GameServ { namespace GameLayer { namespace GameObjects\r
 {\r
        class PlayerGO : public GameObject\r
@@ -104,6 +108,11 @@ namespace GameServ { namespace GameLayer { namespace GameObjects
                //! Property get - Password\r
                string Password(void) const;\r
 \r
+               //! Property set - LastLogin\r
+               void LastLogin(const ptime &value);\r
+               //! Property get - LastLogin\r
+               ptime LastLogin(void) const;\r
+\r
                bool operator==(const PlayerGO &right) const;\r
                bool operator!=(const PlayerGO &right) const;\r
 \r
@@ -125,7 +134,7 @@ namespace GameServ { namespace GameLayer { namespace GameObjects
                shared_ptr<WeaponGO> mWeapon;\r
                shared_ptr<ArmorGO> mArmor;\r
                vector< shared_ptr<ItemGO> > mInventory;\r
-\r
+               ptime mLastLogin;\r
        };\r
 }}} // GameServ::GameLayer::GameObjects\r
 #endif
\ No newline at end of file
index a6fd61e147328e5aa32195e3c8f6d20bca1bc4e2..417c1304fec4d0cf62865e43a8fdd179c6c9dbc7 100644 (file)
@@ -11,6 +11,9 @@ using boost::shared_ptr;
 #include <GameServ/GameServException.h>\r
 using GameServ::Exceptions::GameServException;\r
 \r
+#include <boost/date_time/posix_time/posix_time.hpp>\r
+using boost::posix_time::ptime;\r
+\r
 PlayerGO::PlayerGO() : GameObject(), mName(""), mLevel(1), mExperience(0), mGold(0), mHealth(0), mMaxHealth(0), mStrength(1),\r
 mDefense(1), mForestFights(0), mPlayerFights(0), mPassword("")\r
 {\r
@@ -183,6 +186,16 @@ string PlayerGO::Password(void) const
        return mPassword;\r
 }\r
 \r
+void PlayerGO::LastLogin(const ptime &value)\r
+{\r
+       mLastLogin = value;\r
+}\r
+\r
+ptime PlayerGO::LastLogin(void) const\r
+{\r
+       return mLastLogin;\r
+}\r
+\r
 bool PlayerGO::operator !=(const PlayerGO &right) const\r
 {\r
        return !(*this == right);\r
@@ -205,4 +218,3 @@ PlayerGO *PlayerGO::Clone(void) const
        return new PlayerGO(*this);\r
 }\r
 \r
-\r
index 1b57d2a417605d50fd54dbf6dee32ad9531245dc..c3321805148e132da479eb3be9b03771308524b0 100644 (file)
@@ -5,9 +5,22 @@ using GameServ::GameLayer::GameObjects::PlayerGO;
 #include <GameServ/GameLayer/PlayerGL.h>\r
 using GameServ::GameLayer::PlayerGL;\r
 \r
+#include <GameServ/GameServException.h>\r
+using GameServ::Exceptions::GameServException;\r
+\r
 int main()\r
 {\r
-       PlayerGL pgl;\r
-       shared_ptr<PlayerGO> spPlayer = pgl.GetById("1");\r
+       try\r
+       {\r
+               PlayerGL pgl;\r
+               shared_ptr<PlayerGO> spPlayer = pgl.GetById("Kain");\r
+       }\r
+       catch (GameServException &e)\r
+       {\r
+               cout << e.VerboseError() << endl;\r
+               string temp;\r
+               cin >> temp;\r
+       }\r
+\r
        return 0;\r
 }\r