From: Laszlo T. <ave...@us...> - 2004-03-27 12:19:54
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9185 Modified Files: ActorBlock.cpp CharAnimations.cpp Log Message: Fixed some possible crashers (don't draw invalid feet circles, print error messages for invalid avatars.2da entries) Index: ActorBlock.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/ActorBlock.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** ActorBlock.cpp 25 Mar 2004 17:02:47 -0000 1.35 --- ActorBlock.cpp 27 Mar 2004 12:08:38 -0000 1.36 *************** *** 254,258 **** void Selectable::DrawCircle() { ! if (!size) { return; } --- 254,258 ---- void Selectable::DrawCircle() { ! if (size<=0) { return; } *************** *** 266,271 **** } Region vp = core->GetVideoDriver()->GetViewport(); ! core->GetVideoDriver()->DrawEllipse( XPos - vp.x, YPos - vp.y, size * 10, ! ( ( size * 15 ) / 2 ), *col ); } --- 266,271 ---- } Region vp = core->GetVideoDriver()->GetViewport(); ! core->GetVideoDriver()->DrawEllipse( XPos - vp.x, YPos - vp.y, ! size * 10, ( ( size * 15 ) / 2 ), *col ); } Index: CharAnimations.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/CharAnimations.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** CharAnimations.cpp 25 Mar 2004 22:11:22 -0000 1.30 --- CharAnimations.cpp 27 Mar 2004 12:08:38 -0000 1.31 *************** *** 267,283 **** } //newresref is based on the prefix (ResRef) and various other things ! char* NewResRef = ( char* ) malloc( 9 ); strcpy( NewResRef, ResRef ); unsigned char Cycle; GetAnimResRef( AnimID, Orient, NewResRef, Cycle ); DataStream* stream = core->GetResourceMgr()->GetResource( NewResRef, IE_BAM_CLASS_ID ); - free( NewResRef ); AnimationMgr* anim = ( AnimationMgr* ) core->GetInterface( IE_BAM_CLASS_ID ); anim->Open( stream, true ); Animation* a = anim->GetAnimation( Cycle, 0, 0, IE_NORMAL ); - a->pos = 0; core->FreeInterface( anim ); a->pos = 0; a->endReached = false; --- 267,285 ---- } //newresref is based on the prefix (ResRef) and various other things ! char NewResRef[9]; strcpy( NewResRef, ResRef ); unsigned char Cycle; GetAnimResRef( AnimID, Orient, NewResRef, Cycle ); + NewResRef[8]=0; DataStream* stream = core->GetResourceMgr()->GetResource( NewResRef, IE_BAM_CLASS_ID ); AnimationMgr* anim = ( AnimationMgr* ) core->GetInterface( IE_BAM_CLASS_ID ); anim->Open( stream, true ); Animation* a = anim->GetAnimation( Cycle, 0, 0, IE_NORMAL ); core->FreeInterface( anim ); + if(!a) { + return NULL; + } a->pos = 0; a->endReached = false; *************** *** 295,305 **** case IE_ANI_CODE_MIRROR: { switch (OrientCount) { case 5: { ! if (Orient > 8) ! core->GetVideoDriver()->MirrorAnimation( a ); ! if (Orient & 1) ! Orient--; Anims[AnimID][Orient] = a; Anims[AnimID][Orient + 1] = a; --- 297,307 ---- case IE_ANI_CODE_MIRROR: { + if (Orient > 8) { + core->GetVideoDriver()->MirrorAnimation( a ); + } switch (OrientCount) { case 5: { ! Orient&=~1; Anims[AnimID][Orient] = a; Anims[AnimID][Orient + 1] = a; *************** *** 309,332 **** case 9: { - if (Orient > 8) { - core->GetVideoDriver()->MirrorAnimation( a ); - } Anims[AnimID][Orient] = a; - if (AnimID == IE_ANI_EMERGE) { - a->playReversed = true; - a->autoSwitchOnEnd = true; - a->nextAnimID = IE_ANI_AWAKE; - } } break; } } break; case IE_ANI_ONE_FILE: ! { ! Anims[AnimID][Orient] = a; ! } ! break; case IE_ANI_CODE_MIRROR_2: --- 311,331 ---- case 9: { Anims[AnimID][Orient] = a; } break; } + if (AnimID == IE_ANI_EMERGE) { + a->playReversed = true; + a->autoSwitchOnEnd = true; + a->nextAnimID = IE_ANI_AWAKE; + } } break; case IE_ANI_ONE_FILE: ! { ! Anims[AnimID][Orient] = a; ! } ! break; case IE_ANI_CODE_MIRROR_2: *************** *** 353,359 **** case 5: { ! if (Orient & 1) { ! Orient--; ! } Anims[AnimID][Orient] = a; Anims[AnimID][Orient + 1] = a; --- 352,356 ---- case 5: { ! Orient&=~1; Anims[AnimID][Orient] = a; Anims[AnimID][Orient + 1] = a; *************** *** 389,394 **** default: { ! if (Orient & 1) ! Orient--; Anims[AnimID][Orient] = a; Anims[AnimID][Orient + 1] = a; --- 386,390 ---- default: { ! Orient &=~1; Anims[AnimID][Orient] = a; Anims[AnimID][Orient + 1] = a; *************** *** 423,464 **** switch (MirrorType) { case IE_ANI_CODE_MIRROR: ! { ! if (OrientCount == 9) { ! AddVHRSuffix( ResRef, AnimID, Cycle, Orient ); ! ResRef[8] = 0; ! } } ! break; case IE_ANI_ONE_FILE: ! { ! if (OrientCount == 16) { ! char* val = Avatars->QueryField( RowIndex, AnimID + 7 ); ! if (val[0] == '*') { ! ResRef[0] = 0; ! return; ! } ! Cycle = atoi( val ) + Orient; } } ! break; case IE_ANI_TWO_FILES_2: ! { ! if (OrientCount == 5) { ! AddMHRSuffix( ResRef, AnimID, Cycle, Orient ); ! ResRef[8] = 0; ! } } ! break; case IE_ANI_TWO_FILES_3: ! { ! if (OrientCount == 5) { ! AddMMRSuffix( ResRef, AnimID, Cycle, Orient ); ! ResRef[8] = 0; ! } } ! break; case IE_ANI_TWO_FILES: --- 419,473 ---- switch (MirrorType) { case IE_ANI_CODE_MIRROR: ! { ! if (OrientCount == 9) { ! AddVHRSuffix( ResRef, AnimID, Cycle, Orient ); } ! else { ! printf("Unsupported animation, IE_ANI_CODE_MIRROR can have only 9 orientations.\n"); ! abort(); ! } ! } ! break; case IE_ANI_ONE_FILE: ! { ! if (OrientCount == 16) { ! char* val = Avatars->QueryField( RowIndex, AnimID + 7 ); ! if (val[0] == '*') { ! ResRef[0] = 0; ! return; } + Cycle = atoi( val ) + Orient; } ! else { ! printf("Unsupported animation, IE_ANI_ONE_FILE can have only 16 orientations.\n"); ! abort(); ! } ! } ! break; case IE_ANI_TWO_FILES_2: ! { ! if (OrientCount == 5) { ! AddMHRSuffix( ResRef, AnimID, Cycle, Orient ); } ! else { ! printf("Unsupported animation, IE_ANI_TWO_FILES_2 can have only 5 orientations.\n"); ! abort(); ! } ! } ! break; case IE_ANI_TWO_FILES_3: ! { ! if (OrientCount == 5) { ! AddMMRSuffix( ResRef, AnimID, Cycle, Orient ); } ! else { ! printf("Unsupported animation, IE_ANI_TWO_FILES_3 can have only 5 orientations.\n"); ! abort(); ! } ! } ! break; case IE_ANI_TWO_FILES: *************** *** 476,484 **** } } } break; case IE_ANI_FOUR_FILES: ! { if (OrientCount == 5) { char* val = Avatars->QueryField( RowIndex, AnimID + 7 ); --- 485,497 ---- } } + else { + printf("Unsupported animation, IE_ANI_TWO_FILES can have only 5 orientations.\n"); + abort(); + } } break; case IE_ANI_FOUR_FILES: ! { if (OrientCount == 5) { char* val = Avatars->QueryField( RowIndex, AnimID + 7 ); *************** *** 511,515 **** case IE_ANI_CODE_MIRROR_2: ! { if (OrientCount == 9) { char* val = Avatars->QueryField( RowIndex, AnimID + 7 ); --- 524,528 ---- case IE_ANI_CODE_MIRROR_2: ! { if (OrientCount == 9) { char* val = Avatars->QueryField( RowIndex, AnimID + 7 ); |