Mercurial > mm7
changeset 2195:70b63fe6587c
fixing a few bugs reported by PVS
author | Grumpy7 |
---|---|
date | Thu, 30 Jan 2014 23:03:04 +0100 |
parents | d0e321190c86 |
children | 628a0ad87136 |
files | CastSpellInfo.h DecalBuilder.cpp DecalBuilder.h Items.cpp UI/UIPopup.cpp mm7_2.cpp |
diffstat | 6 files changed, 58 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/CastSpellInfo.h Thu Jan 30 22:11:28 2014 +0100 +++ b/CastSpellInfo.h Thu Jan 30 23:03:04 2014 +0100 @@ -17,7 +17,7 @@ //----- (00426987) -------------------------------------------------------- inline CastSpellInfo() { - memset(this, 0, sizeof(this)); + memset(this, 0, sizeof(*this)); } struct GUIWindow *GetCastSpellInInventoryWindow();
--- 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) --------------------------------------------------------
--- a/DecalBuilder.h Thu Jan 30 22:11:28 2014 +0100 +++ b/DecalBuilder.h Thu Jan 30 23:03:04 2014 +0100 @@ -65,8 +65,8 @@ } - bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9); - bool AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b); + void AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9); + void AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b); //void ( ***vdestructor_ptr)(BloodsplatContainer *, bool); @@ -165,7 +165,7 @@ {} - bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9); + void AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9); void Reset(unsigned int bPreserveBloodsplats); char ApplyDecals(int light_level, char a3, struct stru154 *a4, int a5, struct RenderVertexSoft *a6, struct IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID); char _49B790_build_decal_geometry(int a2, char a3, DecalBuilder_stru0 *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
--- a/Items.cpp Thu Jan 30 22:11:28 2014 +0100 +++ b/Items.cpp Thu Jan 30 23:03:04 2014 +0100 @@ -1488,7 +1488,6 @@ if ( (uHolderPlayer >0 )&& (uHolderPlayer <= 4) ) { player_name = pPlayers[uHolderPlayer]->pName; - strlen(player_name); if ( player_name[strlen(player_name) - 1] == 's' ) format_str = pGlobalTXT_LocalizationStrings[655]; //"%s' Jar" else
--- a/UI/UIPopup.cpp Thu Jan 30 22:11:28 2014 +0100 +++ b/UI/UIPopup.cpp Thu Jan 30 23:03:04 2014 +0100 @@ -292,7 +292,7 @@ else if ( inspect_item->uEnchantmentType ) sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210], pItemsTable->pEnchantments[inspect_item->uEnchantmentType-1].pBonusStat, inspect_item->m_enchantmentStrength); //"Special" else if ( inspect_item->uSpecEnchantmentType ) - sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->m_enchantmentStrength); + sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement); else if ( inspect_item->uNumCharges ) sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges" } @@ -450,6 +450,7 @@ RECT v84; // [sp+ECh] [bp-100h]@26 const char *string_name[10]; // [sp+FCh] [bp-F0h]@145 const char *content[11]; // [sp+124h] [bp-C8h]@127 + unsigned char resistances[11]; // [sp+124h] [bp-C8h]@127 RenderBillboardTransform_local0 v106; // [sp+150h] [bp-9Ch]@3 unsigned int v107; // [sp+1A0h] [bp-4Ch]@18 unsigned __int16 *v108; // [sp+1A4h] [bp-48h]@34 @@ -734,7 +735,7 @@ } window->DrawText(pFontSmallnum, 12, 196, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[631], 0, 0, 0);//Effects - if ( !for_effects ) + if ( !for_effects && false) window->DrawText(pFontSmallnum, 28, LOBYTE(pFontSmallnum->uFontHeight) + 193, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[630], 0, 0, 0);//? else { @@ -744,86 +745,86 @@ { if ( pActors[uActorID].pActorBuffs[i].uExpireTime > 0 ) { - switch ( i - 1 ) + switch ( i ) { - case 0: + case ACTOR_BUFF_CHARM: pTextColorID = 60; pText = pGlobalTXT_LocalizationStrings[591];//Charmed break; - case 1: + case ACTOR_BUFF_SUMMONED: pTextColorID = 82; pText = pGlobalTXT_LocalizationStrings[649];//Summoned break; - case 2: + case ACTOR_BUFF_SHRINK: pTextColorID = 92; pText = pGlobalTXT_LocalizationStrings[592];//Shrunk break; - case 3: + case ACTOR_BUFF_AFRAID: pTextColorID = 63; pText = pGlobalTXT_LocalizationStrings[4];//Afraid break; - case 4: + case ACTOR_BUFF_STONED: pText = pGlobalTXT_LocalizationStrings[220];//Stoned pTextColorID = 81; break; - case 5: + case ACTOR_BUFF_PARALYZED: pText = pGlobalTXT_LocalizationStrings[162];//Paralyzed pTextColorID = 81; break; - case 6: + case ACTOR_BUFF_SLOWED: pText = pGlobalTXT_LocalizationStrings[593];//Slowed pTextColorID = 35; break; - case 8: + case ACTOR_BUFF_BERSERK: pText = pGlobalTXT_LocalizationStrings[608];//Berserk pTextColorID = 62; break; - case 7: - case 9: + case ACTOR_BUFF_SOMETHING_THAT_HALVES_AC: + case ACTOR_BUFF_MASS_DISTORTION: pText = ""; pTextColorID = 0; continue; - case 10: + case ACTOR_BUFF_FATE: pTextColorID = 47; pText = pGlobalTXT_LocalizationStrings[221];//Fate break; - case 11: + case ACTOR_BUFF_ENSLAVED: pTextColorID = 66; pText = pGlobalTXT_LocalizationStrings[607];//Enslaved break; - case 12: + case ACTOR_BUFF_DAY_OF_PROTECTION: pTextColorID = 85; pText = pGlobalTXT_LocalizationStrings[610];//Day of Protection break; - case 13: + case ACTOR_BUFF_HOUR_OF_POWER: pTextColorID = 86; pText = pGlobalTXT_LocalizationStrings[609];//Hour of Power break; - case 14: + case ACTOR_BUFF_SHIELD: pTextColorID = 17; pText = pGlobalTXT_LocalizationStrings[279];//Shield break; - case 15: + case ACTOR_BUFF_STONESKIN: pTextColorID = 38; pText = pGlobalTXT_LocalizationStrings[442];//Stoneskin break; - case 16: + case ACTOR_BUFF_BLESS: pTextColorID = 46; pText = pGlobalTXT_LocalizationStrings[443];//Bless break; - case 17: + case ACTOR_BUFF_HEROISM: pTextColorID = 51; pText = pGlobalTXT_LocalizationStrings[440];//Heroism break; - case 18: + case ACTOR_BUFF_HASTE: pTextColorID = 5; pText = pGlobalTXT_LocalizationStrings[441];//Haste break; - case 19: + case ACTOR_BUFF_PAIN_REFLECTION: pTextColorID = 95; pText = pGlobalTXT_LocalizationStrings[229];//Pain Reflection break; - case 20: + case ACTOR_BUFF_PAIN_HAMMERHANDS: pTextColorID = 73; pText = pGlobalTXT_LocalizationStrings[228];//Hammerhands break; @@ -831,14 +832,14 @@ pText = ""; break; } - if ( pText != "" ) + if ( _stricmp(pText, "" )) { window->DrawText(pFontSmallnum, 28, pTextHeight, GetSpellColor(pTextColorID), pText, 0, 0, 0); pTextHeight = pTextHeight + *(char *)((int)pFontSmallnum + 5) - 3; } } } - if ( pText == "" ) + if ( !_stricmp(pText,"" )) window->DrawText(pFontSmallnum, 28, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[153], 0, 0, 0);//Νες } @@ -851,10 +852,10 @@ } else { - sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);//? + sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);//? - [630] actually displays a question mark window->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); pTextHeight = v106.uViewportY + LOBYTE(pFontSmallnum->uFontHeight) - 3; - sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[12], 0, (unsigned int)pGlobalTXT_LocalizationStrings[630]);//? + sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[12], 0, pGlobalTXT_LocalizationStrings[630]);//? - [630] actually displays a question mark } window->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 6 + LOBYTE(pFontSmallnum->uFontHeight); @@ -938,28 +939,28 @@ string_name[8] = pGlobalTXT_LocalizationStrings[54]; string_name[9] = pGlobalTXT_LocalizationStrings[624]; - content[0] = (char *)pActors[uActorID].pMonsterInfo.uResFire; - content[1] = (char *)pActors[uActorID].pMonsterInfo.uResAir; - content[2] = (char *)pActors[uActorID].pMonsterInfo.uResWater; - content[3] = (char *)pActors[uActorID].pMonsterInfo.uResEarth; - content[4] = (char *)pActors[uActorID].pMonsterInfo.uResMind; - content[5] = (char *)pActors[uActorID].pMonsterInfo.uResSpirit; - content[6] = (char *)pActors[uActorID].pMonsterInfo.uResBody; - content[7] = (char *)pActors[uActorID].pMonsterInfo.uResLight; - content[8] = (char *)pActors[uActorID].pMonsterInfo.uResPhysical; - content[9] = (char *)pActors[uActorID].pMonsterInfo.uResDark; + resistances[0] = pActors[uActorID].pMonsterInfo.uResFire; + resistances[1] = pActors[uActorID].pMonsterInfo.uResAir; + resistances[2] = pActors[uActorID].pMonsterInfo.uResWater; + resistances[3] = pActors[uActorID].pMonsterInfo.uResEarth; + resistances[4] = pActors[uActorID].pMonsterInfo.uResMind; + resistances[5] = pActors[uActorID].pMonsterInfo.uResSpirit; + resistances[6] = pActors[uActorID].pMonsterInfo.uResBody; + resistances[7] = pActors[uActorID].pMonsterInfo.uResLight; + resistances[8] = pActors[uActorID].pMonsterInfo.uResPhysical; + resistances[9] = pActors[uActorID].pMonsterInfo.uResDark; if ( grandmaster_level ) { for ( uint i = 0; i < 10; i++ ) { - if ( content[i] == (char *)200 ) + if ( resistances[i] == 200 ) { pText = pGlobalTXT_LocalizationStrings[625];//Immune } else { - if ( content[i] ) + if ( resistances[i] ) pText = pGlobalTXT_LocalizationStrings[627];//Resistant else pText = pGlobalTXT_LocalizationStrings[153];//None
--- a/mm7_2.cpp Thu Jan 30 22:11:28 2014 +0100 +++ b/mm7_2.cpp Thu Jan 30 23:03:04 2014 +0100 @@ -1228,12 +1228,11 @@ pMonster->uTetherDistance = 256; pMonster->vInitialPosition.y = a4; pMonster->vPosition.y = a4; - pTexture = 0; pMonster->vInitialPosition.z = a3; pMonster->vPosition.z = a3; pMonster->uSectorID = pSector; pMonster->uGroup = spawn->uGroup; - pMonster->PrepareSprites((char)pTexture); + pMonster->PrepareSprites(0); pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; v32 = rand(); a3 = fixpoint_mul(stru_5C6E00->Cos(v32 % 2048), v52);