From: Willem J. P. <wjp...@us...> - 2007-01-26 21:51:08
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv17723/plugins/Core Modified Files: Actor.cpp CharAnimations.cpp CharAnimations.h Log Message: clean up palettes in CharAnimations a bit Index: Actor.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Actor.cpp,v retrieving revision 1.249 retrieving revision 1.250 diff -C2 -d -r1.249 -r1.250 *** Actor.cpp 17 Jan 2007 21:16:24 -0000 1.249 --- Actor.cpp 26 Jan 2007 21:51:06 -0000 1.250 *************** *** 290,296 **** if (anims) { if (anims->lockPalette) { ! recover = anims->palette; } ! //increase refcount hack so the palette won't get sunk if (recover) { recover->IncRef(); --- 290,296 ---- if (anims) { if (anims->lockPalette) { ! recover = anims->palette[PAL_MAIN]; } ! // Take ownership so the palette won't be deleted if (recover) { recover->IncRef(); *************** *** 316,320 **** //if we have a recovery palette, then set it back ! anims->palette=recover; if (recover) { anims->lockPalette = true; --- 316,321 ---- //if we have a recovery palette, then set it back ! assert(anims->palette[PAL_MAIN] == 0); ! anims->palette[PAL_MAIN] = recover; if (recover) { anims->lockPalette = true; *************** *** 448,452 **** anims->SetColors( gradients ); anims->GetAnimation(0,0); ! if (anims->palette) { anims->lockPalette=true; } --- 449,453 ---- anims->SetColors( gradients ); anims->GetAnimation(0,0); ! if (anims->palette[PAL_MAIN]) { anims->lockPalette=true; } Index: CharAnimations.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/CharAnimations.cpp,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** CharAnimations.cpp 24 Dec 2006 16:47:20 -0000 1.104 --- CharAnimations.cpp 26 Jan 2007 21:51:06 -0000 1.105 *************** *** 194,198 **** // bottleneck. (wjp) DropAnims(); ! core->FreePalette(paletteHelmet, 0); } --- 194,198 ---- // bottleneck. (wjp) DropAnims(); ! core->FreePalette(palette[PAL_HELMET], 0); } *************** *** 204,208 **** // TODO: Only drop weapon anims? DropAnims(); ! core->FreePalette(paletteWeapon, 0); } --- 204,208 ---- // TODO: Only drop weapon anims? DropAnims(); ! core->FreePalette(palette[PAL_WEAPON], 0); } *************** *** 214,218 **** // TODO: Only drop shield/offhand anims? DropAnims(); ! core->FreePalette(paletteOffhand, 0); } --- 214,218 ---- // TODO: Only drop shield/offhand anims? DropAnims(); ! core->FreePalette(palette[PAL_OFFHAND], 0); } *************** *** 220,248 **** { Colors = arg; ! SetupColors(0); ! SetupColors(1); ! SetupColors(2); ! SetupColors(3); } ! void CharAnimations::SetupColors(unsigned int type) { ! Palette* pal = 0; ! switch (type) { ! case 0: ! pal = palette; ! break; ! case 1: ! pal = paletteWeapon; ! break; ! case 2: ! pal = paletteOffhand; ! break; ! case 3: ! pal = paletteHelmet; ! break; ! default: ! break; ! } if (!pal) { --- 220,232 ---- { Colors = arg; ! SetupColors(PAL_MAIN); ! SetupColors(PAL_WEAPON); ! SetupColors(PAL_OFFHAND); ! SetupColors(PAL_HELMET); } ! void CharAnimations::SetupColors(PaletteType type) { ! Palette* pal = palette[(int)type]; if (!pal) { *************** *** 265,274 **** int dest = 256-Colors[6]*size; if (Colors[6] == 0) { ! core->FreePalette(palette, PaletteResRef); PaletteResRef[0]=0; return; } for (unsigned int i = 0; i < Colors[6]; i++) { ! core->GetPalette( Colors[i]&255, size, &palette->col[dest]); //Color* NewPal = core->GetPalette( Colors[i]&255, size ); //memcpy( &palette->col[dest], NewPal, size*sizeof( Color ) ); --- 249,259 ---- int dest = 256-Colors[6]*size; if (Colors[6] == 0) { ! core->FreePalette(palette[PAL_MAIN], PaletteResRef); PaletteResRef[0]=0; return; } for (unsigned int i = 0; i < Colors[6]; i++) { ! core->GetPalette( Colors[i]&255, size, ! &palette[PAL_MAIN]->col[dest] ); //Color* NewPal = core->GetPalette( Colors[i]&255, size ); //memcpy( &palette->col[dest], NewPal, size*sizeof( Color ) ); *************** *** 280,285 **** int PType = NoPalette(); ! if ( PType && type == 0 ) { ! core->FreePalette(palette, PaletteResRef); PaletteResRef[0]=0; //handling special palettes like MBER_BL (black bear) --- 265,270 ---- int PType = NoPalette(); ! if ( PType && type == PAL_MAIN ) { ! core->FreePalette(palette[PAL_MAIN], PaletteResRef); PaletteResRef[0]=0; //handling special palettes like MBER_BL (black bear) *************** *** 289,293 **** snprintf(PaletteResRef,8,"%.4s_%-.2s",ResRef, (char *) &PType); strlwr(PaletteResRef); ! palette = core->GetPalette(PaletteResRef); //invalid palette, rolling back if (!palette) { --- 274,278 ---- snprintf(PaletteResRef,8,"%.4s_%-.2s",ResRef, (char *) &PType); strlwr(PaletteResRef); ! palette[PAL_MAIN] = core->GetPalette(PaletteResRef); //invalid palette, rolling back if (!palette) { *************** *** 297,301 **** } ! pal->SetupPaperdollColours(Colors, type); } --- 282,286 ---- } ! pal->SetupPaperdollColours(Colors, (int)type); } *************** *** 304,311 **** int actorPartCount = GetActorPartCount(); ! if (part < actorPartCount) return palette; ! if (part == actorPartCount) return paletteWeapon; ! if (part == actorPartCount+1) return paletteOffhand; ! if (part == actorPartCount+2) return paletteHelmet; return 0; } --- 289,296 ---- int actorPartCount = GetActorPartCount(); ! if (part < actorPartCount) return palette[PAL_MAIN]; ! if (part == actorPartCount) return palette[PAL_WEAPON]; ! if (part == actorPartCount+1) return palette[PAL_OFFHAND]; ! if (part == actorPartCount+2) return palette[PAL_HELMET]; return 0; } *************** *** 348,355 **** { Colors = NULL; ! palette = NULL; ! paletteHelmet = NULL; ! paletteWeapon = NULL; ! paletteOffhand = NULL; nextStanceID = 0; autoSwitchOnEnd = false; --- 333,339 ---- { Colors = NULL; ! int i,j; ! for (i = 0; i < 4; ++i) ! palette[i] = NULL; nextStanceID = 0; autoSwitchOnEnd = false; *************** *** 359,364 **** } ! for (int i = 0; i < MAX_ANIMS; i++) { ! for (int j = 0; j < MAX_ORIENT; j++) { Anims[i][j] = NULL; } --- 343,348 ---- } ! for (i = 0; i < MAX_ANIMS; i++) { ! for (j = 0; j < MAX_ORIENT; j++) { Anims[i][j] = NULL; } *************** *** 420,427 **** { DropAnims(); ! core->FreePalette(palette, PaletteResRef); ! core->FreePalette(paletteHelmet, 0); ! core->FreePalette(paletteWeapon, 0); ! core->FreePalette(paletteOffhand, 0); } /* --- 404,410 ---- { DropAnims(); ! core->FreePalette(palette[PAL_MAIN], PaletteResRef); ! for (int i = 1; i < 4; ++i) ! core->FreePalette(palette[i], 0); } /* *************** *** 721,747 **** if (part < actorPartCount) { ! if (!palette && (NoPalette()!=1) ) { // This is the first time we're loading an Animation. // We copy the palette of its first frame into our own palette ! palette=core->GetVideoDriver()->GetPalette(a->GetFrame(0)) ! ->Copy(); // ...and setup the colours properly ! SetupColors(0); } } else if (part == actorPartCount) { ! if (!paletteWeapon) { ! paletteWeapon = core->GetVideoDriver()->GetPalette(a->GetFrame(0))->Copy(); ! SetupColors(1); } } else if (part == actorPartCount+1) { ! if (!paletteOffhand) { ! paletteOffhand = core->GetVideoDriver()->GetPalette(a->GetFrame(0))->Copy(); ! SetupColors(2); } } else if (part == actorPartCount+2) { ! if (!paletteHelmet) { ! paletteHelmet = core->GetVideoDriver()->GetPalette(a->GetFrame(0))->Copy(); ! SetupColors(3); } } --- 704,733 ---- if (part < actorPartCount) { ! if (!palette[PAL_MAIN] && (NoPalette()!=1) ) { // This is the first time we're loading an Animation. // We copy the palette of its first frame into our own palette ! palette[PAL_MAIN] = ! core->GetVideoDriver()->GetPalette(a->GetFrame(0))->Copy(); // ...and setup the colours properly ! SetupColors(PAL_MAIN); } } else if (part == actorPartCount) { ! if (!palette[PAL_WEAPON]) { ! palette[PAL_WEAPON] = ! core->GetVideoDriver()->GetPalette(a->GetFrame(0))->Copy(); ! SetupColors(PAL_WEAPON); } } else if (part == actorPartCount+1) { ! if (!palette[PAL_OFFHAND]) { ! palette[PAL_OFFHAND] = ! core->GetVideoDriver()->GetPalette(a->GetFrame(0))->Copy(); ! SetupColors(PAL_OFFHAND); } } else if (part == actorPartCount+2) { ! if (!palette[PAL_HELMET]) { ! palette[PAL_HELMET] = ! core->GetVideoDriver()->GetPalette(a->GetFrame(0))->Copy(); ! SetupColors(PAL_HELMET); } } Index: CharAnimations.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/CharAnimations.h,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** CharAnimations.h 24 Dec 2006 15:34:49 -0000 1.50 --- CharAnimations.h 26 Jan 2007 21:51:06 -0000 1.51 *************** *** 120,123 **** --- 120,130 ---- }; + enum PaletteType { + PAL_MAIN, + PAL_WEAPON, + PAL_OFFHAND, + PAL_HELMET + }; + struct EquipResRefData; *************** *** 130,137 **** public: ieDword *Colors; //these are the custom color indices ! Palette* palette; ! Palette* paletteHelmet; ! Palette* paletteWeapon; ! Palette* paletteOffhand; unsigned int AvatarsRowNum; unsigned char ArmorType, WeaponType, RangedType; --- 137,141 ---- public: ieDword *Colors; //these are the custom color indices ! Palette* palette[4]; unsigned int AvatarsRowNum; unsigned char ArmorType, WeaponType, RangedType; *************** *** 152,156 **** void SetWeaponRef(const char* ref); void SetOffhandRef(const char* ref); ! void SetupColors(unsigned int type); void SetColors(ieDword *Colors); --- 156,160 ---- void SetWeaponRef(const char* ref); void SetOffhandRef(const char* ref); ! void SetupColors(PaletteType type); void SetColors(ieDword *Colors); |