shithub: choc

Download patch

ref: 9efed5192aeb52379a8bfc66cde3b773b1bcb681
parent: 289ae90614062bf5ab367a1befcec98ab99e7094
author: James Haley <haleyjd@hotmail.com>
date: Sun Sep 5 01:51:38 EDT 2010

Remove an order-of-evaluation dependency with respect to P_Random().

Subversion-branch: /branches/strife-branch
Subversion-revision: 2012

--- a/src/strife/p_pspr.c
+++ b/src/strife/p_pspr.c
@@ -654,13 +654,13 @@
 
     if (!linetarget)
     {
-	an += 1<<26;
-	bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
-	if (!linetarget)
-	{
-	    an -= 2<<26;
-	    bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
-	}
+        an += 1<<26;
+        bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
+        if (!linetarget)
+        {
+            an -= 2<<26;
+            bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
+        }
     }
 }
 
@@ -668,20 +668,26 @@
 //
 // P_GunShot
 //
+// [STRIFE] Modifications to support accuracy.
+//
 void
 P_GunShot
 ( mobj_t*	mo,
   boolean	accurate )
 {
-    angle_t	angle;
-    int		damage;
-	
+    angle_t     angle;
+    int         damage;
+    int         t;
+
     damage = 4*(P_Random ()%3+4);   // villsa [STRIFE] different damage formula
     angle = mo->angle;
 
     // villsa [STRIFE] apply player accuracy
     if (!accurate)
-	angle += (P_Random()-P_Random())<<(20 - (mo->player->accuracy * 4 / 100));
+    {
+        t = P_Random();
+        angle += (t - P_Random())<<(20 - (mo->player->accuracy * 4 / 100));
+    }
 
     P_LineAttack (mo, angle, MISSILERANGE, bulletslope, damage);
 }