foxygit / doom Log in
commit 6a2255c70b882391931a7ef7ad9ada47a88b7c77
Author:     James Haley <haleyjd@hotmail.com>
AuthorDate: Mon Feb 25 01:38:41 2013 +0000
Commit:     James Haley <haleyjd@hotmail.com>
CommitDate: Mon Feb 25 01:38:41 2013 +0000

    Portability tweak when adding quest flags from collected items, due to
    the Broken Power Coupling's anomalous speed value of 512*FRACUNIT
    (verified against binary). Added note about this in the quest flags
    enumeration as well; bit 31 (quest #32) is accidentally set by this
    item, but is never checked for anywhere.

    Subversion-branch: /branches/v2-branch
    Subversion-revision: 2560
---
 src/strife/doomdef.h |  4 ++--
 src/strife/p_inter.c | 11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/strife/doomdef.h b/src/strife/doomdef.h
index 3c289808..d48b41ee 100644
--- a/src/strife/doomdef.h
+++ b/src/strife/doomdef.h
@@ -253,7 +253,7 @@ enum
     QF_QUEST5  = (1 << tk_quest5),  // Accepted Gov. Mourel's "bloody" chore
     QF_QUEST6  = (1 << tk_quest6),  // Destroyed the Power Coupling
     QF_QUEST7  = (1 << tk_quest7),  // Killed Blue Acolytes ("Scanning Team")
-    QF_QUEST8  = (1 << tk_quest8),
+    QF_QUEST8  = (1 << tk_quest8),  // Unused; formerly, picked up Broken Coupling
     QF_QUEST9  = (1 << tk_quest9),  // Obtained Derwin's ear
     QF_QUEST10 = (1 << tk_quest10), // Obtained Prison Pass
     QF_QUEST11 = (1 << tk_quest11), // Obtained Prison Key
@@ -277,7 +277,7 @@ enum
     QF_QUEST29 = (1 << tk_quest29), // Destroyed the Mines Transmitter
     QF_QUEST30 = (1 << tk_quest30),
     QF_QUEST31 = (1 << tk_quest31),
-    QF_QUEST32 = (1 << tk_quest32), // Note: seems to be unused
+    QF_QUEST32 = (1 << tk_quest32), // Unused; BUG: Broken Coupling accidentally sets it.

     QF_ALLQUESTS  = (QF_QUEST31 + (QF_QUEST31 - 1)) // does not include bit 32!
 };
diff --git a/src/strife/p_inter.c b/src/strife/p_inter.c
index 9bedd78c..b6138f32 100644
--- a/src/strife/p_inter.c
+++ b/src/strife/p_inter.c
@@ -726,11 +726,14 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher)

     if(special->flags & MF_GIVEQUEST)
     {
-        // [STRIFE] TODO - verify this. Seems that questflag isn't
-        // applied if the special's speed is equal to 8 or if
-        // the player has received a specific quest token
+        // [STRIFE]: Award quest flag based on the thing's speed. Quest 8 was
+        // apparently at some point given by the Broken Power Coupling, which is
+        // why they don't want to award it if you have Quest 6 (which is
+        // acquired by destroying the Front's working power coupling). BUT, the
+        // broken coupling object's speed is NOT 8... it is 512*FRACUNIT. For
+        // strict portability beyond the x86, we need to AND the operand by 31.
         if(special->info->speed != 8 || !(player->questflags & QF_QUEST6))
-            player->questflags |= 1 << (special->info->speed - 1);
+            player->questflags |= 1 << ((special->info->speed - 1) & 31);
     }