]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Person.h
player replaced by Person::players which is a vector of shared_ptr.
[lugaru.git] / Source / Person.h
index 754a046676763e5f138798723124659e11fdad68..9faac6a2f4d214162bc9d8924049516a567cb048 100644 (file)
@@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "Terrain.h"
 #include "Sprite.h"
 #include <cmath>
+#include <memory>
 #include "Weapons.h"
 #include "Animation.h"
 
@@ -47,9 +48,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define rabbittype 0
 #define wolftype 1
 
-class Person
+class Person : public enable_shared_from_this<Person>
 {
 public:
+    static std::vector<std::shared_ptr<Person>> players;
+
     int whichpatchx;
     int whichpatchz;
 
@@ -153,7 +156,7 @@ public:
 
     float grabdelay;
 
-    Person *victim;
+    std::shared_ptr<Person> victim;
     bool hasvictim;
 
     float updatedelay;
@@ -326,10 +329,11 @@ public:
 
 
 
-    // convenience
-    Joint& joint(int);
-    XYZ& jointPos(int);
-    XYZ& jointVel(int);
+    // convenience functions
+    inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
+    inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
+    inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
+
 
     void CheckKick();
     void CatchFire();
@@ -393,5 +397,6 @@ public:
 };
 
 const int maxplayers = 10;
-extern Person player[maxplayers];
+//~ extern Person player[maxplayers];
+
 #endif