X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FSkeleton.cpp;h=aba644e2f86c14a1c6637782a8868c51a45a1a5b;hb=59d1ab59970dcc39917b4be3df6797315dca691a;hp=878bcbe13511cc6ec54d317c146abe447246c94a;hpb=de7834267e2ff8f28a2cb49647fc91e060686e93;p=lugaru.git diff --git a/Source/Skeleton.cpp b/Source/Skeleton.cpp index 878bcbe..aba644e 100644 --- a/Source/Skeleton.cpp +++ b/Source/Skeleton.cpp @@ -23,12 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Game.h" #include "Skeleton.h" #include "openal_wrapper.h" +#include "Animation.h" extern float multiplier; extern float gravity; extern Skeleton testskeleton; extern Terrain terrain; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern Objects objects; extern int environment; @@ -40,8 +40,6 @@ extern XYZ envsound[30]; extern float envsoundvol[30]; extern int numenvsounds; extern float envsoundlife[30]; -extern int bonus; -extern float bonustime; extern int tutoriallevel; extern int whichjointstartarray[26]; @@ -416,19 +414,8 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) if(joints[i].label==groin&&!joints[i].locked&&joints[i].delay<=0){ joints[i].locked=1; joints[i].delay=1; - static float gLoc[3]; - static float vel[3]; - gLoc[0]=joints[i].position.x*(*scale)+coords->x; - gLoc[1]=joints[i].position.y*(*scale)+coords->y; - gLoc[2]=joints[i].position.z*(*scale)+coords->z; - vel[0]=joints[i].velocity.x; - vel[1]=joints[i].velocity.y; - vel[2]=joints[i].velocity.z; if(tutoriallevel!=1||id==0){ - PlaySoundEx( landsound1, samp[landsound1], NULL, true); - OPENAL_3D_SetAttributes(channels[landsound1], gLoc, vel); - OPENAL_SetVolume(channels[landsound1], 128); - OPENAL_SetPaused(channels[landsound1], false); + emit_sound_at(landsound1, joints[i].position*(*scale)+*coords, 128.); } breaking=1; } @@ -436,19 +423,8 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) if(joints[i].label==head&&!joints[i].locked&&joints[i].delay<=0){ joints[i].locked=1; joints[i].delay=1; - static float gLoc[3]; - static float vel[3]; - gLoc[0]=joints[i].position.x*(*scale)+coords->x; - gLoc[1]=joints[i].position.y*(*scale)+coords->y; - gLoc[2]=joints[i].position.z*(*scale)+coords->z; - vel[0]=joints[i].velocity.x; - vel[1]=joints[i].velocity.y; - vel[2]=joints[i].velocity.z; if(tutoriallevel!=1||id==0){ - PlaySoundEx( landsound2, samp[landsound2], NULL, true); - OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel); - OPENAL_SetVolume(channels[landsound2], 128); - OPENAL_SetPaused(channels[landsound2], false); + emit_sound_at(landsound2, joints[i].position*(*scale)+*coords, 128.); } } @@ -470,18 +446,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) breaking=0; camerashake+=.6; - static float gLoc[3]; - static float vel[3]; - gLoc[0]=joints[i].position.x*(*scale)+coords->x; - gLoc[1]=joints[i].position.y*(*scale)+coords->y; - gLoc[2]=joints[i].position.z*(*scale)+coords->z; - vel[0]=joints[i].velocity.x; - vel[1]=joints[i].velocity.y; - vel[2]=joints[i].velocity.z; - PlaySoundEx( breaksound2, samp[breaksound2], NULL, true); - OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel); - OPENAL_SetVolume(channels[breaksound2], 300); - OPENAL_SetPaused(channels[breaksound2], false); + emit_sound_at(breaksound2, joints[i].position*(*scale)+*coords); envsound[numenvsounds]=*coords; envsoundvol[numenvsounds]=64; @@ -538,19 +503,8 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) if(joints[i].label==groin&&!joints[i].locked&&joints[i].delay<=0){ joints[i].locked=1; joints[i].delay=1; - static float gLoc[3]; - static float vel[3]; - gLoc[0]=joints[i].position.x*(*scale)+coords->x; - gLoc[1]=joints[i].position.y*(*scale)+coords->y; - gLoc[2]=joints[i].position.z*(*scale)+coords->z; - vel[0]=joints[i].velocity.x; - vel[1]=joints[i].velocity.y; - vel[2]=joints[i].velocity.z; if(tutoriallevel!=1||id==0){ - PlaySoundEx( landsound1, samp[landsound1], NULL, true); - OPENAL_3D_SetAttributes(channels[landsound1], gLoc, vel); - OPENAL_SetVolume(channels[landsound1], 128); - OPENAL_SetPaused(channels[landsound1], false); + emit_sound_at(landsound1, joints[i].position*(*scale)+*coords, 128.); } breaking=1; } @@ -558,19 +512,8 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) if(joints[i].label==head&&!joints[i].locked&&joints[i].delay<=0){ joints[i].locked=1; joints[i].delay=1; - static float gLoc[3]; - static float vel[3]; - gLoc[0]=joints[i].position.x*(*scale)+coords->x; - gLoc[1]=joints[i].position.y*(*scale)+coords->y; - gLoc[2]=joints[i].position.z*(*scale)+coords->z; - vel[0]=joints[i].velocity.x; - vel[1]=joints[i].velocity.y; - vel[2]=joints[i].velocity.z; if(tutoriallevel!=1||id==0){ - PlaySoundEx( landsound2, samp[landsound2], NULL, true); - OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel); - OPENAL_SetVolume(channels[landsound2], 128); - OPENAL_SetPaused(channels[landsound2], false); + emit_sound_at(landsound2, joints[i].position*(*scale)+*coords, 128.); } } @@ -588,18 +531,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) breaking=0; camerashake+=.6; - static float gLoc[3]; - static float vel[3]; - gLoc[0]=joints[i].position.x*(*scale)+coords->x; - gLoc[1]=joints[i].position.y*(*scale)+coords->y; - gLoc[2]=joints[i].position.z*(*scale)+coords->z; - vel[0]=joints[i].velocity.x; - vel[1]=joints[i].velocity.y; - vel[2]=joints[i].velocity.z; - PlaySoundEx( breaksound2, samp[breaksound2], NULL, true); - OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel); - OPENAL_SetVolume(channels[breaksound2], 300); - OPENAL_SetPaused(channels[breaksound2], false); + emit_sound_at(breaksound2, joints[i].position*(*scale)+*coords); envsound[numenvsounds]=*coords; envsoundvol[numenvsounds]=64; @@ -1007,17 +939,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);