From 402d0e5fa1bdd683832f22640cf1de4433ba2471 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 7 Oct 2008 18:21:03 +0000 Subject: [PATCH] - Fixed: Cheats in demos must not access the weapon slots. - Fixed: S_ChannelEnded didn't check for a NULL SfxInfo. - Fixed: R_InitTables did a typecast to angle_t instead of fixed_t. - Fixed: PowerProtection and PowerDamage applied their defaults incorrectly. - Fixed: The damage type property didn't properly read its factor. SVN r1257 (trunk) --- docs/rh-log.txt | 9 +++++++++ src/g_shared/a_artifacts.cpp | 18 +++++++++++++----- src/m_cheat.cpp | 6 ++++-- src/r_main.cpp | 6 +++--- src/s_sound.cpp | 8 ++++++-- src/thingdef/thingdef_properties.cpp | 2 +- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index ad7d36bf81..04ee1c536a 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,12 @@ +October 7, 2008 (Changes by Graf Zahl) +- Fixed: Cheats in demos must not access the weapon slots. +- Fixed: S_ChannelEnded didn't check for a NULL SfxInfo. +- Fixed: R_InitTables did a typecast to angle_t instead of fixed_t. + +October 6, 2008 (Changes by Graf Zahl) +- Fixed: PowerProtection and PowerDamage applied their defaults incorrectly. +- Fixed: The damage type property didn't properly read its factor. + October 5, 2008 (Changes by Graf Zahl) - Finally has the right idea how to restore Doom's original clipping of projectiles against decorations without breaking anything newer: diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 74c7f5303f..c1cc89f3d7 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1476,12 +1476,17 @@ void APowerDamage::ModifyDamage(int damage, FName damageType, int &newdamage, bo if (!passive && damage > 0) { DmgFactors * df = GetClass()->ActorInfo->DamageFactors; - if (df != NULL) + if (df != NULL && df->CountUsed() != 0) { const fixed_t * pdf = df->CheckKey(damageType); if (pdf== NULL && damageType != NAME_None) pdf = df->CheckKey(NAME_None); - if (pdf == NULL) pdf = &def; - + } + else + { + pdf = &def; + } + if (pdf != NULL) + { damage = newdamage = FixedMul(damage, *pdf); if (*pdf > 0 && damage == 0) damage = newdamage = 1; // don't allow zero damage as result of an underflow if (Owner != NULL && *pdf > FRACUNIT) S_Sound(Owner, 5, ActiveSound, 1.0f, ATTN_NONE); @@ -1530,12 +1535,15 @@ void APowerProtection::ModifyDamage(int damage, FName damageType, int &newdamage if (passive && damage > 0) { DmgFactors * df = GetClass()->ActorInfo->DamageFactors; - if (df != NULL) + if (df != NULL && df->CountUsed() != 0) { const fixed_t * pdf = df->CheckKey(damageType); if (pdf== NULL && damageType != NAME_None) pdf = df->CheckKey(NAME_None); - if (pdf == NULL) pdf = &def; + } + else pdf = &def; + if (pdf != NULL) + { damage = newdamage = FixedMul(damage, *pdf); if (Owner != NULL && *pdf < FRACUNIT) S_Sound(Owner, 5, ActiveSound, 1.0f, ATTN_NONE); } diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 3e8fcda734..12356e4002 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -737,8 +737,10 @@ void cht_Give (player_t *player, const char *name, int amount) // Give the weapon only if it belongs to the current game or // is in a weapon slot. Unfortunately this check only works in // singleplayer games because the weapon slots are stored locally. - // In multiplayer games all weapons must be given. - if (multiplayer || type->ActorInfo->GameFilter == GAME_Any || + // In multiplayer games or demors all weapons must be given because the state of + // the weapon slots is not guaranteed to be the same when recording or playing back. + if (multiplayer || demorecording || demoplayback || + type->ActorInfo->GameFilter == GAME_Any || (type->ActorInfo->GameFilter & gameinfo.gametype) || LocalWeapons.LocateWeapon(type, NULL, NULL)) { diff --git a/src/r_main.cpp b/src/r_main.cpp index 0698952aaf..3f83944235 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -370,16 +370,16 @@ void R_InitTables (void) const double pimul = PI*2/FINEANGLES; // viewangle tangent table - finetangent[0] = (angle_t)(FRACUNIT*tan ((0.5-FINEANGLES/4)*pimul)+0.5); + finetangent[0] = (fixed_t)(FRACUNIT*tan ((0.5-FINEANGLES/4)*pimul)+0.5); for (i = 1; i < FINEANGLES/2; i++) { - finetangent[i] = (angle_t)(FRACUNIT*tan ((i-FINEANGLES/4)*pimul)+0.5); + finetangent[i] = (fixed_t)(FRACUNIT*tan ((i-FINEANGLES/4)*pimul)+0.5); } // finesine table for (i = 0; i < FINEANGLES/4; i++) { - finesine[i] = (angle_t)(FRACUNIT * sin (i*pimul)); + finesine[i] = (fixed_t)(FRACUNIT * sin (i*pimul)); } for (i = 0; i < FINEANGLES/4; i++) { diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 96f5e807be..7d42c38ab2 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1854,8 +1854,8 @@ void S_ChannelEnded(FISoundChannel *ichan) { evicted = true; } - else - { + else if (schan->SfxInfo != NULL) + { unsigned int pos = GSnd->GetPosition(schan); unsigned int len = GSnd->GetSampleLength(schan->SfxInfo->data); if (pos == 0) @@ -1867,6 +1867,10 @@ void S_ChannelEnded(FISoundChannel *ichan) evicted = (pos < len); } } + else + { + evicted = false; + } if (!evicted) { S_ReturnChannel(schan); diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 77a837be8d..432b4d19d1 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1149,7 +1149,7 @@ DEFINE_PROPERTY(damagetype, S, Actor) DEFINE_PROPERTY(damagefactor, SF, Actor) { PROP_STRING_PARM(str, 0); - PROP_FIXED_PARM(id, 0); + PROP_FIXED_PARM(id, 1); if (bag.Info->DamageFactors == NULL) bag.Info->DamageFactors=new DmgFactors;