diff DecalBuilder.cpp @ 2195:70b63fe6587c

fixing a few bugs reported by PVS
author Grumpy7
date Thu, 30 Jan 2014 23:03:04 +0100
parents 0a1438c16c2b
children e18200fcfb50
line wrap: on
line diff
--- a/DecalBuilder.cpp	Thu Jan 30 22:11:28 2014 +0100
+++ b/DecalBuilder.cpp	Thu Jan 30 23:03:04 2014 +0100
@@ -11,6 +11,7 @@
 #include "stru9.h"
 
 #include "Outdoor_stuff.h"
+#include "OurMath.h"
 
 
 struct DecalBuilder *pDecalBuilder = new DecalBuilder;
@@ -41,18 +42,16 @@
 
 
 //----- (0043B6EF) --------------------------------------------------------
-bool BloodsplatContainer::AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b)
+void BloodsplatContainer::AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b)
 {
-  int *v8; // esi@1
+  int v8; // esi@1
   int v9; // eax@3
   Bloodsplat *v10; // eax@3
-  int *result; // eax@3
-  int v12; // ecx@3
 
-  v8 = &this->uNumBloodsplats;
+  v8 = this->uNumBloodsplats;
   if ( this->uNumBloodsplats == 64 )
-    *v8 = 0;
-  v9 = 5 * (*v8)++;
+    v8 = 0;
+  v9 = 5 * (v8 + 1);
   v10 = &this->std__vector_pBloodsplats[8 * v9 / 0x28u];
   v10->x = x;
   v10->y = y;
@@ -61,17 +60,11 @@
   v10->r = r;
   v10->g = g;
   v10->b = b;
-  result = (int *)&this->std__vector_pBloodsplats_size;
-  v12 = this->std__vector_pBloodsplats_size + 1;
-  if ( v12 > 64 )
-    v12 = 64;
-  *result = v12;
-  LOBYTE(result) = 1;
-  return (bool)result;
+  this->std__vector_pBloodsplats_size = min(this->std__vector_pBloodsplats_size + 1, 64);
 }
 
 //----- (0049B490) --------------------------------------------------------
-bool DecalBuilder::AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9)
+void DecalBuilder::AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9)
 {
   //double v10; // ST1C_8@1
   char v11; // ST24_1@1
@@ -90,11 +83,11 @@
   a7a = LODWORD(v12);
   arg14c = r * 255.0;
   v13 = arg14c + 6.7553994e15;*/
-  return pBloodsplatContainer->AddBloodsplat(x, y, z, radius,
+  pBloodsplatContainer->AddBloodsplat(x, y, z, radius,
                                              //SLOBYTE(v13), a7a, v11);
-                                             r * 255.0f,
-                                             g * 255.0f,
-                                             b * 255.0f);
+                                             bankersRounding(r * 255.0f),
+                                             bankersRounding(g * 255.0f),
+                                             bankersRounding(b * 255.0f));
 }
 
 //----- (0049B525) --------------------------------------------------------