Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow multiple palettes for dragon animations

  • Loading branch information...
commit 39f65ddd7d3838d2b80f0ae46faac8ba78494ca4 1 parent ec5f29c
@fizzet fizzet authored
Showing with 45 additions and 24 deletions.
  1. +40 −23 gemrb/core/CharAnimations.cpp
  2. +5 −1 gemrb/core/CharAnimations.h
View
63 gemrb/core/CharAnimations.cpp
@@ -76,7 +76,6 @@ struct EquipResRefData {
unsigned char Cycle;
};
-
void CharAnimations::ReleaseMemory()
{
if (AvatarTable) {
@@ -292,10 +291,16 @@ static const char StancePrefix[] = {'3','2','5','5','4','4','2','2','5','
static const char CyclePrefix[] = {'0','0','1','1','1','1','0','0','1','1','0','1','1','1','1','1','1','1','1'};
static const unsigned int CycleOffset[] = { 0, 0, 0, 0, 0, 9, 0, 0, 0, 18, 0, 0, 9, 18, 0, 0, 0, 0, 0 };
+#define NINE_FRAMES_PALETTE(stance) ((PaletteType) (StancePrefix[stance] - '1'))
+
void CharAnimations::SetColors(const ieDword *arg)
{
Colors = arg;
SetupColors(PAL_MAIN);
+ SetupColors(PAL_MAIN_2);
+ SetupColors(PAL_MAIN_3);
+ SetupColors(PAL_MAIN_4);
+ SetupColors(PAL_MAIN_5);
SetupColors(PAL_WEAPON);
SetupColors(PAL_OFFHAND);
SetupColors(PAL_HELMET);
@@ -386,30 +391,26 @@ void CharAnimations::SetupColors(PaletteType type)
}
int PType = NoPalette();
- if ( PType && (type == PAL_MAIN) ) {
- bool needmod = false;
- if (GlobalColorMod.type != RGBModifier::NONE) {
- needmod = true;
- }
- if (!needmod && PaletteResRef[0]) {
- gamedata->FreePalette(palette[type], PaletteResRef);
- }
- PaletteResRef[0]=0;
+ if ( PType && (type <= PAL_MAIN_5) ) {
//handling special palettes like MBER_BL (black bear)
if (PType!=1) {
+ ieResRef oldResRef;
+ CopyResRef(oldResRef, PaletteResRef[type]);
if (GetAnimType()==IE_ANI_NINE_FRAMES) {
- snprintf(PaletteResRef,9,"%.4s_%-.2s%c",ResRef, (char *) &PType, StancePrefix[StanceID]);
+ snprintf(PaletteResRef[type],9,"%.4s_%-.2s%c",ResRef, (char *) &PType, '1'+type);
} else {
- snprintf(PaletteResRef,9,"%.4s_%-.2s",ResRef, (char *) &PType);
+ snprintf(PaletteResRef[type],9,"%.4s_%-.2s",ResRef, (char *) &PType);
}
- strlwr(PaletteResRef);
- Palette *tmppal = gamedata->GetPalette(PaletteResRef);
+ strlwr(PaletteResRef[type]);
+ Palette *tmppal = gamedata->GetPalette(PaletteResRef[type]);
if (tmppal) {
+ gamedata->FreePalette(palette[type], oldResRef);
palette[type] = tmppal;
} else {
- PaletteResRef[0]=0;
+ PaletteResRef[type][0]=0;
}
}
+ bool needmod = GlobalColorMod.type != RGBModifier::NONE;
if (needmod) {
if (!modifiedPalette[type])
modifiedPalette[type] = new Palette();
@@ -456,9 +457,12 @@ Palette* CharAnimations::GetPartPalette(int part)
{
int actorPartCount = GetActorPartCount();
PaletteType type = PAL_MAIN;
-
+ if (GetAnimType() == IE_ANI_NINE_FRAMES) {
+ //these animations use several palettes
+ type = NINE_FRAMES_PALETTE(StanceID);
+ }
// always use unmodified BAM palette for the supporting part
- if (GetAnimType() == IE_ANI_TWO_PIECE && part == 1) return NULL;
+ else if (GetAnimType() == IE_ANI_TWO_PIECE && part == 1) return NULL;
else if (part == actorPartCount) type = PAL_WEAPON;
else if (part == actorPartCount+1) type = PAL_OFFHAND;
else if (part == actorPartCount+2) type = PAL_HELMET;
@@ -644,7 +648,9 @@ CharAnimations::CharAnimations(unsigned int AnimID, ieDword ArmourLevel)
ArmorType = 0;
RangedType = 0;
WeaponType = 0;
- PaletteResRef[0] = 0;
+ for (i = 0; i < 5; ++i) {
+ PaletteResRef[i][0] = 0;
+ }
WeaponRef[0] = 0;
HelmetRef[0] = 0;
OffhandRef[0] = 0;
@@ -709,9 +715,10 @@ void CharAnimations::DropAnims()
CharAnimations::~CharAnimations(void)
{
DropAnims();
- gamedata->FreePalette(palette[PAL_MAIN], PaletteResRef);
int i;
- for (i = 1; i < PAL_MAX; ++i)
+ for (i = 0; i <= PAL_MAIN_5; ++i)
+ gamedata->FreePalette(palette[i], PaletteResRef[i]);
+ for (; i < PAL_MAX; ++i)
gamedata->FreePalette(palette[i], 0);
for (i = 0; i < PAL_MAX; ++i)
gamedata->FreePalette(modifiedPalette[i], 0);
@@ -1042,16 +1049,22 @@ Animation** CharAnimations::GetAnimation(unsigned char Stance, unsigned char Ori
}
if (part < actorPartCount) {
+ PaletteType ptype = PAL_MAIN;
+ if (AnimType == IE_ANI_NINE_FRAMES) {
+ //these animations use several palettes
+ ptype = NINE_FRAMES_PALETTE(StanceID);
+ }
+
//if you need to revert this change, consider true paletted
//animations which need a GlobalColorMod (mgir for example)
//if (!palette[PAL_MAIN] && ((GlobalColorMod.type!=RGBModifier::NONE) || (NoPalette()!=1)) ) {
- if(!palette[PAL_MAIN]) {
+ if(!palette[ptype]) {
// 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] = a->GetFrame(0)->GetPalette()->Copy();
+ palette[ptype] = a->GetFrame(0)->GetPalette()->Copy();
// ...and setup the colours properly
- SetupColors(PAL_MAIN);
+ SetupColors(ptype);
}
} else if (part == actorPartCount) {
if (!palette[PAL_WEAPON]) {
@@ -2591,6 +2604,10 @@ void CharAnimations::PulseRGBModifiers()
if (change[0]) {
change[0]=0;
SetupColors(PAL_MAIN);
+ SetupColors(PAL_MAIN_2);
+ SetupColors(PAL_MAIN_3);
+ SetupColors(PAL_MAIN_4);
+ SetupColors(PAL_MAIN_5);
}
if (change[1]) {
change[1]=0;
View
6 gemrb/core/CharAnimations.h
@@ -112,6 +112,10 @@ namespace GemRB {
enum PaletteType {
PAL_MAIN,
+ PAL_MAIN_2,
+ PAL_MAIN_3,
+ PAL_MAIN_4,
+ PAL_MAIN_5,
PAL_WEAPON,
PAL_OFFHAND,
PAL_HELMET,
@@ -164,7 +168,7 @@ class GEM_EXPORT CharAnimations {
unsigned int AvatarsRowNum;
unsigned char ArmorType, WeaponType, RangedType;
ieResRef ResRef;
- ieResRef PaletteResRef;
+ ieResRef PaletteResRef[5];
unsigned char nextStanceID, StanceID;
bool autoSwitchOnEnd;
bool lockPalette;

0 comments on commit 39f65dd

Please sign in to comment.
Something went wrong with that request. Please try again.