]> git.jsancho.org Git - lugaru.git/commitdiff
Cleanup animation loading
authorAlexander Monakov <amonakov@gmail.com>
Sun, 6 Jun 2010 23:02:26 +0000 (03:02 +0400)
committerAlexander Monakov <amonakov@gmail.com>
Sun, 6 Jun 2010 23:02:26 +0000 (03:02 +0400)
CMakeLists.txt
Source/Animation.def
Source/Animation.h
Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/Skeleton.cpp
Source/Skeleton.h

index d36f0f8c7f3ecbae37f7a88dfed2f82a898c9bcf..f2f3df6cb0f52b911329f90cb4bbc6ab2477aeb3 100644 (file)
@@ -80,6 +80,7 @@ set(LUGARU_SRCS
        ${SRCDIR}/Input.cpp
        ${SRCDIR}/Settings.cpp
        ${SRCDIR}/Stereo.cpp
+       ${SRCDIR}/Animation.cpp
 )
 
 set(LUGARU_H
index 49aec9fbe7f37698d73b322eb28eec0d9e937d83..3b33c385fe28669b6bdc473ea570ea57486b1d09 100644 (file)
@@ -129,6 +129,8 @@ DECLARE_ANIM(dead2anim, "Dead2", lowheight, neutral)
 DECLARE_ANIM(dead3anim, "Dead3", lowheight, neutral)
 DECLARE_ANIM(dead4anim, "Dead4", lowheight, neutral)
 
+DECLARE_ANIM(loadable_anim_end, "", 0, 0)
+
 /* Not implemented.  */
 DECLARE_ANIM(rabbittacklereversal, "", 0, 0)
 DECLARE_ANIM(rabbittacklereversed, "", 0, 0)
index b8e821b721dff7e41daff1f2996d09b5c718e799..b292813f31429369e7f0c8aa56fbc04e87c92ca8 100644 (file)
@@ -39,4 +39,6 @@ animation_count
 };
 
 extern Animation animation[animation_count];
+
+extern void loadAllAnimations();
 #endif
index dccc88982116918000264b9e5f5a5eecd0e61956..e8e16827b762168ca06d531ba8f13a0975072ac8 100644 (file)
@@ -1444,126 +1444,7 @@ void Game::LoadStuff()
        rabbitcoords=player[0].coords;
        rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z);
 
-       animation[runanim].Load((char *)":Data:Animations:Run",middleheight,neutral);
-
-       animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
-       animation[stopanim].Load((char *)":Data:Animations:Stop",middleheight,neutral);
-
-       animation[jumpupanim].Load((char *)":Data:Animations:JumpUp",highheight,neutral);
-       animation[jumpdownanim].Load((char *)":Data:Animations:JumpDown",highheight,neutral);
-
-       animation[landanim].Load((char *)":Data:Animations:Landing",lowheight,neutral);
-       animation[landhardanim].Load((char *)":Data:Animations:Landhard",lowheight,neutral);
-       animation[climbanim].Load((char *)":Data:Animations:Climb",lowheight,neutral);
-       animation[hanganim].Load((char *)":Data:Animations:Hangon",lowheight,neutral);
-       animation[spinkickanim].Load((char *)":Data:Animations:SpinKick",middleheight,normalattack);
-
-       animation[getupfromfrontanim].Load((char *)":Data:Animations:GetUpFromFront",lowheight,neutral);
-       animation[getupfrombackanim].Load((char *)":Data:Animations:GetUpFromBack",lowheight,neutral);
-       animation[crouchanim].Load((char *)":Data:Animations:Crouch",lowheight,neutral);
-       animation[sneakanim].Load((char *)":Data:Animations:Sneak",lowheight,neutral);
-       animation[rollanim].Load((char *)":Data:Animations:Roll",lowheight,neutral);
-       animation[flipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
-       animation[frontflipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
-       animation[spinkickreversedanim].Load((char *)":Data:Animations:SpinKickCaught",middleheight,reversed);
-
-       animation[spinkickreversalanim].Load((char *)":Data:Animations:SpinKickCatch",middleheight,reversal);
-       animation[lowkickanim].Load((char *)":Data:Animations:lowkick",middleheight,normalattack);
-       animation[sweepanim].Load((char *)":Data:Animations:sweep",lowheight,normalattack);
-       animation[sweepreversedanim].Load((char *)":Data:Animations:SweepCaught",lowheight,reversed);
-       animation[sweepreversalanim].Load((char *)":Data:Animations:SweepCatch",middleheight,reversal);
-       animation[rabbitkickanim].Load((char *)":Data:Animations:RabbitKick",middleheight,normalattack);
-       animation[rabbitkickreversedanim].Load((char *)":Data:Animations:RabbitKickCaught",middleheight,reversed);
-       animation[rabbitkickreversalanim].Load((char *)":Data:Animations:RabbitKickCatch",lowheight,reversal);
-       animation[upunchanim].Load((char *)":Data:Animations:Upunch",middleheight,normalattack);
-       animation[staggerbackhighanim].Load((char *)":Data:Animations:Staggerbackhigh",middleheight,neutral);
-       animation[upunchreversedanim].Load((char *)":Data:Animations:UpunchCaught",middleheight,reversed);
-
-       animation[upunchreversalanim].Load((char *)":Data:Animations:UpunchCatch",middleheight,reversal);
-       animation[hurtidleanim].Load((char *)":Data:Animations:Hurtidle",middleheight,neutral);
-       animation[backhandspringanim].Load((char *)":Data:Animations:Backhandspring",middleheight,neutral);
-       animation[fightidleanim].Load((char *)":Data:Animations:Fightidle",middleheight,neutral);
-       animation[walkanim].Load((char *)":Data:Animations:Walk",middleheight,neutral);
-
-       animation[fightsidestep].Load((char *)":Data:Animations:Fightsidestep",middleheight,neutral);
-       animation[killanim].Load((char *)":Data:Animations:Kill",middleheight,normalattack);
-       animation[sneakattackanim].Load((char *)":Data:Animations:Sneakattack",middleheight,reversal);
-       animation[sneakattackedanim].Load((char *)":Data:Animations:Sneakattacked",middleheight,reversed);
-       animation[drawrightanim].Load((char *)":Data:Animations:drawright",middleheight,neutral);
-       animation[knifeslashstartanim].Load((char *)":Data:Animations:slashstart",middleheight,normalattack);
-       animation[crouchdrawrightanim].Load((char *)":Data:Animations:crouchdrawright",lowheight,neutral);
-       animation[crouchstabanim].Load((char *)":Data:Animations:crouchstab",lowheight,normalattack);
-
-       animation[knifefollowanim].Load((char *)":Data:Animations:slashfollow",middleheight,reversal);
-       animation[knifefollowedanim].Load((char *)":Data:Animations:slashfollowed",middleheight,reversed);
-       animation[knifethrowanim].Load((char *)":Data:Animations:knifethrow",middleheight,normalattack);
-       animation[removeknifeanim].Load((char *)":Data:Animations:removeknife",middleheight,neutral);
-       animation[crouchremoveknifeanim].Load((char *)":Data:Animations:crouchremoveknife",lowheight,neutral);
-       animation[jumpreversedanim].Load((char *)":Data:Animations:JumpCaught",middleheight,reversed);
-       animation[jumpreversalanim].Load((char *)":Data:Animations:JumpCatch",middleheight,reversal);
-       animation[staggerbackhardanim].Load((char *)":Data:Animations:Staggerbackhard",middleheight,neutral);
-
-       animation[dropkickanim].Load((char *)":Data:Animations:Dropkick",middleheight,normalattack);
-       animation[winduppunchanim].Load((char *)":Data:Animations:Winduppunch",middleheight,normalattack);
-       animation[winduppunchblockedanim].Load((char *)":Data:Animations:Winduppunchblocked",middleheight,normalattack);
-       animation[blockhighleftanim].Load((char *)":Data:Animations:Blockhighleft",middleheight,normalattack);
-       animation[blockhighleftstrikeanim].Load((char *)":Data:Animations:Blockhighleftstrike",middleheight,normalattack);
-       animation[backflipanim].Load((char *)":Data:Animations:Backflip",highheight,neutral);
-       animation[walljumpbackanim].Load((char *)":Data:Animations:Walljumpback",highheight,neutral);
-       animation[walljumpfrontanim].Load((char *)":Data:Animations:Walljumpfront",highheight,neutral);
-       animation[rightflipanim].Load((char *)":Data:Animations:Rightflip",highheight,neutral);
-       animation[walljumprightanim].Load((char *)":Data:Animations:Walljumpright",highheight,neutral);
-       animation[leftflipanim].Load((char *)":Data:Animations:Leftflip",highheight,neutral);
-       animation[walljumpleftanim].Load((char *)":Data:Animations:Walljumpleft",highheight,neutral);
-       animation[walljumprightkickanim].Load((char *)":Data:Animations:Walljumprightkick",highheight,neutral);
-       animation[walljumpleftkickanim].Load((char *)":Data:Animations:Walljumpleftkick",highheight,neutral);
-       animation[knifefightidleanim].Load((char *)":Data:Animations:Knifefightidle",middleheight,neutral);
-       animation[knifesneakattackanim].Load((char *)":Data:Animations:Knifesneakattack",middleheight,reversal);
-       animation[knifesneakattackedanim].Load((char *)":Data:Animations:Knifesneakattacked",middleheight,reversed);
-       animation[swordfightidleanim].Load((char *)":Data:Animations:swordfightidle",middleheight,neutral);
-       animation[drawleftanim].Load((char *)":Data:Animations:drawleft",middleheight,neutral);
-       animation[swordslashanim].Load((char *)":Data:Animations:swordslash",middleheight,normalattack);
-       animation[swordgroundstabanim].Load((char *)":Data:Animations:swordgroundstab",lowheight,normalattack);
-       animation[dodgebackanim].Load((char *)":Data:Animations:dodgeback",middleheight,neutral);
-       animation[swordsneakattackanim].Load((char *)":Data:Animations:Swordsneakattack",middleheight,reversal);
-       animation[swordsneakattackedanim].Load((char *)":Data:Animations:Swordsneakattacked",middleheight,reversed);
-       animation[swordslashreversedanim].Load((char *)":Data:Animations:swordslashCaught",middleheight,reversed);
-       animation[swordslashreversalanim].Load((char *)":Data:Animations:swordslashCatch",middleheight,reversal);
-       animation[knifeslashreversedanim].Load((char *)":Data:Animations:knifeslashCaught",middleheight,reversed);
-       animation[knifeslashreversalanim].Load((char *)":Data:Animations:knifeslashCatch",middleheight,reversal);
-       animation[swordfightidlebothanim].Load((char *)":Data:Animations:swordfightidleboth",middleheight,neutral);
-       animation[swordslashparryanim].Load((char *)":Data:Animations:sworduprightparry",middleheight,normalattack);
-       animation[swordslashparriedanim].Load((char *)":Data:Animations:swordslashparried",middleheight,normalattack);
-       animation[wolfidle].Load((char *)":Data:Animations:Wolfidle",middleheight,neutral);
-       animation[wolfcrouchanim].Load((char *)":Data:Animations:Wolfcrouch",lowheight,neutral);
-       animation[wolflandanim].Load((char *)":Data:Animations:Wolflanding",lowheight,neutral);
-       animation[wolflandhardanim].Load((char *)":Data:Animations:Wolflandhard",lowheight,neutral);
-       animation[wolfrunanim].Load((char *)":Data:Animations:Wolfrun",middleheight,neutral);
-       animation[wolfrunninganim].Load((char *)":Data:Animations:Wolfrunning",middleheight,neutral);
-       animation[rabbitrunninganim].Load((char *)":Data:Animations:Rabbitrunning",middleheight,neutral);
-       animation[wolfstopanim].Load((char *)":Data:Animations:Wolfstop",middleheight,neutral);
-       animation[rabbittackleanim].Load((char *)":Data:Animations:Rabbittackle",middleheight,neutral);
-       animation[rabbittacklinganim].Load((char *)":Data:Animations:Rabbittackling",middleheight,reversal);
-       animation[rabbittackledbackanim].Load((char *)":Data:Animations:Rabbittackledback",middleheight,reversed);
-       animation[rabbittackledfrontanim].Load((char *)":Data:Animations:Rabbittackledfront",middleheight,reversed);
-       animation[wolfslapanim].Load((char *)":Data:Animations:Wolfslap",middleheight,normalattack);
-       animation[staffhitanim].Load((char *)":Data:Animations:StaffHit",middleheight,normalattack);
-       animation[staffgroundsmashanim].Load((char *)":Data:Animations:StaffGroundSmash",lowheight,normalattack);
-       animation[staffspinhitanim].Load((char *)":Data:Animations:Spinwhack",middleheight,normalattack);
-       animation[staffhitreversedanim].Load((char *)":Data:Animations:StaffHitCaught",middleheight,reversed);
-       animation[staffhitreversalanim].Load((char *)":Data:Animations:StaffHitCatch",middleheight,reversal);
-       animation[staffspinhitreversedanim].Load((char *)":Data:Animations:SpinWhackCaught",middleheight,reversed);
-       animation[staffspinhitreversalanim].Load((char *)":Data:Animations:SpinWhackCatch",middleheight,reversal);
-
-       animation[sitanim].Load((char *)":Data:Animations:Sit",lowheight,neutral);
-       animation[sleepanim].Load((char *)":Data:Animations:Sleep",lowheight,neutral);
-       animation[talkidleanim].Load((char *)":Data:Animations:TalkIdle",middleheight,neutral);
-
-       animation[sitwallanim].Load((char *)":Data:Animations:Dying",lowheight,neutral);
-       animation[dead1anim].Load((char *)":Data:Animations:Dead1",lowheight,neutral);
-       animation[dead2anim].Load((char *)":Data:Animations:Dead2",lowheight,neutral);
-       animation[dead3anim].Load((char *)":Data:Animations:Dead3",lowheight,neutral);
-       animation[dead4anim].Load((char *)":Data:Animations:Dead4",lowheight,neutral);
+       loadAllAnimations();
        //Fix knife stab, too lazy to do it manually
        XYZ moveamount;
        moveamount=0;
index 476b5aaaa996a0bedb32f7a911e10e62e4b39988..bf754b6f6a71f135f2eaa6fe6ddfd9876ad48e66 100644 (file)
@@ -1629,7 +1629,7 @@ void      Game::Loadlevel(char *name){
                won=0;
 
                //campaign=0;
-               animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
+               animation[bounceidleanim].Load((char *)"Idle",middleheight,neutral);
 
                numdialogues=0;
 
@@ -2195,7 +2195,7 @@ void      Game::Loadlevel(char *name){
                                player[i].proportionlegs.z=0;
                        }
 
-                       player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
+                       player[i].tempanimation.Load((char *)"Tempanim",0,0);
 
                        player[i].headmorphness=0;
                        player[i].targetheadmorphness=1;
@@ -5101,7 +5101,7 @@ void      Game::Tick()
                                                                        player[numplayers].proportionlegs.z=0;
                                                                }
 
-                                                               player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
+                                                               player[numplayers].tempanimation.Load((char *)"Tempanim",0,0);
 
                                                                player[numplayers].damagetolerance=200;
 
index 1facda9b1fcbc36cb6aaec5d35fe51743a2e4b00..2959e8157ab33281b0a96369c0fc8cdff5e67a15 100644 (file)
@@ -1008,17 +1008,24 @@ void Skeleton::FindRotationMuscle(int which, int animation)
        if(!isnormal(muscles[which].rotate3))muscles[which].rotate3=0;
 }
 
-void Animation::Load(char *filename, int aheight, int aattack)
+void Animation::Load(const char *filename, int aheight, int aattack)
 {
        static FILE *tfile;
        static int i,j;
        static XYZ startoffset,endoffset;
        static int howmany;
 
+       static const char *anim_prefix = ":Data:Animations:";
+
+
        LOGFUNC;
 
+       int len = strlen(anim_prefix) + strlen(filename);
+       char *buf = new char[len + 1];
+       snprintf(buf, len + 1, "%s%s", anim_prefix, filename);
        // Changing the filename into something the OS can understand
-       char *fixedFN = ConvertFileName(filename);
+       char *fixedFN = ConvertFileName(buf);
+       delete[] buf;
 
        LOG(std::string("Loading animation...") + fixedFN);
 
index 7dcd203d11bd05ecd2aab36ec69dc1ff678fddad..8186b1824cc391a758b724310d2c7be0f96d716d 100644 (file)
@@ -134,7 +134,7 @@ public:
 
        Animation & operator = (const Animation & ani);
 
-       void Load(char *fileName, int aheight, int aattack);
+       void Load(const char *fileName, int aheight, int aattack);
        void Move(XYZ how);
 
 protected: