Some clean ups due thanks to clang's warnings

This commit is contained in:
Michael Cook (mackal) 2014-12-09 23:41:19 -05:00
parent 362bfc79d6
commit 4c9befee22
6 changed files with 94 additions and 118 deletions

View File

@ -291,7 +291,7 @@ Timer DecayTimer(20);
//bullshit checking, to see if this is really happening, GDB seems to think so... //bullshit checking, to see if this is really happening, GDB seems to think so...
if(stream_itr->second == nullptr) { if(stream_itr->second == nullptr) {
fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %i", stream_itr->first.first, stream_itr->first.second); fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %i:%i", stream_itr->first.first, stream_itr->first.second);
continue; continue;
} }

View File

@ -896,7 +896,7 @@ bool IsHealOverTimeSpell(uint16 spell_id)
bool IsCompleteHealSpell(uint16 spell_id) bool IsCompleteHealSpell(uint16 spell_id)
{ {
if (spell_id == 13 || IsEffectInSpell(spell_id, SE_CompleteHeal) || if (spell_id == 13 || IsEffectInSpell(spell_id, SE_CompleteHeal) ||
IsPercentalHealSpell(spell_id) && !IsGroupSpell(spell_id)) (IsPercentalHealSpell(spell_id) && !IsGroupSpell(spell_id)))
return true; return true;
return false; return false;

View File

@ -547,7 +547,7 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
if(totalusers<=20 || admin>=100) if(totalusers<=20 || admin>=100)
totallength=totallength+strlen(countcle->name())+strlen(countcle->AccountName())+strlen(guild_mgr.GetGuildName(countcle->GuildID()))+5; totallength=totallength+strlen(countcle->name())+strlen(countcle->AccountName())+strlen(guild_mgr.GetGuildName(countcle->GuildID()))+5;
} }
else if((countcle->Anon()>0 && admin<=countcle->Admin()) || countcle->Anon()==0 && !countcle->GetGM()){ else if((countcle->Anon()>0 && admin<=countcle->Admin()) || (countcle->Anon()==0 && !countcle->GetGM())) {
totalusers++; totalusers++;
if(totalusers<=20 || admin>=100) if(totalusers<=20 || admin>=100)
totallength=totallength+strlen(countcle->name())+strlen(guild_mgr.GetGuildName(countcle->GuildID()))+5; totallength=totallength+strlen(countcle->name())+strlen(guild_mgr.GetGuildName(countcle->GuildID()))+5;

View File

@ -893,7 +893,7 @@ void Mob::WakeTheDead(uint16 spell_id, Mob *target, uint32 duration)
//turn on an AA effect //turn on an AA effect
//duration == 0 means no time limit, used for one-shot deals, etc.. //duration == 0 means no time limit, used for one-shot deals, etc..
void Client::EnableAAEffect(aaEffectType type, uint32 duration) { void Client::EnableAAEffect(aaEffectType type, uint32 duration) {
if(type > 32) if(type > _maxaaEffectType)
return; //for now, special logic needed. return; //for now, special logic needed.
m_epp.aa_effects |= 1 << (type-1); m_epp.aa_effects |= 1 << (type-1);
@ -905,7 +905,7 @@ void Client::EnableAAEffect(aaEffectType type, uint32 duration) {
} }
void Client::DisableAAEffect(aaEffectType type) { void Client::DisableAAEffect(aaEffectType type) {
if(type > 32) if(type > _maxaaEffectType)
return; //for now, special logic needed. return; //for now, special logic needed.
uint32 bit = 1 << (type-1); uint32 bit = 1 << (type-1);
if(m_epp.aa_effects & bit) { if(m_epp.aa_effects & bit) {
@ -919,7 +919,7 @@ By default an AA effect is a one shot deal, unless
a duration timer is set. a duration timer is set.
*/ */
bool Client::CheckAAEffect(aaEffectType type) { bool Client::CheckAAEffect(aaEffectType type) {
if(type > 32) if(type > _maxaaEffectType)
return(false); //for now, special logic needed. return(false); //for now, special logic needed.
if(m_epp.aa_effects & (1 << (type-1))) { //is effect enabled? if(m_epp.aa_effects & (1 << (type-1))) { //is effect enabled?
//has our timer expired? //has our timer expired?

View File

@ -51,7 +51,8 @@ typedef enum { //AA Effect IDs
aaEffectFrostArrows, aaEffectFrostArrows,
aaEffectWarcry, aaEffectWarcry,
aaEffectLeechTouch, aaEffectLeechTouch,
aaEffectProjectIllusion // unused - Handled via spell effect aaEffectProjectIllusion, // unused - Handled via spell effect
_maxaaEffectType = 32
} aaEffectType; } aaEffectType;

View File

@ -293,7 +293,6 @@ bool Mob::CheckHitChance(Mob* other, SkillUseTypes skillinuse, int Hand, int16 c
attacker->spellbonuses.HitChanceEffect[HIGHEST_SKILL+1] + attacker->spellbonuses.HitChanceEffect[HIGHEST_SKILL+1] +
attacker->aabonuses.HitChanceEffect[HIGHEST_SKILL+1]; attacker->aabonuses.HitChanceEffect[HIGHEST_SKILL+1];
//Accuracy = Spell Effect , HitChance = 'Accuracy' from Item Effect //Accuracy = Spell Effect , HitChance = 'Accuracy' from Item Effect
//Only AA derived accuracy can be skill limited. ie (Precision of the Pathfinder, Dead Aim) //Only AA derived accuracy can be skill limited. ie (Precision of the Pathfinder, Dead Aim)
hitBonus += (attacker->itembonuses.Accuracy[HIGHEST_SKILL+1] + hitBonus += (attacker->itembonuses.Accuracy[HIGHEST_SKILL+1] +
@ -330,7 +329,6 @@ bool Mob::CheckHitChance(Mob* other, SkillUseTypes skillinuse, int Hand, int16 c
//I dont know the best way to handle a garunteed hit discipline being used //I dont know the best way to handle a garunteed hit discipline being used
//agains a garunteed riposte (for example) discipline... for now, garunteed hit wins //agains a garunteed riposte (for example) discipline... for now, garunteed hit wins
#if EQDEBUG>=11 #if EQDEBUG>=11
LogFile->write(EQEMuLog::Debug, "3 FINAL calculated chance to hit is: %5.2f", chancetohit); LogFile->write(EQEMuLog::Debug, "3 FINAL calculated chance to hit is: %5.2f", chancetohit);
#endif #endif
@ -346,7 +344,6 @@ bool Mob::CheckHitChance(Mob* other, SkillUseTypes skillinuse, int Hand, int16 c
return(tohit_roll <= chancetohit); return(tohit_roll <= chancetohit);
} }
bool Mob::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) bool Mob::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte)
{ {
/* solar: called when a mob is attacked, does the checks to see if it's a hit /* solar: called when a mob is attacked, does the checks to see if it's a hit
@ -1164,7 +1161,6 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b
if (GetFeigned()) if (GetFeigned())
return false; // Rogean: How can you attack while feigned? Moved up from Aggro Code. return false; // Rogean: How can you attack while feigned? Moved up from Aggro Code.
ItemInst* weapon; ItemInst* weapon;
if (Hand == MainSecondary){ // Kaiyodo - Pick weapon from the attacking hand if (Hand == MainSecondary){ // Kaiyodo - Pick weapon from the attacking hand
weapon = GetInv().GetItem(MainSecondary); weapon = GetInv().GetItem(MainSecondary);
@ -1225,7 +1221,6 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b
CheckIncreaseSkill(skillinuse, other, -15); CheckIncreaseSkill(skillinuse, other, -15);
CheckIncreaseSkill(SkillOffense, other, -15); CheckIncreaseSkill(SkillOffense, other, -15);
// *************************************************************** // ***************************************************************
// *** Calculate the damage bonus, if applicable, for this hit *** // *** Calculate the damage bonus, if applicable, for this hit ***
// *************************************************************** // ***************************************************************
@ -1522,7 +1517,6 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att
hate_list.RemoveEnt(this); hate_list.RemoveEnt(this);
RemoveAutoXTargets(); RemoveAutoXTargets();
//remove ourself from all proximities //remove ourself from all proximities
ClearAllProximities(); ClearAllProximities();
@ -1598,7 +1592,7 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att
else else
UnmemSpellAll(false); UnmemSpellAll(false);
if(RuleB(Character, LeaveCorpses) && GetLevel() >= RuleI(Character, DeathItemLossLevel) || RuleB(Character, LeaveNakedCorpses)) if((RuleB(Character, LeaveCorpses) && GetLevel() >= RuleI(Character, DeathItemLossLevel)) || RuleB(Character, LeaveNakedCorpses))
{ {
// creating the corpse takes the cash/items off the player too // creating the corpse takes the cash/items off the player too
Corpse *new_corpse = new Corpse(this, exploss); Corpse *new_corpse = new Corpse(this, exploss);
@ -1836,7 +1830,6 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool
else else
damage = zone->random.Int((min_dmg+eleBane),(max_dmg+eleBane)); damage = zone->random.Int((min_dmg+eleBane),(max_dmg+eleBane));
//check if we're hitting above our max or below it. //check if we're hitting above our max or below it.
if((min_dmg+eleBane) != 0 && damage < (min_dmg+eleBane)) { if((min_dmg+eleBane) != 0 && damage < (min_dmg+eleBane)) {
mlog(COMBAT__DAMAGE, "Damage (%d) is below min (%d). Setting to min.", damage, (min_dmg+eleBane)); mlog(COMBAT__DAMAGE, "Damage (%d) is below min (%d). Setting to min.", damage, (min_dmg+eleBane));
@ -2497,7 +2490,6 @@ void Mob::AddToHateList(Mob* other, int32 hate, int32 damage, bool iYellForHelp,
} }
#endif //BOTS #endif //BOTS
// if other is a merc, add the merc client to the hate list // if other is a merc, add the merc client to the hate list
if(other->IsMerc()) { if(other->IsMerc()) {
if(other->CastToMerc()->GetMercOwner() && other->CastToMerc()->GetMercOwner()->CastToClient()->GetFeigned()) { if(other->CastToMerc()->GetMercOwner() && other->CastToMerc()->GetMercOwner()->CastToClient()->GetFeigned()) {
@ -2636,7 +2628,6 @@ uint8 Mob::GetWeaponDamageBonus( const Item_Struct *Weapon )
// This function calculates and returns the damage bonus for the weapon identified by the parameter "Weapon". // This function calculates and returns the damage bonus for the weapon identified by the parameter "Weapon".
// Modified 9/21/2008 by Cantus // Modified 9/21/2008 by Cantus
// Assert: This function should only be called for hits by the mainhand, as damage bonuses apply only to the // Assert: This function should only be called for hits by the mainhand, as damage bonuses apply only to the
// weapon in the primary slot. Be sure to check that Hand == MainPrimary before calling. // weapon in the primary slot. Be sure to check that Hand == MainPrimary before calling.
@ -2648,7 +2639,6 @@ uint8 Mob::GetWeaponDamageBonus( const Item_Struct *Weapon )
// Assert: This function should not be called unless the player is a melee class, as casters do not receive a damage bonus. // Assert: This function should not be called unless the player is a melee class, as casters do not receive a damage bonus.
if( Weapon == nullptr || Weapon->ItemType == ItemType1HSlash || Weapon->ItemType == ItemType1HBlunt || Weapon->ItemType == ItemTypeMartial || Weapon->ItemType == ItemType1HPiercing ) if( Weapon == nullptr || Weapon->ItemType == ItemType1HSlash || Weapon->ItemType == ItemType1HBlunt || Weapon->ItemType == ItemTypeMartial || Weapon->ItemType == ItemType1HPiercing )
{ {
// The weapon in the player's main (primary) hand is a one-handed weapon, or there is no item equipped at all. // The weapon in the player's main (primary) hand is a one-handed weapon, or there is no item equipped at all.
@ -2676,7 +2666,6 @@ uint8 Mob::GetWeaponDamageBonus( const Item_Struct *Weapon )
// as I suspect, then please feel free to delete the following line, and replace all occurences of "ucPlayerLevel" with "GetLevel()". // as I suspect, then please feel free to delete the following line, and replace all occurences of "ucPlayerLevel" with "GetLevel()".
uint8 ucPlayerLevel = (uint8) GetLevel(); uint8 ucPlayerLevel = (uint8) GetLevel();
// The following may look cleaner, and would certainly be easier to understand, if it was // The following may look cleaner, and would certainly be easier to understand, if it was
// a simple 53x150 cell matrix. // a simple 53x150 cell matrix.
// //
@ -2694,7 +2683,6 @@ uint8 Mob::GetWeaponDamageBonus( const Item_Struct *Weapon )
// lookup table. In cases where a formula is the best bet, I use a formula. In other places // lookup table. In cases where a formula is the best bet, I use a formula. In other places
// where a formula would be ugly, I use a lookup table in the interests of speed. // where a formula would be ugly, I use a lookup table in the interests of speed.
if( Weapon->Delay <= 27 ) if( Weapon->Delay <= 27 )
{ {
// Damage Bonuses for all 2H weapons with delays of 27 or less are identical. // Damage Bonuses for all 2H weapons with delays of 27 or less are identical.
@ -2706,7 +2694,6 @@ uint8 Mob::GetWeaponDamageBonus( const Item_Struct *Weapon )
return (ucPlayerLevel - 22) / 3; return (ucPlayerLevel - 22) / 3;
} }
if( ucPlayerLevel == 65 && Weapon->Delay <= 59 ) if( ucPlayerLevel == 65 && Weapon->Delay <= 59 )
{ {
// Consider these two facts: // Consider these two facts:
@ -2725,7 +2712,6 @@ uint8 Mob::GetWeaponDamageBonus( const Item_Struct *Weapon )
return ucLevel65DamageBonusesForDelays28to59[Weapon->Delay-28]; return ucLevel65DamageBonusesForDelays28to59[Weapon->Delay-28];
} }
if( ucPlayerLevel > 65 ) if( ucPlayerLevel > 65 )
{ {
if( ucPlayerLevel > 80 ) if( ucPlayerLevel > 80 )
@ -2864,7 +2850,6 @@ uint8 Mob::GetWeaponDamageBonus( const Item_Struct *Weapon )
} }
} }
// If we've gotten to this point in the function without hitting a return statement, // If we've gotten to this point in the function without hitting a return statement,
// we know that the character's level is between 28 and 65, and that the 2H weapon's // we know that the character's level is between 28 and 65, and that the 2H weapon's
// delay is 28 or higher. // delay is 28 or higher.
@ -3110,7 +3095,6 @@ int Mob::GetMonkHandToHandDelay(void)
} }
} }
int32 Mob::ReduceDamage(int32 damage) int32 Mob::ReduceDamage(int32 damage)
{ {
if(damage <= 0) if(damage <= 0)
@ -3161,7 +3145,6 @@ int32 Mob::ReduceDamage(int32 damage)
} }
} }
if (spellbonuses.MitigateMeleeRune[0] && !DisableMeleeRune){ if (spellbonuses.MitigateMeleeRune[0] && !DisableMeleeRune){
slot = spellbonuses.MitigateMeleeRune[1]; slot = spellbonuses.MitigateMeleeRune[1];
if(slot >= 0) if(slot >= 0)
@ -3265,7 +3248,6 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi
// Reduce damage by the Spell Shielding first so that the runes don't take the raw damage. // Reduce damage by the Spell Shielding first so that the runes don't take the raw damage.
damage -= (damage * itembonuses.SpellShield / 100); damage -= (damage * itembonuses.SpellShield / 100);
//Only mitigate if damage is above the minimium specified. //Only mitigate if damage is above the minimium specified.
if (spellbonuses.SpellThresholdGuard[0]){ if (spellbonuses.SpellThresholdGuard[0]){
slot = spellbonuses.SpellThresholdGuard[1]; slot = spellbonuses.SpellThresholdGuard[1];
@ -3288,7 +3270,6 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi
} }
} }
// Do runes now. // Do runes now.
if (spellbonuses.MitigateSpellRune[0] && !DisableSpellRune){ if (spellbonuses.MitigateSpellRune[0] && !DisableSpellRune){
slot = spellbonuses.MitigateSpellRune[1]; slot = spellbonuses.MitigateSpellRune[1];
@ -3721,18 +3702,15 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons
//if the attacker is a client, try them with the correct filter //if the attacker is a client, try them with the correct filter
if(attacker && attacker->IsClient()) { if(attacker && attacker->IsClient()) {
if (((spell_id != SPELL_UNKNOWN)||(FromDamageShield)) && damage>0) { if ((spell_id != SPELL_UNKNOWN || FromDamageShield) && damage > 0) {
//special crap for spell damage, looks hackish to me //special crap for spell damage, looks hackish to me
char val1[20] = {0}; char val1[20] = {0};
if (FromDamageShield) if (FromDamageShield) {
{ if (attacker->CastToClient()->GetFilter(FilterDamageShields) != FilterHide)
if(!attacker->CastToClient()->GetFilter(FilterDamageShields) == FilterHide)
{
attacker->Message_StringID(MT_DS,OTHER_HIT_NONMELEE, GetCleanName(), ConvertArray(damage, val1)); attacker->Message_StringID(MT_DS,OTHER_HIT_NONMELEE, GetCleanName(), ConvertArray(damage, val1));
} } else {
}
else
entity_list.MessageClose_StringID(this, true, 100, MT_NonMelee, HIT_NON_MELEE, attacker->GetCleanName(), GetCleanName(), ConvertArray(damage, val1)); entity_list.MessageClose_StringID(this, true, 100, MT_NonMelee, HIT_NON_MELEE, attacker->GetCleanName(), GetCleanName(), ConvertArray(damage, val1));
}
} else { } else {
if(damage > 0) { if(damage > 0) {
if(spell_id != SPELL_UNKNOWN) if(spell_id != SPELL_UNKNOWN)
@ -3790,7 +3768,6 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons
} }
void Mob::HealDamage(uint32 amount, Mob *caster, uint16 spell_id) void Mob::HealDamage(uint32 amount, Mob *caster, uint16 spell_id)
{ {
int32 maxhp = GetMaxHP(); int32 maxhp = GetMaxHP();
@ -4190,7 +4167,7 @@ void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttack
// decided to branch this into it's own function since it's going to be duplicating a lot of the // decided to branch this into it's own function since it's going to be duplicating a lot of the
// code in here, but could lead to some confusion otherwise // code in here, but could lead to some confusion otherwise
if (IsPet() && GetOwner()->IsClient() || (IsNPC() && CastToNPC()->GetSwarmOwner())) { if ((IsPet() && GetOwner()->IsClient()) || (IsNPC() && CastToNPC()->GetSwarmOwner())) {
TryPetCriticalHit(defender,skill,damage); TryPetCriticalHit(defender,skill,damage);
return; return;
} }
@ -4335,7 +4312,6 @@ void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttack
} }
} }
bool Mob::TryFinishingBlow(Mob *defender, SkillUseTypes skillinuse) bool Mob::TryFinishingBlow(Mob *defender, SkillUseTypes skillinuse)
{ {
if (defender && !defender->IsClient() && defender->GetHPRatio() < 10){ if (defender && !defender->IsClient() && defender->GetHPRatio() < 10){
@ -4503,8 +4479,8 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
for(int e = 0; e < MAX_SKILL_PROCS; e++){ for(int e = 0; e < MAX_SKILL_PROCS; e++){
if (CanProc && if (CanProc &&
(!Success && spellbonuses.SkillProc[e] && IsValidSpell(spellbonuses.SkillProc[e])) ((!Success && spellbonuses.SkillProc[e] && IsValidSpell(spellbonuses.SkillProc[e]))
|| (Success && spellbonuses.SkillProcSuccess[e] && IsValidSpell(spellbonuses.SkillProcSuccess[e]))) { || (Success && spellbonuses.SkillProcSuccess[e] && IsValidSpell(spellbonuses.SkillProcSuccess[e])))) {
if (Success) if (Success)
base_spell_id = spellbonuses.SkillProcSuccess[e]; base_spell_id = spellbonuses.SkillProcSuccess[e];
@ -4547,8 +4523,8 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
CanProc = true; CanProc = true;
for(int e = 0; e < MAX_SKILL_PROCS; e++){ for(int e = 0; e < MAX_SKILL_PROCS; e++){
if (CanProc && if (CanProc &&
(!Success && itembonuses.SkillProc[e] && IsValidSpell(itembonuses.SkillProc[e])) ((!Success && itembonuses.SkillProc[e] && IsValidSpell(itembonuses.SkillProc[e]))
|| (Success && itembonuses.SkillProcSuccess[e] && IsValidSpell(itembonuses.SkillProcSuccess[e]))) { || (Success && itembonuses.SkillProcSuccess[e] && IsValidSpell(itembonuses.SkillProcSuccess[e])))) {
if (Success) if (Success)
base_spell_id = itembonuses.SkillProcSuccess[e]; base_spell_id = itembonuses.SkillProcSuccess[e];
@ -4594,8 +4570,8 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
for(int e = 0; e < MAX_SKILL_PROCS; e++){ for(int e = 0; e < MAX_SKILL_PROCS; e++){
if (CanProc && if (CanProc &&
(!Success && aabonuses.SkillProc[e]) ((!Success && aabonuses.SkillProc[e])
|| (Success && aabonuses.SkillProcSuccess[e])){ || (Success && aabonuses.SkillProcSuccess[e]))) {
int aaid = 0; int aaid = 0;
if (Success) if (Success)
@ -4739,7 +4715,6 @@ int32 Mob::RuneAbsorb(int32 damage, uint16 type)
} }
} }
else{ else{
for(uint32 slot = 0; slot < buff_max; slot++) { for(uint32 slot = 0; slot < buff_max; slot++) {
if(slot == spellbonuses.AbsorbMagicAtt[1] && spellbonuses.AbsorbMagicAtt[0] && buffs[slot].magic_rune && IsValidSpell(buffs[slot].spellid)){ if(slot == spellbonuses.AbsorbMagicAtt[1] && spellbonuses.AbsorbMagicAtt[0] && buffs[slot].magic_rune && IsValidSpell(buffs[slot].spellid)){