Core&Tools: Fix multiple issues found by a static code coverage tool
This commit is contained in:
@@ -98,7 +98,16 @@ namespace VMAP
|
||||
|
||||
printf("Creating map tree for map %u...\n", map_iter->first);
|
||||
BIH pTree;
|
||||
pTree.build(mapSpawns, BoundsTrait<ModelSpawn*>::getBounds);
|
||||
|
||||
try
|
||||
{
|
||||
pTree.build(mapSpawns, BoundsTrait<ModelSpawn*>::getBounds);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
printf("Exception ""%s"" when calling pTree.build", e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===> possibly move this code to StaticMapTree class
|
||||
std::map<uint32, uint32> modelNodeIdx;
|
||||
|
||||
@@ -696,13 +696,12 @@ void ChatHandler::FillMessageData(WorldPacket* data, WorldSession* session, uint
|
||||
*data << uint32(0); // 2.1.0
|
||||
*data << uint32(speaker->GetName().size() + 1);
|
||||
*data << speaker->GetName();
|
||||
uint64 listener_guid = 0;
|
||||
*data << uint64(listener_guid);
|
||||
if (listener_guid && !IS_PLAYER_GUID(listener_guid))
|
||||
{
|
||||
*data << uint32(1); // string listener_name_length
|
||||
*data << uint8(0); // string listener_name
|
||||
}
|
||||
*data << uint64(0); // listener_guid
|
||||
//if (listener_guid && !IS_PLAYER_GUID(listener_guid))
|
||||
//{
|
||||
// *data << uint32(1); // string listener_name_length
|
||||
// *data << uint8(0); // string listener_name
|
||||
//}
|
||||
*data << uint32(messageLength);
|
||||
*data << message;
|
||||
*data << uint8(0);
|
||||
|
||||
@@ -6878,10 +6878,8 @@ void Player::CheckAreaExploreAndOutdoor()
|
||||
}
|
||||
else if (diff > 5)
|
||||
{
|
||||
int32 exploration_percent = (100-((diff-5)*5));
|
||||
if (exploration_percent > 100)
|
||||
exploration_percent = 100;
|
||||
else if (exploration_percent < 0)
|
||||
int32 exploration_percent = 100 - ((diff - 5) * 5);
|
||||
if (exploration_percent < 0)
|
||||
exploration_percent = 0;
|
||||
|
||||
XP = uint32(sObjectMgr->GetBaseXP(areaEntry->area_level)*exploration_percent/100*sWorld->getRate(RATE_XP_EXPLORE));
|
||||
|
||||
@@ -2411,6 +2411,7 @@ void UnitAura::FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster)
|
||||
}
|
||||
case SPELL_EFFECT_APPLY_AREA_AURA_PET:
|
||||
targetList.push_back(GetUnitOwner());
|
||||
// no break
|
||||
case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
|
||||
{
|
||||
if (Unit* owner = GetUnitOwner()->GetCharmerOrOwner())
|
||||
|
||||
@@ -6129,6 +6129,7 @@ SpellCastResult Spell::CheckItems()
|
||||
return SPELL_FAILED_DONT_REPORT;
|
||||
}
|
||||
}
|
||||
// no break
|
||||
case SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC:
|
||||
{
|
||||
Item* targetItem = m_targets.GetItemTarget();
|
||||
|
||||
@@ -1236,7 +1236,7 @@ void SpellMgr::LoadSpellTalentRanks()
|
||||
node.rank = rank + 1;
|
||||
|
||||
node.prev = prevSpell;
|
||||
node.next = node.rank < MAX_TALENT_RANK ? GetSpellInfo(talentInfo->RankID[rank + 1]) : NULL;
|
||||
node.next = node.rank < MAX_TALENT_RANK ? GetSpellInfo(talentInfo->RankID[node.rank]) : NULL;
|
||||
|
||||
mSpellChains[spellId] = node;
|
||||
mSpellInfoMap[spellId]->ChainEntry = &mSpellChains[spellId];
|
||||
@@ -2782,6 +2782,9 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
|
||||
{
|
||||
uint32 enchantId = spellInfo->Effects[j].MiscValue;
|
||||
SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId);
|
||||
if (!enchant)
|
||||
break;
|
||||
|
||||
for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
|
||||
{
|
||||
if (enchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
|
||||
@@ -3769,10 +3772,10 @@ void SpellMgr::LoadSpellInfoCorrections()
|
||||
}
|
||||
}
|
||||
|
||||
SummonPropertiesEntry* properties = const_cast<SummonPropertiesEntry*>(sSummonPropertiesStore.LookupEntry(121));
|
||||
properties->Type = SUMMON_TYPE_TOTEM;
|
||||
properties = const_cast<SummonPropertiesEntry*>(sSummonPropertiesStore.LookupEntry(647)); // 52893
|
||||
properties->Type = SUMMON_TYPE_TOTEM;
|
||||
if (SummonPropertiesEntry* properties = const_cast<SummonPropertiesEntry*>(sSummonPropertiesStore.LookupEntry(121)))
|
||||
properties->Type = SUMMON_TYPE_TOTEM;
|
||||
if (SummonPropertiesEntry* properties = const_cast<SummonPropertiesEntry*>(sSummonPropertiesStore.LookupEntry(647))) // 52893
|
||||
properties->Type = SUMMON_TYPE_TOTEM;
|
||||
|
||||
TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, ">> Loaded SpellInfo corrections in %u ms", GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ public:
|
||||
{
|
||||
if (InstanceScript* instance = go->GetInstanceScript())
|
||||
if (instance->GetData(DATA_EGG_EVENT) != DONE)
|
||||
if (Creature* razor = Unit::GetCreature(*go, instance ? instance->GetData64(DATA_RAZORGORE_THE_UNTAMED) : 0))
|
||||
if (Creature* razor = Unit::GetCreature(*go, instance->GetData64(DATA_RAZORGORE_THE_UNTAMED)))
|
||||
{
|
||||
razor->Attack(player, true);
|
||||
player->CastSpell(razor, SPELL_MINDCONTROL);
|
||||
|
||||
@@ -473,6 +473,7 @@ public:
|
||||
{
|
||||
case SPELL_BLAZE:
|
||||
target->CastSpell(target, SPELL_BLAZE_SUMMON, true);
|
||||
break;
|
||||
case SPELL_CONFLAGRATION:
|
||||
case SPELL_FLAME_SEAR:
|
||||
HandleTouchedSpells(target, SPELL_FLAME_TOUCHED);
|
||||
|
||||
@@ -139,10 +139,12 @@ public:
|
||||
Talk(SAY_CORPORAL_4);
|
||||
uiTimer = 2500;
|
||||
uiPhase = 5;
|
||||
break;
|
||||
case 5:
|
||||
Talk(SAY_CORPORAL_5);
|
||||
uiTimer = 0;
|
||||
uiPhase = 0;
|
||||
break;
|
||||
}
|
||||
} else uiTimer -= uiDiff;
|
||||
}
|
||||
|
||||
@@ -361,13 +361,12 @@ public:
|
||||
break;
|
||||
case 15:
|
||||
Talk(SAY_WP_2);
|
||||
break;
|
||||
case 21:
|
||||
Theldanis = GetClosestCreatureWithEntry(me, NPC_THEL_DANIS, 150);
|
||||
if (Theldanis)
|
||||
Theldanis->AI()->Talk(SAY_WP_3);
|
||||
break;
|
||||
case 22:
|
||||
break;
|
||||
case 23:
|
||||
Ughost = me->SummonCreature(NPC_GHOST_UTHER, 971.86f, -1825.42f, 81.99f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
|
||||
if (Ughost)
|
||||
|
||||
@@ -608,6 +608,7 @@ public:
|
||||
if (GameObject* pMainDoor = instance->GetGameObject(uiMainDoor))
|
||||
pMainDoor->SetGoState(GO_STATE_READY);
|
||||
DoUpdateWorldState(WORLD_STATE_VH_PRISON_STATE, 100);
|
||||
// no break
|
||||
}
|
||||
default:
|
||||
SpawnPortal();
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void EnterCombat(Unit* /*who*/)OVERRIDE {}
|
||||
void EnterCombat(Unit* /*who*/) OVERRIDE {}
|
||||
|
||||
void UpdateAI(uint32 diff) OVERRIDE
|
||||
{
|
||||
@@ -119,7 +119,8 @@ public:
|
||||
case 3:
|
||||
DoCast(me, SPELL_EXPLODE_CART, true);
|
||||
phaseTimer = 2000;
|
||||
phase = 4;
|
||||
phase = 5; // @fixme: phase 4 is missing...
|
||||
break;
|
||||
case 5:
|
||||
DoCast(me, SPELL_SUMMON_WORM, true);
|
||||
if (Unit* worm = me->FindNearestCreature(26250, 3))
|
||||
|
||||
@@ -521,9 +521,9 @@ class spell_sha_flame_shock : public SpellScriptLoader
|
||||
// Lava Flows
|
||||
if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, SHAMAN_ICON_ID_SHAMAN_LAVA_FLOW, EFFECT_0))
|
||||
{
|
||||
SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_SHAMAN_LAVA_FLOWS_R1);
|
||||
if (!aurEff->GetSpellInfo()->IsRankOf(firstRankSpellInfo))
|
||||
return;
|
||||
if (SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_SHAMAN_LAVA_FLOWS_R1))
|
||||
if (!aurEff->GetSpellInfo()->IsRankOf(firstRankSpellInfo))
|
||||
return;
|
||||
|
||||
uint8 rank = aurEff->GetSpellInfo()->GetRank();
|
||||
caster->CastSpell(caster, sSpellMgr->GetSpellWithRank(SPELL_SHAMAN_LAVA_FLOWS_TRIGGERED_R1, rank), true);
|
||||
|
||||
@@ -60,6 +60,9 @@ m_length(NULL)
|
||||
if (mysql_stmt_store_result(m_stmt))
|
||||
{
|
||||
TC_LOG_WARN(LOG_FILTER_SQL, "%s:mysql_stmt_store_result, cannot bind result from MySQL server. Error: %s", __FUNCTION__, mysql_stmt_error(m_stmt));
|
||||
delete[] m_rBind;
|
||||
delete[] m_isNull;
|
||||
delete[] m_length;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ inline bool isExtendedLatinCharacter(wchar_t wchar)
|
||||
return true;
|
||||
if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
return true;
|
||||
if (wchar >= 0x00D8 && wchar <= 0x00DF) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
|
||||
if (wchar >= 0x00D8 && wchar <= 0x00DE) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
|
||||
return true;
|
||||
if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
|
||||
return true;
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
mpq_archive_s *mpq_a;
|
||||
|
||||
MPQArchive(const char* filename);
|
||||
~MPQArchive() { close(); }
|
||||
void close();
|
||||
|
||||
void GetFileListTo(vector<string>& filelist) {
|
||||
|
||||
@@ -202,7 +202,10 @@ namespace MMAP
|
||||
minX = INT_MIN;
|
||||
minY = INT_MIN;
|
||||
|
||||
float bmin[3], bmax[3], lmin[3], lmax[3];
|
||||
float bmin[3] = { 0, 0, 0 };
|
||||
float bmax[3] = { 0, 0, 0 };
|
||||
float lmin[3] = { 0, 0, 0 };
|
||||
float lmax[3] = { 0, 0, 0 };
|
||||
MeshData meshData;
|
||||
|
||||
// make sure we process maps which don't have tiles
|
||||
@@ -260,25 +263,45 @@ namespace MMAP
|
||||
|
||||
uint32 verticesCount, indicesCount;
|
||||
if (fread(&verticesCount, sizeof(uint32), 1, file) != 1)
|
||||
{
|
||||
fclose(file);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fread(&indicesCount, sizeof(uint32), 1, file) != 1)
|
||||
{
|
||||
fclose(file);
|
||||
return;
|
||||
}
|
||||
|
||||
float* verts = new float[verticesCount];
|
||||
int* inds = new int[indicesCount];
|
||||
|
||||
if (fread(verts, sizeof(float), verticesCount, file) != verticesCount)
|
||||
{
|
||||
fclose(file);
|
||||
delete[] verts;
|
||||
delete[] inds;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fread(inds, sizeof(int), indicesCount, file) != indicesCount)
|
||||
{
|
||||
fclose(file);
|
||||
delete[] verts;
|
||||
delete[] inds;
|
||||
return;
|
||||
}
|
||||
|
||||
MeshData data;
|
||||
|
||||
for (uint32 i = 0; i < verticesCount; ++i)
|
||||
data.solidVerts.append(verts[i]);
|
||||
delete[] verts;
|
||||
|
||||
for (uint32 i = 0; i < indicesCount; ++i)
|
||||
data.solidTris.append(inds[i]);
|
||||
delete[] inds;
|
||||
|
||||
TerrainBuilder::cleanVertices(data.solidVerts, data.solidTris);
|
||||
// get bounds of current tile
|
||||
@@ -659,6 +682,9 @@ namespace MMAP
|
||||
if (!iv.polyMesh)
|
||||
{
|
||||
printf("%s alloc iv.polyMesh FIALED!\n", tileString);
|
||||
delete[] pmmerge;
|
||||
delete[] dmmerge;
|
||||
delete[] tiles;
|
||||
return;
|
||||
}
|
||||
rcMergePolyMeshes(m_rcContext, pmmerge, nmerge, *iv.polyMesh);
|
||||
@@ -667,6 +693,9 @@ namespace MMAP
|
||||
if (!iv.polyMeshDetail)
|
||||
{
|
||||
printf("%s alloc m_dmesh FIALED!\n", tileString);
|
||||
delete[] pmmerge;
|
||||
delete[] dmmerge;
|
||||
delete[] tiles;
|
||||
return;
|
||||
}
|
||||
rcMergePolyMeshDetails(m_rcContext, dmmerge, nmerge, *iv.polyMeshDetail);
|
||||
@@ -674,7 +703,6 @@ namespace MMAP
|
||||
// free things up
|
||||
delete[] pmmerge;
|
||||
delete[] dmmerge;
|
||||
|
||||
delete[] tiles;
|
||||
|
||||
// set polygons as walkable
|
||||
|
||||
@@ -114,7 +114,6 @@ namespace MMAP
|
||||
const char *p = dirpath.c_str();
|
||||
DIR * dirp = opendir(p);
|
||||
struct dirent * dp;
|
||||
dirp = opendir(p);
|
||||
|
||||
while (dirp)
|
||||
{
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc != 3)
|
||||
if (argc != 3)
|
||||
{
|
||||
//printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv[0]);
|
||||
std::cout << "usage: " << argv[0] << " <raw data dir> <vmap dest dir>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -19,7 +18,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
VMAP::TileAssembler* ta = new VMAP::TileAssembler(src, dest);
|
||||
|
||||
if(!ta->convertWorld2())
|
||||
if (!ta->convertWorld2())
|
||||
{
|
||||
std::cout << "exit with errors" << std::endl;
|
||||
delete ta;
|
||||
|
||||
@@ -49,7 +49,13 @@ void ExtractGameobjectModels()
|
||||
basepath += "/";
|
||||
std::string path;
|
||||
|
||||
FILE * model_list = fopen((basepath + "temp_gameobject_models").c_str(), "wb");
|
||||
std::string modelListPath = basepath + "temp_gameobject_models";
|
||||
FILE* model_list = fopen(modelListPath.c_str(), "wb");
|
||||
if (!model_list)
|
||||
{
|
||||
printf("Fatal error: Could not open file %s\n", modelListPath.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
for (DBCFile::Iterator it = dbc.begin(); it != dbc.end(); ++it)
|
||||
{
|
||||
|
||||
@@ -158,16 +158,16 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
return true;
|
||||
|
||||
int p = 0;
|
||||
//Select root wmo files
|
||||
// Select root wmo files
|
||||
char const* rchr = strrchr(plain_name, '_');
|
||||
if(rchr != NULL)
|
||||
if (rchr != NULL)
|
||||
{
|
||||
char cpy[4];
|
||||
strncpy((char*)cpy, rchr, 4);
|
||||
memcpy(cpy, rchr, 4);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
int m = cpy[i];
|
||||
if(isdigit(m))
|
||||
if (isdigit(m))
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,14 +136,12 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE* pOutfile)
|
||||
return true;
|
||||
}
|
||||
|
||||
WMORoot::~WMORoot()
|
||||
{
|
||||
}
|
||||
|
||||
WMOGroup::WMOGroup(const std::string &filename) :
|
||||
filename(filename), MOPY(0), MOVI(0), MoviEx(0), MOVT(0), MOBA(0), MobaEx(0),
|
||||
hlq(0), LiquEx(0), LiquBytes(0), groupName(0), descGroupName(0), mogpFlags(0),
|
||||
mopy_size(0), moba_size(0), LiquEx_size(0), nVertices(0), nTriangles(0)
|
||||
mopy_size(0), moba_size(0), LiquEx_size(0), nVertices(0), nTriangles(0),
|
||||
moprIdx(0), moprNItems(0), nBatchA(0), nBatchB(0), fogIdx(0), liquidType(0),
|
||||
groupWMOID(0), liquflags(0)
|
||||
{
|
||||
memset(bbcorn1, 0, sizeof(bbcorn1));
|
||||
memset(bbcorn2, 0, sizeof(bbcorn2));
|
||||
@@ -439,7 +437,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
|
||||
if (liquidEntry && liquidEntry < 21)
|
||||
{
|
||||
switch (((uint8)liquidEntry - 1) & 3)
|
||||
switch ((liquidEntry - 1) & 3)
|
||||
{
|
||||
case 0:
|
||||
liquidEntry = ((mogpFlags & 0x80000) != 0) + 13;
|
||||
@@ -453,8 +451,6 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool precise
|
||||
case 3:
|
||||
liquidEntry = 20;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +484,7 @@ WMOGroup::~WMOGroup()
|
||||
}
|
||||
|
||||
WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile)
|
||||
: currx(0), curry(0), wmo(NULL), doodadset(0), pos(), indx(0), d3(0)
|
||||
: currx(0), curry(0), wmo(NULL), doodadset(0), pos(), indx(0), id(0), d2(0), d3(0)
|
||||
{
|
||||
float ff[3];
|
||||
f.read(&id, 4);
|
||||
|
||||
@@ -53,7 +53,6 @@ public:
|
||||
float bbcorn2[3];
|
||||
|
||||
WMORoot(std::string& filename);
|
||||
~WMORoot();
|
||||
|
||||
bool open();
|
||||
bool ConvertToVMAPRootWmo(FILE* output);
|
||||
|
||||
Reference in New Issue
Block a user