]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Animation/Animation.cpp
Applied clang-format on all files
[lugaru.git] / Source / Animation / Animation.cpp
index af6c31955293c23826739819478f8f8832b26d92..a8ad6e19cf448dba073e62923b5d527d84af1290 100644 (file)
@@ -17,19 +17,19 @@ You should have received a copy of the GNU General Public License
 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "Animation/Skeleton.h"
-#include "Animation/Animation.h"
-#include "Utils/Folders.h"
-#include "Game.h"
+#include "Animation/Animation.hpp"
 
-extern bool visibleloading;
+#include "Animation/Skeleton.hpp"
+#include "Game.hpp"
+#include "Utils/Folders.hpp"
 
 std::vector<Animation> Animation::animations;
 
 void Animation::loadAll()
 {
-    int i = 0;
-#define DECLARE_ANIM(id, file, height, attack, ...) if (i++ < loadable_anim_end) animations.emplace_back(file, height, attack);
+#define DECLARE_ANIM(id, file, height, attack, ...) \
+    if (id < loadable_anim_end)                     \
+        animations.emplace_back(file, height, attack);
 #include "Animation.def"
 #undef DECLARE_ANIM
 }
@@ -72,37 +72,37 @@ void AnimationFrame::loadWeaponTarget(FILE* tfile)
     funpackf(tfile, "Bf Bf Bf", &weapontarget.x, &weapontarget.y, &weapontarget.z);
 }
 
-Animation::Animation():
-    height(0),
-    attack(0),
-    numjoints(0)
+Animation::Animation()
+    : height(lowheight)
+    , attack(neutral)
+    numjoints(0)
 {
 }
 
 /* EFFECT
  * load an animation from file
  */
-Animation::Animation(const std::string& filename, int aheight, int aattack):
-    Animation()
+Animation::Animation(const std::string& filename, anim_height_type aheight, anim_attack_type aattack)
+    Animation()
 {
-    FILE *tfile;
-    int i, j, numframes;
+    FILE* tfile;
+    int numframes;
+    unsigned i;
 
     LOGFUNC;
 
     // Changing the filename into something the OS can understand
-    std::string filepath = Folders::getResourcePath("Animations/"+filename);
+    std::string filepath = Folders::getResourcePath("Animations/" + filename);
 
     LOG(std::string("Loading animation...") + filepath);
 
     height = aheight;
     attack = aattack;
 
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
     // read file in binary mode
-    tfile = Folders::openMandatoryFile( filepath, "rb" );
+    tfile = Folders::openMandatoryFile(filepath, "rb");
 
     // read numframes, joints to know how much memory to allocate
     funpackf(tfile, "Bi Bi", &numframes, &numjoints);
@@ -141,16 +141,12 @@ Animation::Animation(const std::string& filename, int aheight, int aattack):
     // 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 < numjoints; j++) {
-        if (frames.back().joints[j].position.y < 1) {
-            endoffset += frames.back().joints[j].position;
+    for (i = 0; i < frames.back().joints.size(); i++) {
+        if (frames.back().joints[i].position.y < 1) {
+            endoffset += frames.back().joints[i].position;
         }
     }
     endoffset /= numjoints;
     offset = endoffset;
     offset.y = 0;
 }
-
-Animation::~Animation()
-{
-}