]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Skeleton.cpp
Cleaned up handling of envsounds array through a function
[lugaru.git] / Source / Skeleton.cpp
index 0f06dd3c011405a881c26ee5b2984d25560ab58d..af343d6b3261b3a405f876f877e665a7a6813c85 100644 (file)
@@ -26,17 +26,12 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 
 extern float multiplier;
 extern float gravity;
-extern Skeleton testskeleton;
 extern Terrain terrain;
 extern Objects objects;
 extern int environment;
 extern float camerashake;
 extern bool freeze;
 extern int detail;
-extern XYZ envsound[30];
-extern float envsoundvol[30];
-extern int numenvsounds;
-extern float envsoundlife[30];
 extern int tutoriallevel;
 
 extern int whichjointstartarray[26];
@@ -351,10 +346,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale)
 
                             emit_sound_at(breaksound2, joints[i].position * (*scale) + *coords);
 
-                            envsound[numenvsounds] = *coords;
-                            envsoundvol[numenvsounds] = 64;
-                            envsoundlife[numenvsounds] = .4;
-                            numenvsounds++;
+                            addEnvSound(*coords, 64);
                         }
 
                     if (findLengthfast(&bounceness) > 2500) {
@@ -439,10 +431,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale)
 
                                             emit_sound_at(breaksound2, joints[i].position * (*scale) + *coords);
 
-                                            envsound[numenvsounds] = *coords;
-                                            envsoundvol[numenvsounds] = 64;
-                                            envsoundlife[numenvsounds] = .4;
-                                            numenvsounds++;
+                                            addEnvSound(*coords, 64);
                                         }
                                     if (objects.type[k] == treetrunktype) {
                                         objects.rotx[k] += joints[i].velocity.x * multiplier * .4;
@@ -683,7 +672,7 @@ void Animation::Load(const char *filename, int aheight, int aattack)
 {
     FILE *tfile;
     int i, j;
-    XYZ startoffset, endoffset;
+    XYZ endoffset;
 
     // path to dir
     const char *anim_prefix = ":Data:Animations:";
@@ -782,18 +771,14 @@ void Animation::Load(const char *filename, int aheight, int aattack)
         fclose(tfile);
     }
 
-    startoffset = 0;
     endoffset = 0;
-    // find average position of certain joints on first and last frames
-    // and save in startoffset, endoffset
+    // find average position of certain joints on last frames
+    // and save in endoffset
     // (not sure what exactly this accomplishes. the y < 1 test confuses me.)
     for (j = 0; j < joints; j++) {
-        if (position[j][0].y < 1)
-            startoffset += position[j][0];
         if (position[j][numframes - 1].y < 1)
             endoffset += position[j][numframes - 1];
     }
-    startoffset /= joints;
     endoffset /= joints;
     offset = endoffset;
     offset.y = 0;