From: Alexander Monakov Date: Sun, 6 Jun 2010 23:02:26 +0000 (+0400) Subject: Cleanup animation loading X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=9248d1455aa434112b5ddd771fd69b8df02d44ee;p=lugaru.git Cleanup animation loading --- diff --git a/CMakeLists.txt b/CMakeLists.txt index d36f0f8..f2f3df6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ set(LUGARU_SRCS ${SRCDIR}/Input.cpp ${SRCDIR}/Settings.cpp ${SRCDIR}/Stereo.cpp + ${SRCDIR}/Animation.cpp ) set(LUGARU_H diff --git a/Source/Animation.def b/Source/Animation.def index 49aec9f..3b33c38 100644 --- a/Source/Animation.def +++ b/Source/Animation.def @@ -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) diff --git a/Source/Animation.h b/Source/Animation.h index b8e821b..b292813 100644 --- a/Source/Animation.h +++ b/Source/Animation.h @@ -39,4 +39,6 @@ animation_count }; extern Animation animation[animation_count]; + +extern void loadAllAnimations(); #endif diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index dccc889..e8e1682 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -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; diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 476b5aa..bf754b6 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -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; diff --git a/Source/Skeleton.cpp b/Source/Skeleton.cpp index 1facda9..2959e81 100644 --- a/Source/Skeleton.cpp +++ b/Source/Skeleton.cpp @@ -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); diff --git a/Source/Skeleton.h b/Source/Skeleton.h index 7dcd203..8186b18 100644 --- a/Source/Skeleton.h +++ b/Source/Skeleton.h @@ -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: