Commit e28d400a authored by Richard Gobeille's avatar Richard Gobeille Committed by Richard Gobeille
Browse files

Duke3d: fix savegame MUSICANDSFX issues

Fixes terminx/eduke32#75 and terminx/eduke32#179.
parent d595a39d
......@@ -6228,6 +6228,46 @@ static void MaybeTrainKillEnemies(int const spriteNum)
while (findSprite >= 0);
}
int dukeValidateSectorEffectorPlaysSound(int num)
{
switch (SLT(num))
{
case SE_11_SWINGING_DOOR:
case SE_15_SLIDING_DOOR:
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
case SE_20_STRETCH_BRIDGE:
case SE_21_DROP_FLOOR:
case SE_31_FLOOR_RISE_FALL:
case SE_32_CEILING_RISE_FALL:
case SE_36_PROJ_SHOOTER:
return 1;
}
return 0;
}
int dukeValidateSectorPlaysSound(int sect)
{
switch (sector[sect].lotag)
{
case ST_9_SLIDING_ST_DOOR:
case ST_16_PLATFORM_DOWN:
case ST_17_PLATFORM_UP:
case ST_18_ELEVATOR_DOWN:
case ST_19_ELEVATOR_UP:
case ST_29_TEETH_DOOR:
case ST_20_CEILING_DOOR:
case ST_21_FLOOR_DOOR:
case ST_22_SPLITTING_DOOR:
case ST_23_SWINGING_DOOR:
case ST_25_SLIDING_DOOR:
case ST_27_STRETCH_BRIDGE:
case ST_28_DROP_FLOOR:
case ST_30_ROTATE_RISE_BRIDGE:
case ST_31_TWO_WAY_TRAIN:
return 1;
}
return 0;
}
ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
{
......
......@@ -385,6 +385,9 @@ extern int32_t ticrandomseed;
extern projectile_t SpriteProjectile[MAXSPRITES];
extern uint8_t g_radiusDmgStatnums[(MAXSTATUS+7)>>3];
int dukeValidateSectorEffectorPlaysSound(int);
int dukeValidateSectorPlaysSound(int);
int A_CheckNoSE7Water(uspriteptr_t pSprite, int sectNum, int sectLotag, int32_t *pOther);
int A_CheckSwitchTile(int spriteNum);
int A_IncurDamage(int spriteNum);
......
......@@ -2451,12 +2451,30 @@ static void postloadplayer(int32_t savegamep)
if (savegamep)
{
for (SPRITES_OF(STAT_FX, i))
if (sprite[i].picnum == MUSICANDSFX)
if (sprite[i].picnum == MUSICANDSFX && T1(i) && SLT(i) < 999 && g_sounds[SLT(i)].m & (SF_MSFX|SF_LOOP))
{
int soundNum = sprite[i].lotag;
T2(i) = ud.config.SoundToggle;
if (!((g_sounds[soundNum].m & SF_LOOP) || (sprite[i].hitag && sprite[i].hitag != soundNum)))
T1(i) = 0;
T2(i) = 0;
for (int SPRITES_OF_SECT(SECT(i), j))
if (sprite[j].picnum == SECTOREFFECTOR && dukeValidateSectorEffectorPlaysSound(j))
{
T1(i) = 0;
T2(i) = ud.config.SoundToggle;
A_CallSound(SECT(i), j);
break;
}
if (T1(i))
{
if (dukeValidateSectorPlaysSound(SECT(i)))
{
T1(i) = 0;
T2(i) = ud.config.SoundToggle;
A_CallSound(SECT(i), i);
}
}
}
G_UpdateScreenArea();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment