Skip to content

Commit

Permalink
[sd2_mr0529] fix many compiler warnings and static code analyzer erro…
Browse files Browse the repository at this point in the history
…rs (also some real script errors) part 2, possible crushes sources. to be continued...
  • Loading branch information
rsa committed Nov 28, 2012
1 parent 5a5ba1b commit 51f0ce6
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 88 deletions.
4 changes: 2 additions & 2 deletions include/sc_creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, int32 uiSchool, int32 i
{
//No target so we can't cast
if (!pTarget)
return false;
return NULL;

//Silenced so we can't cast
if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
return false;
return NULL;

//Using the extended script system we first create a list of viable spells
SpellEntry const* apSpell[4];
Expand Down
10 changes: 5 additions & 5 deletions include/sc_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ void ScriptedInstance::DoStartTimedAchievement(AchievementCriteriaTypes criteria
@param pDialogueArray The static const array of DialogueEntry holding the information about the dialogue. This array MUST be terminated by {0,0,0}
*/
DialogueHelper::DialogueHelper(DialogueEntry const* pDialogueArray) :
m_pDialogueArray(pDialogueArray),
m_pDialogueTwoSideArray(NULL),
m_pInstance(NULL),
m_pDialogueArray(pDialogueArray),
m_pCurrentEntry(NULL),
m_pDialogueTwoSideArray(NULL),
m_pCurrentEntryTwoSide(NULL),
m_uiTimer(0),
m_bCanSimulate(false),
Expand All @@ -306,8 +306,8 @@ DialogueHelper::DialogueHelper(DialogueEntryTwoSide const* pDialogueTwoSideArray
m_pCurrentEntry(NULL),
m_pCurrentEntryTwoSide(NULL),
m_uiTimer(0),
m_bCanSimulate(false),
m_bIsFirstSide(true)
m_bIsFirstSide(true),
m_bCanSimulate(false)
{}

/**
Expand Down Expand Up @@ -358,7 +358,7 @@ void DialogueHelper::StartNextDialogueText(int32 iTextEntry)
void DialogueHelper::DoNextDialogueStep()
{
// Last Dialogue Entry done?
if (m_pCurrentEntry && !m_pCurrentEntry->iTextEntry || m_pCurrentEntryTwoSide && !m_pCurrentEntryTwoSide->iTextEntry)
if ((m_pCurrentEntry && !m_pCurrentEntry->iTextEntry) || (m_pCurrentEntryTwoSide && !m_pCurrentEntryTwoSide->iTextEntry))
{
m_uiTimer = 0;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void instance_temple_of_ahnqiraj::SetData(uint32 uiType, uint32 uiData)
std::ostringstream saveStream;
saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " " << m_auiEncounter[3] << " "
<< m_auiEncounter[4] << " " << m_auiEncounter[5] << " " << m_auiEncounter[6] << " " << m_auiEncounter[7] << " "
<< m_auiEncounter[8] << " " << m_auiEncounter[9];
<< m_auiEncounter[8];

m_strInstData = saveStream.str();

Expand All @@ -206,7 +206,7 @@ void instance_temple_of_ahnqiraj::Load(const char* chrIn)
std::istringstream loadStream(chrIn);
loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3]
>> m_auiEncounter[4] >> m_auiEncounter[5] >> m_auiEncounter[6] >> m_auiEncounter[7]
>> m_auiEncounter[8] >> m_auiEncounter[9];
>> m_auiEncounter[8];

for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/kalimdor/temple_of_ahnqiraj/temple_of_ahnqiraj.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

enum
{
MAX_ENCOUNTER = 9,

TYPE_SKERAM = 0,
TYPE_BUG_TRIO = 1,
Expand All @@ -18,6 +17,7 @@ enum
TYPE_TWINS = 6,
TYPE_OURO = 7,
TYPE_CTHUN = 8,
MAX_ENCOUNTER,

NPC_SKERAM = 15263,
//NPC_KRI = 15511,
Expand Down
4 changes: 4 additions & 0 deletions scripts/northrend/borean_tundra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,11 @@ const int32 textOnQuest[4] =
bool ProcessEventId_go_tadpole_cage(uint32 uiEventId, Object* pSource, Object* pTarget, bool bIsStart)
{
if (Player* pPlayer = (Player*) pSource)
{
if (GameObject* pGo = (GameObject*) pTarget)
{
if (Creature* pTadpole = GetClosestCreatureWithEntry(pGo,NPC_TADPOLE,0.5))
{
if (pPlayer->GetQuestStatus(QUEST_TADPOLES) == QUEST_STATUS_INCOMPLETE)
{
DoScriptText(textOnQuest[urand(0,3)],pTadpole,pPlayer);
Expand All @@ -862,7 +864,9 @@ bool ProcessEventId_go_tadpole_cage(uint32 uiEventId, Object* pSource, Object* p
}
else
DoScriptText(textNotOnQuest[urand(0,2)],pTadpole,pPlayer);
}
}
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct MANGOS_DLL_DECL boss_black_knightAI : public ScriptedAI

if (Choke_Timer < diff && phase1)
{
if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,1))
if (m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,1))
DoCast(m_creature->getVictim(), SPELL_CHOKE);
Choke_Timer = m_bIsRegularMode ? 15000 : 10000;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ struct MANGOS_DLL_DECL mob_toc5_hunterAI : public ScriptedAI
Multi_Shot_Timer = m_bIsRegularMode ? 15000 : 8000;
Disengage_Cooldown = 0;
enemy_check = 1000;
disengage_check;
disengage_check = 1000;
m_creature->GetMotionMaster()->MovePoint(0, 746, 614, m_creature->GetPositionZ());
m_creature->SetWalk(true);
}
Expand Down Expand Up @@ -767,7 +767,7 @@ struct MANGOS_DLL_DECL mob_toc5_rogueAI : public ScriptedAI

if (Poison_Timer < diff)
{
if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
if (m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
DoCast(m_creature, SPELL_POISON_BOTTLE);

Poison_Timer = m_bIsRegularMode ? 10000 : 5000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ struct MANGOS_DLL_DECL instance_trial_of_the_champion : public ScriptedInstance

pPlayer->CastSpell(pPlayer, ALLIANCE_CONTROL_PHASE_SHIFT_2, false);
break;
default:
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ struct MANGOS_DLL_DECL boss_faction_championsAI : public BSWScriptedAI
{
ThreatList const& tList = m_creature->getThreatManager().getThreatList();
ThreatList::const_iterator itr;
bool empty = true;
for (itr = tList.begin(); itr!=tList.end(); ++itr)
{
Unit* pUnit = m_creature->GetMap()->GetUnit((*itr)->getUnitGuid());
Expand All @@ -335,7 +334,6 @@ struct MANGOS_DLL_DECL boss_faction_championsAI : public BSWScriptedAI
float threat = CalculateThreat(m_creature->GetDistance2d(pUnit), (float)pUnit->GetArmor(), pUnit->GetHealth());
m_creature->getThreatManager().modifyThreatPercent(pUnit, -100);
m_creature->AddThreat(pUnit, 1000000.0f * threat);
empty = false;
}
}
}
Expand Down Expand Up @@ -364,10 +362,9 @@ struct MANGOS_DLL_DECL boss_faction_championsAI : public BSWScriptedAI
ThreatList::const_iterator iter;
for (iter = tList.begin(); iter!=tList.end(); ++iter)
{
Unit *target;
if (target = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid()))
if (target->getPowerType() == POWER_MANA)
return target;
Unit* target = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid());
if (target && target->getPowerType() == POWER_MANA)
return target;
}
return NULL;
}
Expand All @@ -378,10 +375,9 @@ struct MANGOS_DLL_DECL boss_faction_championsAI : public BSWScriptedAI
ThreatList::const_iterator iter;
for (iter = tList.begin(); iter!=tList.end(); ++iter)
{
Unit *target;
if (target = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid()))
if (target->GetHealthPercent() < 30.0f)
return target;
Unit* target = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid());
if (target && target->GetHealthPercent() < 30.0f)
return target;
}
return NULL;
}
Expand Down Expand Up @@ -1078,7 +1074,7 @@ struct MANGOS_DLL_DECL mob_toc_shadow_priestAI : public boss_faction_championsAI

if (m_uiHorrorTimer < uiDiff)
{
if (Unit *target = SelectTargetWithinDist())
if (Unit* target = SelectTargetWithinDist())
{
DoCastSpellIfCan(target, SPELL_HORROR);
m_uiHorrorTimer = 2*MINUTE*IN_MILLISECONDS;
Expand All @@ -1089,7 +1085,7 @@ struct MANGOS_DLL_DECL mob_toc_shadow_priestAI : public boss_faction_championsAI

if (m_uiFearTimer < uiDiff)
{
if (Unit *target = SelectTargetWithinDist())
if (SelectTargetWithinDist())
{
DoCastSpellIfCan(m_creature, SPELL_PSYCHIC_SCREAM);
m_uiFearTimer = urand(20*IN_MILLISECONDS, 35*IN_MILLISECONDS);
Expand Down Expand Up @@ -1730,10 +1726,9 @@ struct MANGOS_DLL_DECL mob_toc_warriorAI : public boss_faction_championsAI
ThreatList::const_iterator iter;
for (iter = tList.begin(); iter!=tList.end(); ++iter)
{
Unit *target;
if (target = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid()))
if (target->HasAura(SPELL_DIVINE_SHIELD))
return target;
Unit* target = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid());
if (target && target->HasAura(SPELL_DIVINE_SHIELD))
return target;
}
return NULL;
}
Expand All @@ -1745,10 +1740,9 @@ struct MANGOS_DLL_DECL mob_toc_warriorAI : public boss_faction_championsAI
ThreatList::const_iterator iter;
for (iter = tList.begin(); iter!=tList.end(); ++iter)
{
Unit *target;
if (target = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid()))
if (target->HasAura(SPELL_ICE_BLOCK))
return target;
Unit* target = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid());
if (target && target->HasAura(SPELL_ICE_BLOCK))
return target;
}
return NULL;
}
Expand Down Expand Up @@ -2115,9 +2109,9 @@ struct MANGOS_DLL_DECL mob_toc_rogueAI : public boss_faction_championsAI

if (m_uiBlindTimer <= uiDiff)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1))
if (m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1))
{
if(Unit *target = SelectTargetWithinDist())
if (Unit *target = SelectTargetWithinDist())
{
DoCastSpellIfCan(target, SPELL_BLIND);
m_uiBlindTimer = 2*MINUTE*IN_MILLISECONDS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ bool instance_trial_of_the_crusader::IsEncounterInProgress() const
if (m_auiEncounter[i] == IN_PROGRESS)
return true;

if (m_auiEncounter[TYPE_NORTHREND_BEASTS] == SNAKES_SPECIAL)
return true;

return false;
}

Expand Down Expand Up @@ -203,22 +200,25 @@ void instance_trial_of_the_crusader::SetData(uint32 uiType, uint32 uiData)
m_auiEncounter[TYPE_CRUSADERS] = uiData;
if (uiData == DONE)
{
if (Creature* pTirion = GetSingleCreatureFromStorage(NPC_TIRION))
if (GetSingleCreatureFromStorage(NPC_TIRION))
DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_ACHIEV_FACTION_CHAMPIONS_DEFEAT);

uint32 uiCacheEntry = GO_CRUSADERS_CACHE_10;

switch (instance->GetDifficulty())
{
case RAID_DIFFICULTY_10MAN_HEROIC:
uiCacheEntry = GO_CRUSADERS_CACHE_10_H;
break;
case RAID_DIFFICULTY_25MAN_NORMAL:
uiCacheEntry = GO_CRUSADERS_CACHE_25;
break;
case RAID_DIFFICULTY_25MAN_HEROIC:
uiCacheEntry = GO_CRUSADERS_CACHE_25_H;
break;
case RAID_DIFFICULTY_10MAN_HEROIC:
uiCacheEntry = GO_CRUSADERS_CACHE_10_H;
break;
case RAID_DIFFICULTY_25MAN_NORMAL:
uiCacheEntry = GO_CRUSADERS_CACHE_25;
break;
case RAID_DIFFICULTY_25MAN_HEROIC:
uiCacheEntry = GO_CRUSADERS_CACHE_25_H;
break;
default:
uiCacheEntry = GO_CRUSADERS_CACHE_10;
break;
}
if (GameObject* pChest = GetSingleGameObjectFromStorage(uiCacheEntry))
if (!pChest->isSpawned())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ bool GossipHello_npc_toc_announcer(Player* pPlayer, Creature* pCreature)
if (pPlayer->IsInCombat() || m_pInstance->IsEncounterInProgress() || m_pInstance->GetData(TYPE_EVENT))
return true;

switch (LocaleConstant currentlocale = pPlayer->GetSession()->GetSessionDbcLocale())
switch (pPlayer->GetSession()->GetSessionDbcLocale())
{
case LOCALE_esES:
_message = "¡Estamos listos!";
Expand Down Expand Up @@ -562,17 +562,17 @@ struct MANGOS_DLL_DECL boss_lich_king_tocAI : public ScriptedAI

void MovementInform(uint32 type, uint32 id)
{
if(m_pInstance)
if (m_pInstance)
{
if(id == 2)
if (id == 2)
{
Event = true;
}
}
if(type != POINT_MOTION_TYPE)
if (type != POINT_MOTION_TYPE)
return;

if(WayPoint->id != id)
if (WayPoint->id != id)
return;

++WayPoint;
Expand Down
12 changes: 7 additions & 5 deletions scripts/northrend/gundrak/boss_moorabi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ struct MANGOS_DLL_DECL boss_moorabiAI : public ScriptedAI
if (m_pInstance)
m_pInstance->SetData(TYPE_MOORABI, DONE);

if (!m_bIsRegularMode)
if (m_bMammothPhase)
return;
else
m_pInstance->DoCompleteAchievement(2040);
if (!m_bIsRegularMode)
{
if (m_bMammothPhase)
return;
else
m_pInstance->DoCompleteAchievement(2040);
}
}

void UpdateAI(const uint32 uiDiff)
Expand Down
2 changes: 1 addition & 1 deletion scripts/northrend/howling_fjord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ bool GossipSelect_npc_jack_adams(Player* pPlayer, Creature* pCreature, uint32 ui
{
pPlayer->CLOSE_GOSSIP_MENU();
ItemPosCountVec dest;
uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, ITEM_JACK_ADAMS_DEBT, 1, false);
uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, ITEM_JACK_ADAMS_DEBT, 1);
if (msg == EQUIP_ERR_OK)
pPlayer->StoreNewItem(dest, ITEM_JACK_ADAMS_DEBT, 1, true);
pCreature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,19 @@ uint32 uiSummon_counter;

void Reset()
{
if (m_pInstance)
if (m_pInstance->GetData(TYPE_DEVOURER_OF_SOULS) != DONE)
{
m_pInstance->SetData(TYPE_DEVOURER_OF_SOULS, NOT_STARTED);
Step = 0;
m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
} else Step = 10;
if (m_pInstance)
{
if (m_pInstance->GetData(TYPE_DEVOURER_OF_SOULS) != DONE)
{
m_pInstance->SetData(TYPE_DEVOURER_OF_SOULS, NOT_STARTED);
Step = 0;
m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
}
else Step = 10;
StepTimer = 100;
m_creature->SetVisibility(VISIBILITY_OFF);
}
}

void UpdateAI(const uint32 diff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct MANGOS_DLL_DECL boss_lich_king_hrAI : public npc_escortAI

m_pInstance->DoOpenDoor(GO_ICECROWN_DOOR_2);

Team team;
Team team = TEAM_NONE;
if (Group* pGroup = pPlayer->GetGroup())
{
ObjectGuid LeaderGuid = pGroup->GetLeaderGuid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ static _Locations SpawnLoc[]=
{5298.198f, 2037.762f, 707.694f, 4.71f} //0
};


static _Locations WallLoc[]=
{
{5540.39f, 2086.48f, 731.066f, 1.00057f},
Expand All @@ -130,6 +131,7 @@ static _Locations WallLoc[]=
{5547.27002f, 2256.949951f, 733.010986f, 0.9f}, // Spawn point for Jaina && Silvana outro
};


enum HallsOfReflectionWorldStates
{
WORLD_STATE_HOR = 4884,
Expand Down
Loading

0 comments on commit 51f0ce6

Please sign in to comment.