]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Animations: fix regression in previous commit
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 8 Dec 2015 10:46:26 +0000 (21:46 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 8 Dec 2015 10:46:26 +0000 (21:46 +1100)
qcsrc/common/animdecide.qc
qcsrc/common/animdecide.qh
qcsrc/lib/oo.qh

index 84e395aa24c35c8883664e666ee29f9e7e3c0b81..44b3c1baf5fe68a85080bf3666c1783d10922ee4 100644 (file)
@@ -66,6 +66,8 @@ void animdecide_load_if_needed(entity e)
                        return;
        }
 
+#define ANIM_VEC(a, frames, rate) anim_vec(ANIM_##a, mdlidx, frames, rate)
+
        vector none = '0 0 0';
        e.anim_die1 = animfixfps(e, ANIM_VEC(die1, 1, 0.5), none); // 2 seconds
        e.anim_die2 = animfixfps(e, ANIM_VEC(die2, 1, 0.5), none); // 2 seconds
@@ -96,6 +98,8 @@ void animdecide_load_if_needed(entity e)
        e.anim_duckwalkbackright = animfixfps(e, ANIM_VEC(duckwalkbackright, 1,  1), ANIM_VEC(duckwalk, 1, 1));
        e.anim_duckwalkbackleft  = animfixfps(e, ANIM_VEC(duckwalkbackleft , 1,  1), ANIM_VEC(duckwalk, 1, 1));
 
+#undef ANIM_VEC
+
        // these anims ought to stay until stopped explicitly by weaponsystem
        e.anim_shoot_z = 0.001;
        e.anim_melee_z = 0.001;
index 7cf7ee45509d530d4fee3c2002c266179be2f755..0869cb79a1dba754030ae24be50ec7a1d00cd01b 100644 (file)
@@ -10,7 +10,7 @@ void animdecide_setframes(entity e, bool support_blending, .int fld_frame, .int
 
 CLASS(Animation, Object)
        ATTRIB(Animation, m_framenames, string, string_null)
-       METHOD(Animation, anim_getframe, int(Animation this, int mdlidx))
+       STATIC_METHOD(Animation, getframe, int(Animation this, int mdlidx))
        {
                FOREACH_WORD(this.m_framenames, true, {
                        int f = frameforname(mdlidx, it);
@@ -31,16 +31,14 @@ REGISTER_REGISTRY(Animations)
                this.m_framenames = framenames; \
        }
 
-vector _ANIM_VEC_v;
-Animation _ANIM_VEC_a;
-#define ANIM_VEC(anim, numframes, framerate) \
-( \
-       _ANIM_VEC_v.y = numframes, \
-       _ANIM_VEC_v.z = framerate, \
-       _ANIM_VEC_a = ANIM_##anim, \
-       _ANIM_VEC_v.x = _ANIM_VEC_a.anim_getframe(_ANIM_VEC_a, mdlidx), \
-       _ANIM_VEC_v \
-)
+vector anim_vec(Animation anim, int mdlidx, int numframes, float framerate)
+{
+       vector v;
+       v.x = Animation_getframe(anim, mdlidx);
+       v.y = numframes;
+       v.z = framerate;
+       return v;
+}
 
 // player animation data for this model
 // each vector is as follows:
@@ -51,12 +49,9 @@ Animation _ANIM_VEC_a;
 REGISTER_ANIMATION(die1, "dieone groupified_0_anim");
 /** player dies differently */
 REGISTER_ANIMATION(die2, "dietwo groupified_1_anim");
-/**  */
-REGISTER_ANIMATION(dead1, "deadone groupified_17_anim");
-/**  */
-REGISTER_ANIMATION(dead2, "deadtwo groupified_18_anim");
 /** player pulls out a weapon */
 REGISTER_ANIMATION(draw, "draw groupified_2_anim");
+REGISTER_ANIMATION(duck, "duck groupified_3_anim");
 /** player walking while crouching */
 REGISTER_ANIMATION(duckwalk, "duckwalk groupified_4_anim");
 /** player jumping from a crouch */
@@ -83,6 +78,10 @@ REGISTER_ANIMATION(runbackwards, "runbackwards groupified_14_anim");
 REGISTER_ANIMATION(strafeleft, "strafeleft groupified_15_anim");
 /** player shuffling right quickly */
 REGISTER_ANIMATION(straferight, "straferight groupified_16_anim");
+/**  */
+REGISTER_ANIMATION(dead1, "deadone groupified_17_anim");
+/**  */
+REGISTER_ANIMATION(dead2, "deadtwo groupified_18_anim");
 /** player running forward and right */
 REGISTER_ANIMATION(forwardright, "forwardright groupified_19_anim");
 /** player running forward and left */
@@ -93,7 +92,6 @@ REGISTER_ANIMATION(backright, "backright groupified_21_anim");
 REGISTER_ANIMATION(backleft, "backleft groupified_22_anim");
 /** player doing the melee action */
 REGISTER_ANIMATION(melee, "melee groupified_23_anim");
-REGISTER_ANIMATION(duck, "duck groupified_3_anim");
 REGISTER_ANIMATION(duckwalkbackwards, "duckwalkbackwards groupified_24_anim");
 REGISTER_ANIMATION(duckwalkstrafeleft, "duckwalkstrafeleft duckstrafeleft groupified_25_anim");
 REGISTER_ANIMATION(duckwalkstraferight, "duckwalkstraferight duckstraferight groupified_26_anim");
index d7e9df848865a02039757ba6f92e12d39ecc9b7f..51c16d8c50d3d770eb92ea6588ef2397ecd9d058 100644 (file)
@@ -158,14 +158,20 @@ STATIC_INIT(RegisterClasses)
                spawn##base##_1(this);              \
        }
 
-#define METHOD(cname, name, prototype)      \
-       class(cname).prototype name;           \
-       prototype cname##_##name;               \
+#define METHOD_REFERENCE(cname, name) \
+       cname##_##name
+
+#define STATIC_METHOD(cname, name, prototype) \
+       prototype METHOD_REFERENCE(cname, name)
+
+#define METHOD(cname, name, prototype) \
+       class(cname).prototype name; \
+       STATIC_METHOD(cname, name, prototype); \
        INIT_STATIC(cname) \
        { \
-               this.name = cname##_##name; \
+               this.name = METHOD_REFERENCE(cname, name); \
        } \
-       prototype cname##_##name
+       STATIC_METHOD(cname, name, prototype)
 
 #define ATTRIB(cname, name, type, val)      \
        class(cname).type name;                \