changeset 2224:c2eeeb991a87

some more pvs warning fixes
author Grumpy7
date Wed, 19 Feb 2014 22:26:10 +0100
parents 44d956d4f838
children 080fd5a5433d
files CastSpellInfo.cpp Game.cpp Indoor.cpp Player.cpp SaveLoad.cpp UI/UiGame.cpp
diffstat 6 files changed, 22 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/CastSpellInfo.cpp	Mon Feb 03 23:07:15 2014 +0100
+++ b/CastSpellInfo.cpp	Wed Feb 19 22:26:10 2014 +0100
@@ -492,7 +492,7 @@
         pSpellSprite.uAttributes |= 0x80u;
         pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
         int obj_id = pSpellSprite.Create(0, 0, 0, 0);
-        if ( !MonsterStats::BelongsToSupertype(pActor->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
+        if ( !MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
         {
           ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
           pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
@@ -2070,8 +2070,8 @@
         if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Eradicated]
           || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] )
         {
-          if ( !(pParty->pPlayers[v396].pConditions[Condition_Weak]) )
-            pParty->pPlayers[v396].PlaySound(SPEECH_25, 0);
+          if ( !(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak]) )
+            pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_25, 0);
           if ( skill_level == 4 )
           {
             pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Eradicated] = 0;
--- a/Game.cpp	Mon Feb 03 23:07:15 2014 +0100
+++ b/Game.cpp	Wed Feb 19 22:26:10 2014 +0100
@@ -1351,6 +1351,7 @@
   char Str2[128]; // [sp+238h] [bp-3C4h]@527
   Actor actor; // [sp+2B8h] [bp-344h]@4
   //unsigned short* screenshot;
+  int currHour;
 
   dword_50CDC8 = 0;
   if ( !pEventTimer->bPaused )
@@ -1943,8 +1944,8 @@
             uVoicesVolumeMultiplier = 9;
           if ( !uVoicesVolumeMultiplier )
             continue;
-            pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
-            continue;
+          pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
+          continue;
         case UIMSG_SetTurnSpeed:
           if ( uMessageParam )
             pParty->sRotationY = uMessageParam * pParty->sRotationY / uMessageParam;
@@ -4068,19 +4069,22 @@
           GameUI_SetFooterString(pTmpBuf.data());
           continue;
         case UIMSG_ShowStatus_DateTime:
-          pNPCData4 = (NPCData *)pParty->uCurrentHour;
-          if ( (signed int)pParty->uCurrentHour <= 12 )
+          currHour = pParty->uCurrentHour;
+          uNumSeconds = 1;
+          if (pParty->uCurrentHour > 12 )
           {
-            if ( !pNPCData4 )
-              pNPCData4 = (NPCData *)12;
+            if (pParty->uCurrentHour >= 24)
+              uNumSeconds = 0;
+            currHour = (currHour - 12);
           }
-          else
+          else 
           {
-            pNPCData4 = (NPCData *)((char *)pNPCData4 - 12);
+		  	if (pParty->uCurrentHour < 12) // 12:00 is PM
+	            uNumSeconds = 0;
+            if (pParty->uCurrentHour == 0)
+              currHour = 12;
           }
-          if ( pParty->uCurrentHour < 0xC || (uNumSeconds = 1, pParty->uCurrentHour >= 0x18) )
-            uNumSeconds = 0;
-          sprintf(pTmpBuf.data(), "%d:%02d%s %s %d %s %d", pNPCData4, pParty->uCurrentMinute, aAMPMNames[uNumSeconds], aDayNames[pParty->uDaysPlayed % 7],
+          sprintf(pTmpBuf.data(), "%d:%02d%s %s %d %s %d", currHour, pParty->uCurrentMinute, aAMPMNames[uNumSeconds], aDayNames[pParty->uDaysPlayed % 7],
             7 * pParty->uCurrentMonthWeek + pParty->uDaysPlayed % 7 + 1, aMonthNames[pParty->uCurrentMonth], pParty->uCurrentYear);
           GameUI_SetFooterString(pTmpBuf.data());
           continue;
--- a/Indoor.cpp	Mon Feb 03 23:07:15 2014 +0100
+++ b/Indoor.cpp	Wed Feb 19 22:26:10 2014 +0100
@@ -3240,7 +3240,7 @@
 
   for (uint i = 0; i < pIndoor->uNumFaces; ++i)
   {
-    if (!pIndoor->pFaces[i].uBitmapID != -1)
+    if (pIndoor->pFaces[i].uBitmapID != -1)
       pBitmaps_LOD->pTextures[pIndoor->pFaces[i].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[i].uBitmapID].palette_id1);
   }
 
--- a/Player.cpp	Mon Feb 03 23:07:15 2014 +0100
+++ b/Player.cpp	Wed Feb 19 22:26:10 2014 +0100
@@ -1996,7 +1996,6 @@
   {
     return 0;
   }
-    pGlobalTXT_LocalizationStrings[1];
   if ( !(BYTE2(actroPtr->uAttributes) & 0x80) )
     actroPtr->SetRandomGoldIfTheresNoItem();
   unsigned __int16 v6 = this->pActiveSkills[PLAYER_SKILL_STEALING];
@@ -2006,7 +2005,6 @@
   int v29 = StealingRandomBonuses[rand() % 5];
   fineIfFailed = actroPtr->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation);
   currMaxItemValue = v29 + v7 * v30;
-  pGlobalTXT_LocalizationStrings[200];
   if ( rand() % 100 < 5 || fineIfFailed > currMaxItemValue || BYTE2(actroPtr->uAttributes) & 8 )
   {
     Actor::AggroSurroundingPeasants(uActorID, 1);
--- a/SaveLoad.cpp	Mon Feb 03 23:07:15 2014 +0100
+++ b/SaveLoad.cpp	Wed Feb 19 22:26:10 2014 +0100
@@ -470,7 +470,7 @@
     compressed_block_size += 16;
     memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4);
     memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4);
-    sprintf(Source, "%s%s", &Filename, &Ext);
+    sprintf(Source, "%s%s", Filename, Ext);
     strcpy(pLodDirectory.pFilename, Source);
     pLodDirectory.uDataSize = compressed_block_size;
     if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) )
--- a/UI/UiGame.cpp	Mon Feb 03 23:07:15 2014 +0100
+++ b/UI/UiGame.cpp	Wed Feb 19 22:26:10 2014 +0100
@@ -118,8 +118,10 @@
     return;
   viewparams->bRedrawGameUI = true;
   if ( uActiveCharacter != uPlayerID )
+  {
     uActiveCharacter = uPlayerID;
     return;
+  }
   if (dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_6)
   {
     __debugbreak(); // fix indexing