diff --git a/src/deh_tables.c b/src/deh_tables.c index 93a70b779..ed401d68a 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5096,6 +5096,10 @@ struct int_const_s const INT_CONST[] = { {"RF_SHADOWEFFECTS",RF_SHADOWEFFECTS}, {"RF_DROPSHADOW",RF_DROPSHADOW}, + // Animation flags + {"SPR2F_MASK",SPR2F_MASK}, + {"SPR2F_SUPER",SPR2F_SUPER}, + // Level flags {"LF_SCRIPTISFILE",LF_SCRIPTISFILE}, {"LF_SPEEDMUSIC",LF_SPEEDMUSIC}, diff --git a/src/f_finale.c b/src/f_finale.c index c221ed52f..3478c0c6b 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -3530,7 +3530,7 @@ void F_TitleDemoTicker(void) // ========== static skin_t *contskins[2]; -static UINT8 cont_spr2[2][6]; +static UINT16 cont_spr2[2][6]; static UINT8 *contcolormaps[2]; void F_StartContinue(void) diff --git a/src/g_demo.c b/src/g_demo.c index e445c4b5d..0efba5a59 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -413,7 +413,7 @@ void G_WriteGhostTic(mobj_t *ghost) { oldghost.sprite2 = ghost->sprite2; ziptic |= GZT_SPR2; - WRITEUINT8(demo_p,oldghost.sprite2); + WRITEUINT16(demo_p,oldghost.sprite2); } // Check for sprite set changes @@ -513,7 +513,7 @@ void G_WriteGhostTic(mobj_t *ghost) temp = ghost->player->followmobj->z-ghost->z; WRITEFIXED(demo_p,temp); if (followtic & FZT_SKIN) - WRITEUINT8(demo_p,ghost->player->followmobj->sprite2); + WRITEUINT16(demo_p,ghost->player->followmobj->sprite2); WRITEUINT16(demo_p,ghost->player->followmobj->sprite); WRITEUINT8(demo_p,(ghost->player->followmobj->frame & FF_FRAMEMASK)); WRITEUINT16(demo_p,ghost->player->followmobj->color); @@ -575,7 +575,7 @@ void G_ConsGhostTic(void) if (ziptic & GZT_FRAME) demo_p++; if (ziptic & GZT_SPR2) - demo_p++; + demo_p += (demoversion < 0x0011) ? sizeof(UINT8) : sizeof(UINT16); if (ziptic & GZT_EXTRA) { // But wait, there's more! @@ -644,7 +644,7 @@ void G_ConsGhostTic(void) // momx, momy and momz demo_p += (demoversion < 0x000e) ? sizeof(INT16) * 3 : sizeof(fixed_t) * 3; if (followtic & FZT_SKIN) - demo_p++; + demo_p += (demoversion < 0x0011) ? sizeof(UINT8) : sizeof(UINT16); demo_p += sizeof(UINT16); demo_p++; demo_p += (demoversion==0x000c) ? 1 : sizeof(UINT16); @@ -726,7 +726,7 @@ void G_GhostTicker(void) if (ziptic & GZT_FRAME) g->oldmo.frame = READUINT8(g->p); if (ziptic & GZT_SPR2) - g->oldmo.sprite2 = READUINT8(g->p); + g->oldmo.sprite2 = (g->version < 0x0011) ? READUINT8(g->p) : READUINT16(g->p); // Update ghost P_UnsetThingPosition(g->mo); @@ -941,7 +941,7 @@ void G_GhostTicker(void) follow->z = g->mo->z + temp; P_SetThingPosition(follow); if (followtic & FZT_SKIN) - follow->sprite2 = READUINT8(g->p); + follow->sprite2 = (g->version < 0x0011) ? READUINT8(g->p) : READUINT16(g->p); else follow->sprite2 = 0; follow->sprite = READUINT16(g->p); @@ -1056,7 +1056,7 @@ void G_ReadMetalTic(mobj_t *metal) oldmetal.frame = G_ConvertOldFrameFlags(oldmetal.frame); } if (ziptic & GZT_SPR2) - oldmetal.sprite2 = READUINT8(metal_p); + oldmetal.sprite2 = (metalversion < 0x0011) ? READUINT8(metal_p) : READUINT16(metal_p); // Set movement, position, and angle // oldmetal contains where you're supposed to be. @@ -1199,7 +1199,7 @@ void G_ReadMetalTic(mobj_t *metal) follow->z = metal->z + temp; P_SetThingPosition(follow); if (followtic & FZT_SKIN) - follow->sprite2 = READUINT8(metal_p); + follow->sprite2 = (metalversion < 0x0011) ? READUINT8(metal_p) : READUINT16(metal_p); else follow->sprite2 = 0; follow->sprite = READUINT16(metal_p); @@ -1207,7 +1207,7 @@ void G_ReadMetalTic(mobj_t *metal) if (metalversion < 0x000f) follow->frame = G_ConvertOldFrameFlags(follow->frame); follow->angle = metal->angle; - follow->color = (metalversion==0x000c) ? READUINT8(metal_p) : READUINT16(metal_p); + follow->color = (metalversion == 0x000c) ? READUINT8(metal_p) : READUINT16(metal_p); if (!(followtic & FZT_SPAWNED)) { @@ -1308,7 +1308,7 @@ void G_WriteMetalTic(mobj_t *metal) { oldmetal.sprite2 = metal->sprite2; ziptic |= GZT_SPR2; - WRITEUINT8(demo_p,oldmetal.sprite2); + WRITEUINT16(demo_p,oldmetal.sprite2); } // Check for sprite set changes @@ -1383,7 +1383,7 @@ void G_WriteMetalTic(mobj_t *metal) temp = metal->player->followmobj->z-metal->z; WRITEFIXED(demo_p,temp); if (followtic & FZT_SKIN) - WRITEUINT8(demo_p,metal->player->followmobj->sprite2); + WRITEUINT16(demo_p,metal->player->followmobj->sprite2); WRITEUINT16(demo_p,metal->player->followmobj->sprite); WRITEUINT32(demo_p,metal->player->followmobj->frame); // NOT & FF_FRAMEMASK here, so 32 bits WRITEUINT16(demo_p,metal->player->followmobj->color); @@ -2607,10 +2607,10 @@ void G_AddGhost(char *defdemoname) } gh->oldmo.color = gh->mo->color; - gh->mo->state = states+S_PLAY_STND; + gh->mo->state = &states[S_PLAY_STND]; gh->mo->sprite = gh->mo->state->sprite; - gh->mo->sprite2 = (gh->mo->state->frame & FF_FRAMEMASK); - //gh->mo->frame = tr_trans30<mo->sprite2 = P_GetStateSprite2(gh->mo->state); + gh->mo->frame = (gh->mo->state->frame & ~FF_FRAMEMASK) | P_GetSprite2StateFrame(gh->mo->state); gh->mo->flags2 |= MF2_DONTDRAW; gh->fadein = (9-3)*6; // fade from invisible to trans30 over as close to 35 tics as possible gh->mo->tics = -1; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bd8f31617..86f83aab5 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4364,9 +4364,9 @@ static void HWR_ProjectSprite(mobj_t *thing) //Fab : 02-08-98: 'skin' override spritedef currently used for skin if (thing->skin && thing->sprite == SPR_PLAY) { - sprdef = &((skin_t *)thing->skin)->sprites[thing->sprite2]; + sprdef = P_GetSkinSpritedef(thing->skin, thing->sprite2); #ifdef ROTSPRITE - sprinfo = &((skin_t *)thing->skin)->sprinfo[thing->sprite2]; + sprinfo = P_GetSkinSpriteInfo(thing->skin, thing->sprite2); #endif } else diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index ef0341bd5..656fbc4a6 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1078,30 +1078,47 @@ static boolean HWR_CanInterpolateSprite2(modelspr2frames_t *spr2frame) return spr2frame->interpolate; } -// -// HWR_GetModelSprite2 (see P_GetSkinSprite2) -// For non-super players, tries each sprite2's immediate predecessor until it finds one with a number of frames or ends up at standing. -// For super players, does the same as above - but tries the super equivalent for each sprite2 before the non-super version. -// - -static UINT8 HWR_GetModelSprite2(md2_t *md2, skin_t *skin, UINT8 spr2, player_t *player) +static modelspr2frames_t *HWR_GetModelSprite2Frames(md2_t *md2, UINT16 spr2) { - UINT8 super = 0, i = 0; + if (!md2 || !md2->model) + return NULL; - if (!md2 || !md2->model || !md2->model->spr2frames || !skin) - return 0; + boolean is_super = spr2 & SPR2F_SUPER; - if ((playersprite_t)(spr2 & ~FF_SPR2SUPER) >= free_spr2) - return 0; + spr2 &= SPR2F_MASK; - while (!md2->model->spr2frames[spr2].numframes - && spr2 != SPR2_STND - && ++i != 32) // recursion limiter + if (spr2 >= free_spr2) + return NULL; + + if (is_super) { - if (spr2 & FF_SPR2SUPER) + modelspr2frames_t *frames = md2->model->superspr2frames; + if (frames && md2->model->superspr2frames[spr2].numframes) + return &md2->model->superspr2frames[spr2]; + } + + if (md2->model->spr2frames) + return &md2->model->spr2frames[spr2]; + + return NULL; +} + +static modelspr2frames_t *HWR_GetModelSprite2(md2_t *md2, skin_t *skin, UINT16 spr2, player_t *player) +{ + UINT16 super = 0; + UINT8 i = 0; + + if (!md2 || !md2->model || !skin) + return HWR_GetModelSprite2Frames(md2, 0); + + while (!HWR_GetModelSprite2Frames(md2, spr2) + && spr2 != SPR2_STND + && ++i < 32) // recursion limiter + { + if (spr2 & SPR2F_SUPER) { - super = FF_SPR2SUPER; - spr2 &= ~FF_SPR2SUPER; + super = SPR2F_SUPER; + spr2 &= ~SPR2F_SUPER; continue; } @@ -1130,9 +1147,9 @@ static UINT8 HWR_GetModelSprite2(md2_t *md2, skin_t *skin, UINT8 spr2, player_t } if (i >= 32) // probably an infinite loop... - return 0; + spr2 = 0; - return spr2; + return HWR_GetModelSprite2Frames(md2, spr2); } // Adjust texture coords of model to fit into a patch's max_s and max_t @@ -1188,7 +1205,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) char filename[64]; INT32 frame = 0; INT32 nextFrame = -1; - UINT8 spr2 = 0; + modelspr2frames_t *spr2frames = NULL; FTransform p; FSurfaceInfo Surf; @@ -1418,18 +1435,24 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) tics = (float)spr->mobj->anim_duration; } + if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) + sprdef = P_GetSkinSpritedef(spr->mobj->skin, spr->mobj->sprite2); + else + sprdef = &sprites[spr->mobj->sprite]; + frame = (spr->mobj->frame & FF_FRAMEMASK); - if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && md2->model->spr2frames) + if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) + spr2frames = HWR_GetModelSprite2(md2, spr->mobj->skin, spr->mobj->sprite2, spr->mobj->player); + if (spr2frames) { - spr2 = HWR_GetModelSprite2(md2, spr->mobj->skin, spr->mobj->sprite2, spr->mobj->player); - mod = md2->model->spr2frames[spr2].numframes; + mod = spr2frames->numframes; #ifndef DONTHIDEDIFFANIMLENGTH // by default, different anim length is masked by the mod - if (mod > (INT32)((skin_t *)spr->mobj->skin)->sprites[spr2].numframes) - mod = ((skin_t *)spr->mobj->skin)->sprites[spr2].numframes; + if (mod > (INT32)sprdef->numframes) + mod = sprdef->numframes; #endif if (!mod) mod = 1; - frame = md2->model->spr2frames[spr2].frames[frame%mod]; + frame = spr2frames->frames[frame % mod]; } else { @@ -1449,13 +1472,18 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) if (durs > INTERPOLERATION_LIMIT) durs = INTERPOLERATION_LIMIT; - if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && md2->model->spr2frames) + if (spr2frames) { - if (HWR_CanInterpolateSprite2(&md2->model->spr2frames[spr2]) + UINT16 next_spr2 = P_GetStateSprite2(&states[spr->mobj->state->nextstate]); + + // Add or remove SPR2F_SUPER based on certain conditions + next_spr2 = P_ApplySuperFlagToSprite2(next_spr2, spr->mobj); + + if (HWR_CanInterpolateSprite2(spr2frames) && (spr->mobj->frame & FF_ANIMATE || (spr->mobj->state->nextstate != S_NULL && states[spr->mobj->state->nextstate].sprite == SPR_PLAY - && ((P_GetSkinSprite2(spr->mobj->skin, (((spr->mobj->player && spr->mobj->player->powers[pw_super]) ? FF_SPR2SUPER : 0)|states[spr->mobj->state->nextstate].frame) & FF_FRAMEMASK, spr->mobj->player) == spr->mobj->sprite2))))) + && ((P_GetSkinSprite2(spr->mobj->skin, next_spr2, spr->mobj->player) == spr->mobj->sprite2))))) { nextFrame = (spr->mobj->frame & FF_FRAMEMASK) + 1; if (nextFrame >= mod) @@ -1466,7 +1494,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) nextFrame = 0; } if (frame || !(spr->mobj->state->frame & FF_SPR2ENDSTATE)) - nextFrame = md2->model->spr2frames[spr2].frames[nextFrame]; + nextFrame = spr2frames->frames[nextFrame]; else nextFrame = -1; } @@ -1502,11 +1530,6 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) else p.z = FIXED_TO_FLOAT(interp.z); - if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) - sprdef = &((skin_t *)spr->mobj->skin)->sprites[spr->mobj->sprite2]; - else - sprdef = &sprites[spr->mobj->sprite]; - sprframe = &sprdef->spriteframes[spr->mobj->frame & FF_FRAMEMASK]; if (sprframe->rotate || papersprite) diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c index 0d656f35a..5856473e4 100644 --- a/src/hardware/hw_model.c +++ b/src/hardware/hw_model.c @@ -292,6 +292,7 @@ void LoadModelSprite2(model_t *model) { INT32 i; modelspr2frames_t *spr2frames = NULL; + modelspr2frames_t *superspr2frames = NULL; INT32 numframes = model->meshes[0].numFrames; char *framename = model->frameNames; @@ -335,25 +336,33 @@ void LoadModelSprite2(model_t *model) spr2idx = 0; while (spr2idx < free_spr2) { + modelspr2frames_t *frames = NULL; if (!memcmp(spr2names[spr2idx], name, 4)) { if (!spr2frames) - spr2frames = (modelspr2frames_t*)Z_Calloc(sizeof(modelspr2frames_t)*NUMPLAYERSPRITES*2, PU_STATIC, NULL); + spr2frames = (modelspr2frames_t*)Z_Calloc(sizeof(modelspr2frames_t)*NUMPLAYERSPRITES, PU_STATIC, NULL); + frames = spr2frames; + if (super) - spr2idx |= FF_SPR2SUPER; + { + if (!superspr2frames) + superspr2frames = (modelspr2frames_t*)Z_Calloc(sizeof(modelspr2frames_t)*NUMPLAYERSPRITES, PU_STATIC, NULL); + frames = superspr2frames; + } + if (framechars[0]) { frame = atoi(framechars); - if (spr2frames[spr2idx].numframes < frame+1) - spr2frames[spr2idx].numframes = frame+1; + if (frames[spr2idx].numframes < frame+1) + frames[spr2idx].numframes = frame+1; } else { - frame = spr2frames[spr2idx].numframes; - spr2frames[spr2idx].numframes++; + frame = frames[spr2idx].numframes; + frames[spr2idx].numframes++; } - spr2frames[spr2idx].frames[frame] = i; - spr2frames[spr2idx].interpolate = interpolate; + frames[spr2idx].frames[frame] = i; + frames[spr2idx].interpolate = interpolate; break; } spr2idx++; @@ -366,7 +375,10 @@ void LoadModelSprite2(model_t *model) if (model->spr2frames) Z_Free(model->spr2frames); + if (model->superspr2frames) + Z_Free(model->superspr2frames); model->spr2frames = spr2frames; + model->superspr2frames = superspr2frames; } // diff --git a/src/hardware/hw_model.h b/src/hardware/hw_model.h index f057271df..5eb649b17 100644 --- a/src/hardware/hw_model.h +++ b/src/hardware/hw_model.h @@ -101,6 +101,7 @@ typedef struct model_s char *frameNames; boolean interpolate[256]; modelspr2frames_t *spr2frames; + modelspr2frames_t *superspr2frames; // the max_s and max_t values that the uvs are currently adjusted to // (if a sprite is used as a texture) diff --git a/src/info.c b/src/info.c index 8dd1aac80..382ecba7f 100644 --- a/src/info.c +++ b/src/info.c @@ -691,3309 +691,3309 @@ state_t states[NUMSTATES] = // (or tr_trans10<