changeset 1113:39eaa6b00141

something to bool cast (performance warning) mostly fixed
author Grumpy7
date Tue, 28 May 2013 00:19:45 +0200
parents 4994eb3947ae
children d110108dab74
files Arcomage.cpp AudioPlayer.h Chest.h DecalBuilder.cpp DecorationList.h Indoor.cpp Indoor.h Items.h Monsters.cpp NPC.h Outdoor.h Party.h Player.cpp Render.cpp SpriteObject.h Vis.cpp mm7_2.cpp mm7_3.cpp stru10.cpp
diffstat 19 files changed, 55 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/Arcomage.cpp	Tue May 28 00:19:45 2013 +0200
@@ -736,7 +736,7 @@
     {
       result = dword_4DF3A4 - 2;
       if ( dword_4DF3A4 != 2 )
-        return result;
+        return result != 0;
       v64 = a1;
       v145 = &stru_505708[a1];
       v130 = a1;
@@ -1008,7 +1008,7 @@
           {
             --v123;
             if ( v123 < 0 )
-              return am_40BCFB(v64, v137);
+              return am_40BCFB(v64, v137) != 0;
           }
           v137 = dword_4FA9B0[2 * v123];
         }
@@ -1033,12 +1033,12 @@
           {
             ++v124;
             if ( v124 >= v136 )
-              return am_40BCFB(v64, v137);
+              return am_40BCFB(v64, v137) != 0;
           }
-          return am_40BE0E(v64, dword_4FA9B0[2 * v124]);
+          return am_40BE0E(v64, dword_4FA9B0[2 * v124]) != 0;
         }
       }
-      return am_40BCFB(v64, v137);
+      return am_40BCFB(v64, v137) != 0;
     }
     v9 = a1;
     v144 = &stru_505708[a1];
@@ -1300,7 +1300,7 @@
         {
           --v62;
           if ( v62 < 0 )
-            return am_40BCFB(v9, v137);
+            return am_40BCFB(v9, v137) != 0;
         }
         v137 = dword_4FA9B0[2 * v62];
       }
@@ -1325,12 +1325,12 @@
         {
           ++v63;
           if ( v63 >= v135 )
-            return am_40BCFB(v9, v137);
+            return am_40BCFB(v9, v137) != 0;
         }
-        return am_40BE0E(v9, dword_4FA9B0[2 * v63]);
+        return am_40BE0E(v9, dword_4FA9B0[2 * v63]) != 0;
       }
     }
-    return am_40BCFB(v9, v137);
+    return am_40BCFB(v9, v137) != 0;
   }
   v3 = 0;
   v4 = a1;
@@ -1355,7 +1355,7 @@
     }
     result = am_40BE0E(v4, v6);
   }
-  return result;
+  return result != 0;
 }
 // 408BB4: could not find valid save-restore pair for ebp
 // 4DF3A4: using guessed type int dword_4DF3A4;
--- a/AudioPlayer.h	Mon May 27 23:29:39 2013 +0200
+++ b/AudioPlayer.h	Tue May 28 00:19:45 2013 +0200
@@ -241,7 +241,7 @@
 
 struct SoundDesc
 {
-  inline bool Is3D()  {return uFlags & SOUND_DESC_3D;}
+  inline bool Is3D()  {return (uFlags & SOUND_DESC_3D) != 0;}
 
   char pSoundName[32];
   unsigned int uSoundID;
--- a/Chest.h	Mon May 27 23:29:39 2013 +0200
+++ b/Chest.h	Tue May 28 00:19:45 2013 +0200
@@ -48,9 +48,9 @@
 #pragma pack(push, 1)
 struct Chest //0x14cc
 {
-  inline bool Initialized() const    {return uFlags & CHEST_ITEMS_PLACED;}
+  inline bool Initialized() const    {return (uFlags & CHEST_ITEMS_PLACED) != 0;}
   inline void SetInitialized(bool b) {if (b) uFlags |= CHEST_ITEMS_PLACED; else uFlags &= ~CHEST_ITEMS_PLACED;}
-  inline bool Trapped() const        {return uFlags & CHEST_TRAPPED;}
+  inline bool Trapped() const        {return (uFlags & CHEST_TRAPPED) != 0;}
 
   static bool CanPlaceItemAt(signed int a1, int a2, signed int uChestID);
   static int CountChestItems(signed int uChestID);
--- a/DecalBuilder.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/DecalBuilder.cpp	Tue May 28 00:19:45 2013 +0200
@@ -581,7 +581,7 @@
   float a3;
 
   this->uNumDecals = 0;
-  result = pBloodsplatContainer->std__vector_pBloodsplats_size;
+  result = pBloodsplatContainer->std__vector_pBloodsplats_size != 0;
   v24 = this;
   v23 = pBloodsplatContainer->std__vector_pBloodsplats_size;
   if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
--- a/DecorationList.h	Mon May 27 23:29:39 2013 +0200
+++ b/DecorationList.h	Tue May 28 00:19:45 2013 +0200
@@ -25,10 +25,10 @@
 #pragma pack(push, 1)
 struct DecorationDesc
 {
-  inline bool CanMoveThrough() {return uFlags & DECORATION_MOVE_THROUGH;}
-  inline bool DontDraw()       {return uFlags & DECORATION_DONT_DRAW;} 
-  inline bool SoundOnDawn()    {return uFlags & DECORATION_SOUND_ON_DAWN;}
-  inline bool SoundOnDusk()    {return uFlags & DECORATION_SOUND_ON_DUSK;}
+  inline bool CanMoveThrough() {return (uFlags & DECORATION_MOVE_THROUGH) != 0;}
+  inline bool DontDraw()       {return (uFlags & DECORATION_DONT_DRAW) != 0;} 
+  inline bool SoundOnDawn()    {return (uFlags & DECORATION_SOUND_ON_DAWN) != 0;}
+  inline bool SoundOnDusk()    {return (uFlags & DECORATION_SOUND_ON_DUSK) != 0;}
 
   char pName[32];
   char field_20[32];
--- a/Indoor.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/Indoor.cpp	Tue May 28 00:19:45 2013 +0200
@@ -3260,7 +3260,7 @@
         return pSectorID;
     }
   }
-  //return pSectorID;
+  return pSectorID;
 }
 // 49AC17: using guessed type int var_108[50];
 
--- a/Indoor.h	Mon May 27 23:29:39 2013 +0200
+++ b/Indoor.h	Tue May 28 00:19:45 2013 +0200
@@ -23,7 +23,7 @@
 {
   LevelDecoration();
   int GetGlobalEvent();
-  int IsInteractive();
+  bool IsInteractive();
   bool _47A825();
 
 
@@ -286,11 +286,11 @@
   struct Texture *GetTexture();
   void FromODM(struct ODMFace *face);
 
-  inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;}
+  inline bool Invisible() const {return (uAttributes & FACE_INVISIBLE) != 0;}
   inline bool Visible() const   {return !Invisible();}
-  inline bool Portal() const    {return uAttributes & FACE_PORTAL;}
-  inline bool Fluid() const     {return uAttributes & FACE_FLUID;}
-  inline bool Clickable() const {return uAttributes & FACE_CLICKABLE;}
+  inline bool Portal() const    {return (uAttributes & FACE_PORTAL) != 0;}
+  inline bool Fluid() const     {return (uAttributes & FACE_FLUID) != 0;}
+  inline bool Clickable() const {return (uAttributes & FACE_CLICKABLE) != 0;}
 
 
   struct Plane_float_ pFacePlane;
--- a/Items.h	Mon May 27 23:29:39 2013 +0200
+++ b/Items.h	Tue May 28 00:19:45 2013 +0200
@@ -145,10 +145,10 @@
  //   Reset();
  // }
 
-  inline bool Broken()        {return uAttributes & ITEM_BROKEN;}
-  inline bool Identified()    {return uAttributes & ITEM_IDENTIFIED;}
+  inline bool Broken()        {return (uAttributes & ITEM_BROKEN) != 0;}
+  inline bool Identified()    {return (uAttributes & ITEM_IDENTIFIED) != 0;}
   inline void SetIdentified() {uAttributes |= ITEM_IDENTIFIED;}
-  inline bool Stolen()        {return uAttributes & ITEM_STOLEN;}
+  inline bool Stolen()        {return (uAttributes & ITEM_STOLEN) != 0;}
   inline void SetStolen()     {uAttributes |= ITEM_STOLEN;}
 
   bool GenerateArtifact();
--- a/Monsters.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/Monsters.cpp	Tue May 28 00:19:45 2013 +0200
@@ -1166,5 +1166,6 @@
         {
         if( (!_stricmp(pMonsters[i].pMonsterName, pMonsterName)))
             return i;
-        }
     }
+    assert(false && "Monster not found!");
+}
--- a/NPC.h	Mon May 27 23:29:39 2013 +0200
+++ b/NPC.h	Tue May 28 00:19:45 2013 +0200
@@ -77,7 +77,7 @@
 #pragma pack(push, 1)
 struct NPCData  //4Ch
 {
-  inline bool Hired() {return uFlags & 0x80;}
+  inline bool Hired() {return (uFlags & 0x80) != 0;}
 
   char *pName;  //0
   unsigned int uPortraitID;  //4
--- a/Outdoor.h	Mon May 27 23:29:39 2013 +0200
+++ b/Outdoor.h	Tue May 28 00:19:45 2013 +0200
@@ -85,11 +85,11 @@
   
   static bool IsBackfaceCulled(struct ODMFace *a1, struct RenderVertexSoft *a2, struct stru148 *a3);
   
-  inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;}
+  inline bool Invisible() const {return (uAttributes & FACE_INVISIBLE) != 0;}
   inline bool Visible() const   {return !Invisible();}
-  inline bool Portal() const    {return uAttributes & FACE_PORTAL;}
-  inline bool Fluid() const     {return uAttributes & FACE_FLUID;}
-  inline bool Clickable() const {return uAttributes & FACE_CLICKABLE;}
+  inline bool Portal() const    {return (uAttributes & FACE_PORTAL) != 0;}
+  inline bool Fluid() const     {return (uAttributes & FACE_FLUID) != 0;}
+  inline bool Clickable() const {return (uAttributes & FACE_CLICKABLE) != 0;}
 
   struct Plane_int_ pFacePlane;
   int zCalc1;
--- a/Party.h	Mon May 27 23:29:39 2013 +0200
+++ b/Party.h	Tue May 28 00:19:45 2013 +0200
@@ -186,13 +186,13 @@
   inline bool FlyActive()            {return pPartyBuffs[PARTY_BUFF_FLY].uExpireTime > 0;}
   inline bool WaterWalkActive()      {return pPartyBuffs[PARTY_BUFF_WATER_WALK].uExpireTime > 0;}
   inline bool ImmolationActive()     {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uExpireTime > 0;}
-  inline bool ImmolationSkillLevel() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uSkill;}
+  inline int ImmolationSkillLevel() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uSkill;}
   inline bool FeatherFallActive()    {return pPartyBuffs[PARTY_BUFF_FEATHER_FALL].uExpireTime > 0;}
   inline bool Invisible()            {return pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0;}
 
-  inline bool GetRedAlert()    {return uFlags & PARTY_FLAGS_1_ALERT_RED;}
+  inline bool GetRedAlert()    {return (uFlags & PARTY_FLAGS_1_ALERT_RED) != 0;}
   inline void SetRedAlert()    {uFlags |= PARTY_FLAGS_1_ALERT_RED;}
-  inline bool GetYellowAlert() {return uFlags & PARTY_FLAGS_1_ALERT_YELLOW;}
+  inline bool GetYellowAlert() {return (uFlags & PARTY_FLAGS_1_ALERT_YELLOW) != 0;}
   inline void SetYellowAlert() {uFlags |= PARTY_FLAGS_1_ALERT_YELLOW;}
 
 
--- a/Player.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/Player.cpp	Tue May 28 00:19:45 2013 +0200
@@ -6073,7 +6073,7 @@
     }
     
   
-  
+    assert(false && "Unknown attribute!");
 }
 
 //----- (00490109) --------------------------------------------------------
@@ -9041,11 +9041,11 @@
               break;
             case 243:
               v17 = (char *)&this->uSkillPoints;
-			  result = *v17;
+			  result = *v17 != NULL;
               if ( (unsigned int)pValue <= *(int *)v17 )
               {
 					*(int *)v17 -= (int)pValue;
-					result = v17;
+					result = (v17 != NULL);
 			  }
               else
                 *(int *)v17 = 0;
@@ -9105,6 +9105,7 @@
         pParty->uNumArenaLordWins -= (char)pValue;
         break;
     }
+    assert(false && "Function not returning any value!");
   }
   else
   {
--- a/Render.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/Render.cpp	Tue May 28 00:19:45 2013 +0200
@@ -1929,8 +1929,8 @@
   int v77; // [sp-Ch] [bp-DCh]@61
   IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61
   //int v79; // [sp-4h] [bp-D4h]@61
-  int v80; // [sp+0h] [bp-D0h]@59
-  int v81; // [sp+0h] [bp-D0h]@109
+  bool v80; // [sp+0h] [bp-D0h]@59
+  bool v81; // [sp+0h] [bp-D0h]@109
   int v82; // [sp+54h] [bp-7Ch]@1
   int v83; // [sp+60h] [bp-70h]@1
   int v84; // [sp+6Ch] [bp-64h]@1
@@ -2298,13 +2298,13 @@
       {
         if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id )
         {
-          v81 = 0;
+          v81 = false;
           v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
         }
         else
         {
           v58 = v40->uTileBitmapID;
-          v81 = 1;
+          v81 = true;
         }
         pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81);
       }
@@ -5920,7 +5920,7 @@
   pParty->uFlags |= 2u;
   LODWORD(flt_6BE3A0) = 0x3F0CCCCDu;
   pViewport->_4C02F8(36044);
-  return v15;
+  return v15 != 0;
 }
 // 6BE3A0: using guessed type float flt_6BE3A0;
 
@@ -10651,7 +10651,7 @@
 void Render::ChangeBetweenWinFullscreenModes()
 {
   float v0; // ST14_4@17
-  int v1; // edx@24
+  bool v1; // edx@24
   signed int v2; // ecx@24
   int v3; // esi@25
   int v4; // edx@26
@@ -10733,9 +10733,8 @@
         ++v3;
         *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR;
         LOBYTE(v4) = v5->uParticleTrailColorG;
-        v1 = v5->uParticleTrailColorB | (v4 << 8);
+        v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8);
         ++v2;
-        v5->uParticleTrailColor = v1;
       }
       while ( v2 < (signed int)pObjectList->uNumObjects );
     }
--- a/SpriteObject.h	Mon May 27 23:29:39 2013 +0200
+++ b/SpriteObject.h	Tue May 28 00:19:45 2013 +0200
@@ -12,7 +12,7 @@
 #pragma pack(push, 1)
 struct SpriteObject
 {
-  inline bool AttachedToActor() const {return uAttributes & OBJECT_ATTACHED_TO_ACTOR;}
+  inline bool AttachedToActor() const {return (uAttributes & OBJECT_ATTACHED_TO_ACTOR) != 0;}
 
   SpriteObject();
   int Create(int yaw, int pitch, int a4, int a5);
--- a/Vis.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/Vis.cpp	Tue May 28 00:19:45 2013 +0200
@@ -488,7 +488,7 @@
   Vis *thisa; // [sp+68h] [bp-8h]@1
   RenderVertexSoft *v15; // [sp+6Ch] [bp-4h]@2
 
-  result = a4;
+  result = a4 != 0;
   thisa = this;
   if ( a4 > a3 )
   {
--- a/mm7_2.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/mm7_2.cpp	Tue May 28 00:19:45 2013 +0200
@@ -7053,7 +7053,7 @@
         v29 = 0;
         //goto LABEL_262;
         v30 = 1;
-        ArcomageGame::OnMouseClick(v30, v29);
+        ArcomageGame::OnMouseClick(v30, v29 != 0);
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
 
       case WM_LBUTTONDBLCLK:
@@ -7129,7 +7129,7 @@
           ArcomageGame::OnMouseMove((POINT *)pXY);
           ArcomageGame::OnMouseClick(0, wParam & 1);
           v29 = (wParam >> 1) & 1;
-          ArcomageGame::OnMouseClick(1, v29);
+          ArcomageGame::OnMouseClick(1, v29 != 0);
         }
         else
         {
--- a/mm7_3.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/mm7_3.cpp	Tue May 28 00:19:45 2013 +0200
@@ -13911,7 +13911,7 @@
 //----- (00449B57) --------------------------------------------------------
 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 )
 {
-  return a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8);
+  return (a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8)) != 0;
 }
 
 //----- (00449B7E) --------------------------------------------------------
@@ -13980,7 +13980,7 @@
 }
 
 //----- (0044C2F4) --------------------------------------------------------
-int LevelDecoration::IsInteractive()
+bool LevelDecoration::IsInteractive()
 {
   switch (uDecorationDescID)
   {
--- a/stru10.cpp	Mon May 27 23:29:39 2013 +0200
+++ b/stru10.cpp	Tue May 28 00:19:45 2013 +0200
@@ -775,7 +775,7 @@
   //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
  //   pGame->pIndoorCameraD3D->debug_outline_sw(pLimits, 4, 0xFF1E1E, 0.000099999997);
   if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding))
-    return _49C720(pOutBounding, a3);
+    return _49C720(pOutBounding, a3) != 0;
   return false;
 }
 // 4D864C: using guessed type char byte_4D864C;