[Performance] Reworked how all log calls are made in the source, see changelog.txt for more details

This commit is contained in:
Akkadius
2017-04-01 03:51:46 -05:00
parent 93a6efa95f
commit 7aa1d243b0
131 changed files with 3126 additions and 3066 deletions
+31 -29
View File
@@ -489,7 +489,7 @@ int Mob::MonkSpecialAttack(Mob *other, uint8 unchecked_type)
reuse = KickReuseTime;
break;
default:
Log.Out(Logs::Detail, Logs::Attack, "Invalid special attack type %d attempted", unchecked_type);
Log(Logs::Detail, Logs::Attack, "Invalid special attack type %d attempted", unchecked_type);
return (1000); /* nice long delay for them, the caller depends on this! */
}
@@ -627,7 +627,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
//make sure the attack and ranged timers are up
//if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow
if(!CanDoubleAttack && ((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check()))) {
Log.Out(Logs::Detail, Logs::Combat, "Throwing attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime());
Log(Logs::Detail, Logs::Combat, "Throwing attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime());
// The server and client timers are not exact matches currently, so this would spam too often if enabled
//Message(0, "Error: Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime());
return;
@@ -639,12 +639,12 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
const EQEmu::ItemInstance* Ammo = m_inv[EQEmu::inventory::slotAmmo];
if (!RangeWeapon || !RangeWeapon->IsClassCommon()) {
Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotRange), EQEmu::inventory::slotRange);
Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotRange), EQEmu::inventory::slotRange);
Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have no bow!", GetItemIDAt(EQEmu::inventory::slotRange));
return;
}
if (!Ammo || !Ammo->IsClassCommon()) {
Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ammo item (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotAmmo), EQEmu::inventory::slotAmmo);
Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ammo item (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotAmmo), EQEmu::inventory::slotAmmo);
Message(0, "Error: Ammo: GetItem(%i)==0, you have no ammo!", GetItemIDAt(EQEmu::inventory::slotAmmo));
return;
}
@@ -653,17 +653,17 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
const EQEmu::ItemData* AmmoItem = Ammo->GetItem();
if (RangeItem->ItemType != EQEmu::item::ItemTypeBow) {
Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ranged item is not a bow. type %d.", RangeItem->ItemType);
Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ranged item is not a bow. type %d.", RangeItem->ItemType);
Message(0, "Error: Rangeweapon: Item %d is not a bow.", RangeWeapon->GetID());
return;
}
if (AmmoItem->ItemType != EQEmu::item::ItemTypeArrow) {
Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ammo item is not an arrow. type %d.", AmmoItem->ItemType);
Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ammo item is not an arrow. type %d.", AmmoItem->ItemType);
Message(0, "Error: Ammo: type %d != %d, you have the wrong type of ammo!", AmmoItem->ItemType, EQEmu::item::ItemTypeArrow);
return;
}
Log.Out(Logs::Detail, Logs::Combat, "Shooting %s with bow %s (%d) and arrow %s (%d)", other->GetName(), RangeItem->Name, RangeItem->ID, AmmoItem->Name, AmmoItem->ID);
Log(Logs::Detail, Logs::Combat, "Shooting %s with bow %s (%d) and arrow %s (%d)", other->GetName(), RangeItem->Name, RangeItem->ID, AmmoItem->Name, AmmoItem->ID);
//look for ammo in inventory if we only have 1 left...
if(Ammo->GetCharges() == 1) {
@@ -690,7 +690,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
Ammo = baginst;
ammo_slot = m_inv.CalcSlotId(r, i);
found = true;
Log.Out(Logs::Detail, Logs::Combat, "Using ammo from quiver stack at slot %d. %d in stack.", ammo_slot, Ammo->GetCharges());
Log(Logs::Detail, Logs::Combat, "Using ammo from quiver stack at slot %d. %d in stack.", ammo_slot, Ammo->GetCharges());
break;
}
}
@@ -705,17 +705,17 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
if (aslot != INVALID_INDEX) {
ammo_slot = aslot;
Ammo = m_inv[aslot];
Log.Out(Logs::Detail, Logs::Combat, "Using ammo from inventory stack at slot %d. %d in stack.", ammo_slot, Ammo->GetCharges());
Log(Logs::Detail, Logs::Combat, "Using ammo from inventory stack at slot %d. %d in stack.", ammo_slot, Ammo->GetCharges());
}
}
}
float range = RangeItem->Range + AmmoItem->Range + GetRangeDistTargetSizeMod(GetTarget());
Log.Out(Logs::Detail, Logs::Combat, "Calculated bow range to be %.1f", range);
Log(Logs::Detail, Logs::Combat, "Calculated bow range to be %.1f", range);
range *= range;
float dist = DistanceSquared(m_Position, other->GetPosition());
if(dist > range) {
Log.Out(Logs::Detail, Logs::Combat, "Ranged attack out of range... client should catch this. (%f > %f).\n", dist, range);
Log(Logs::Detail, Logs::Combat, "Ranged attack out of range... client should catch this. (%f > %f).\n", dist, range);
Message_StringID(13,TARGET_OUT_OF_RANGE);//Client enforces range and sends the message, this is a backup just incase.
return;
}
@@ -743,9 +743,9 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
if (RangeItem->ExpendableArrow || !ChanceAvoidConsume || (ChanceAvoidConsume < 100 && zone->random.Int(0,99) > ChanceAvoidConsume)){
DeleteItemInInventory(ammo_slot, 1, true);
Log.Out(Logs::Detail, Logs::Combat, "Consumed one arrow from slot %d", ammo_slot);
Log(Logs::Detail, Logs::Combat, "Consumed one arrow from slot %d", ammo_slot);
} else {
Log.Out(Logs::Detail, Logs::Combat, "Endless Quiver prevented ammo consumption.");
Log(Logs::Detail, Logs::Combat, "Endless Quiver prevented ammo consumption.");
}
CheckIncreaseSkill(EQEmu::skills::SkillArchery, GetTarget(), -15);
@@ -805,7 +805,7 @@ void Mob::DoArcheryAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon,
SendItemAnimation(other, AmmoItem, EQEmu::skills::SkillArchery);
}
Log.Out(Logs::Detail, Logs::Combat, "Ranged attack hit %s.", other->GetName());
Log(Logs::Detail, Logs::Combat, "Ranged attack hit %s.", other->GetName());
uint32 hate = 0;
int TotalDmg = 0;
@@ -836,12 +836,14 @@ void Mob::DoArcheryAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon,
int MaxDmg = WDmg + ADmg;
hate = ((WDmg + ADmg));
if (RuleB(Combat, ProjectileDmgOnImpact))
Log.Out(Logs::Detail, Logs::Combat, "Bow and Arrow DMG %d, Max Damage %d.", WDmg,
if (RuleB(Combat, ProjectileDmgOnImpact)) {
Log(Logs::Detail, Logs::Combat, "Bow and Arrow DMG %d, Max Damage %d.", WDmg,
MaxDmg);
else
Log.Out(Logs::Detail, Logs::Combat, "Bow DMG %d, Arrow DMG %d, Max Damage %d.", WDmg,
}
else {
Log(Logs::Detail, Logs::Combat, "Bow DMG %d, Arrow DMG %d, Max Damage %d.", WDmg,
ADmg, MaxDmg);
}
if (MaxDmg == 0)
MaxDmg = 1;
@@ -1082,7 +1084,7 @@ void NPC::RangedAttack(Mob* other)
//make sure the attack and ranged timers are up
//if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow
if((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check())){
Log.Out(Logs::Detail, Logs::Combat, "Archery canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime());
Log(Logs::Detail, Logs::Combat, "Archery canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime());
return;
}
@@ -1218,7 +1220,7 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51
//make sure the attack and ranged timers are up
//if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow
if((!CanDoubleAttack && (attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check()))) {
Log.Out(Logs::Detail, Logs::Combat, "Throwing attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime());
Log(Logs::Detail, Logs::Combat, "Throwing attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime());
// The server and client timers are not exact matches currently, so this would spam too often if enabled
//Message(0, "Error: Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime());
return;
@@ -1228,19 +1230,19 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51
const EQEmu::ItemInstance* RangeWeapon = m_inv[EQEmu::inventory::slotRange];
if (!RangeWeapon || !RangeWeapon->IsClassCommon()) {
Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotRange), EQEmu::inventory::slotRange);
Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotRange), EQEmu::inventory::slotRange);
Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have nothing to throw!", GetItemIDAt(EQEmu::inventory::slotRange));
return;
}
const EQEmu::ItemData* item = RangeWeapon->GetItem();
if (item->ItemType != EQEmu::item::ItemTypeLargeThrowing && item->ItemType != EQEmu::item::ItemTypeSmallThrowing) {
Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ranged item %d is not a throwing weapon. type %d.", item->ItemType);
Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ranged item %d is not a throwing weapon. type %d.", item->ItemType);
Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have nothing useful to throw!", GetItemIDAt(EQEmu::inventory::slotRange));
return;
}
Log.Out(Logs::Detail, Logs::Combat, "Throwing %s (%d) at %s", item->Name, item->ID, other->GetName());
Log(Logs::Detail, Logs::Combat, "Throwing %s (%d) at %s", item->Name, item->ID, other->GetName());
if(RangeWeapon->GetCharges() == 1) {
//first check ammo
@@ -1249,7 +1251,7 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51
//more in the ammo slot, use it
RangeWeapon = AmmoItem;
ammo_slot = EQEmu::inventory::slotAmmo;
Log.Out(Logs::Detail, Logs::Combat, "Using ammo from ammo slot, stack at slot %d. %d in stack.", ammo_slot, RangeWeapon->GetCharges());
Log(Logs::Detail, Logs::Combat, "Using ammo from ammo slot, stack at slot %d. %d in stack.", ammo_slot, RangeWeapon->GetCharges());
} else {
//look through our inventory for more
int32 aslot = m_inv.HasItem(item->ID, 1, invWherePersonal);
@@ -1257,17 +1259,17 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51
//the item wont change, but the instance does, not that it matters
ammo_slot = aslot;
RangeWeapon = m_inv[aslot];
Log.Out(Logs::Detail, Logs::Combat, "Using ammo from inventory slot, stack at slot %d. %d in stack.", ammo_slot, RangeWeapon->GetCharges());
Log(Logs::Detail, Logs::Combat, "Using ammo from inventory slot, stack at slot %d. %d in stack.", ammo_slot, RangeWeapon->GetCharges());
}
}
}
float range = item->Range + GetRangeDistTargetSizeMod(other);
Log.Out(Logs::Detail, Logs::Combat, "Calculated bow range to be %.1f", range);
Log(Logs::Detail, Logs::Combat, "Calculated bow range to be %.1f", range);
range *= range;
float dist = DistanceSquared(m_Position, other->GetPosition());
if(dist > range) {
Log.Out(Logs::Detail, Logs::Combat, "Throwing attack out of range... client should catch this. (%f > %f).\n", dist, range);
Log(Logs::Detail, Logs::Combat, "Throwing attack out of range... client should catch this. (%f > %f).\n", dist, range);
Message_StringID(13,TARGET_OUT_OF_RANGE);//Client enforces range and sends the message, this is a backup just incase.
return;
}
@@ -1333,7 +1335,7 @@ void Mob::DoThrowingAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon
SendItemAnimation(other, AmmoItem, EQEmu::skills::SkillThrowing);
}
Log.Out(Logs::Detail, Logs::Combat, "Throwing attack hit %s.", other->GetName());
Log(Logs::Detail, Logs::Combat, "Throwing attack hit %s.", other->GetName());
int WDmg = 0;
@@ -1371,7 +1373,7 @@ void Mob::DoThrowingAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon
DoAttack(other, my_hit);
TotalDmg = my_hit.damage_done;
Log.Out(Logs::Detail, Logs::Combat, "Item DMG %d. Hit for damage %d", WDmg, TotalDmg);
Log(Logs::Detail, Logs::Combat, "Item DMG %d. Hit for damage %d", WDmg, TotalDmg);
} else {
TotalDmg = DMG_INVULNERABLE;
}