]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv-2.0/libgameservcore/include/GameServ/Types.h
Revisited GameServ 2.0 and got it compiling in VS 2010!
[irc/gameservirc.git] / gameserv-2.0 / libgameservcore / include / GameServ / Types.h
index 821d066197c4d304edefd5031483cfebc9bf8efd..9e6636fb56f8dcb35d0e09953e4df9c970a1caeb 100644 (file)
@@ -1,32 +1,12 @@
 #ifndef __GS__TYPES_H__\r
 #define __GS__TYPES_H__\r
 \r
+#include <ctime>\r
 #include <string>\r
 using std::string;\r
 #include <GameServ/GameServException.h>\r
 using GameServ::Exceptions::GameServException;\r
 \r
-#include <ctime>\r
-#include <boost/random/linear_congruential.hpp>\r
-#include <boost/random/uniform_int.hpp>\r
-#include <boost/random/uniform_real.hpp>\r
-#include <boost/random/variate_generator.hpp>\r
-// Sun CC doesn't handle boost::iterator_adaptor yet\r
-#if !defined(__SUNPRO_CC) || (__SUNPRO_CC > 0x530)\r
-#include <boost/generator_iterator.hpp>\r
-#endif\r
-\r
-#ifdef BOOST_NO_STDC_NAMESPACE\r
-namespace std {\r
-  using ::time;\r
-}\r
-#endif\r
-\r
-// This is a typedef for a random number generator.\r
-// Try boost::mt19937 or boost::ecuyer1988 instead of boost::minstd_rand\r
-typedef boost::minstd_rand base_generator_type;\r
-\r
-\r
 namespace GameServ \r
 {              \r
        namespace Types\r
@@ -122,83 +102,74 @@ namespace GameServ
                        static const modifierinfo mModifierInfoTable[];\r
                }; // Modifiers class\r
 \r
-               template <class T>\r
-               class Range\r
+               class IntRange\r
                {\r
                public:\r
 \r
-                       Range()\r
-                       {\r
-                       }\r
+                       IntRange();\r
 \r
-                       Range(const T &high, const T &low)\r
-                       {\r
-                               mHigh = high;\r
-                               mLow = low;\r
-                               mLastRandom = T(0);\r
-                       }\r
+                       IntRange(const int &high, const int &low);\r
 \r
-                       ~Range()\r
-                       {\r
-                       }\r
+                       ~IntRange();\r
 \r
-                       //! Generate a random number within the range\r
-                       T Random()\r
-                       {\r
-                               static base_generator_type generator(static_cast<T>(std::time(0)));\r
-                               if (mLow == mHigh)\r
-                               {\r
-                                       return mLow;\r
-                               }\r
-                               else\r
-                               {\r
-                                       boost::uniform_int<> uni_dist(mLow, mHigh);\r
-                                       boost::variate_generator<base_generator_type&, boost::uniform_int<> > uni(generator, uni_dist);\r
-                                       mLastRandom = uni();\r
-                                       return mLastRandom;\r
-                               }\r
-                       }\r
+                       //! Generate a random number within the IntRange\r
+                       int Random();\r
 \r
                        //! Property get - High\r
-                       T High(void) const\r
-                       {\r
-                               return mHigh;\r
-                       }\r
+                       int High(void) const;\r
                        \r
                        //! Property set - High\r
-                       void High(const T &value)\r
-                       {\r
-                               if (value >= mLow)\r
-                               {\r
-                                       mHigh = value;\r
-                               }\r
-                       }\r
+                       void High(const int &value);\r
 \r
                        //! Property get - Low\r
-                       T Low(void) const\r
-                       {\r
-                               return mLow;\r
-                       }\r
+                       int Low(void) const;\r
+                       \r
 \r
                        //! Property set - Low\r
-                       void Low(const T &value)\r
-                       {\r
-                               if (value <= mHigh)\r
-                               {\r
-                                       mLow = value;\r
-                               }\r
-                       }\r
+                       void Low(const int &value);\r
 \r
                        //! Property get - Last random number to be generated\r
-                       T LastRandom(void) const\r
-                       {\r
-                               return mLastRandom;\r
-                       }\r
+                       int LastRandom(void) const;\r
+                       \r
+                       \r
+               private:\r
+                       int mHigh;\r
+                       int mLow;\r
+                       int mLastRandom;\r
+               };\r
+\r
+               class UIntRange\r
+               {\r
+               public:\r
+\r
+                       UIntRange();\r
+\r
+                       UIntRange(const unsigned int &high, const unsigned int &low);\r
+\r
+                       ~UIntRange();\r
+\r
+                       //! Generate a random number within the IntRange\r
+                       unsigned int Random();\r
+\r
+                       //! Property get - High\r
+                       unsigned int High(void) const;\r
+\r
+                       //! Property set - High\r
+                       void High(const unsigned int &value);\r
+\r
+                       //! Property get - Low\r
+                       unsigned int Low(void) const;\r
+\r
+                       //! Property set - Low\r
+                       void Low(const unsigned int &value);\r
+\r
+                       //! Property get - Last random number to be generated\r
+                       unsigned int LastRandom(void) const;\r
                        \r
                private:\r
-                       T mHigh;\r
-                       T mLow;\r
-                       T mLastRandom;\r
+                       unsigned int mHigh;\r
+                       unsigned int mLow;\r
+                       unsigned int mLastRandom;\r
                };\r
        } \r
 }\r