From fb1d4109a99cfdc0ca3b0d4a617f00a7f87a3e0e Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Tue, 29 Apr 2014 22:23:25 -0400 Subject: [PATCH 01/10] Fix for AA stacking where first AA in series has only 1 rank. --- zone/AA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/AA.cpp b/zone/AA.cpp index 87463247b..8566c09b5 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -1358,7 +1358,7 @@ void Client::SendAA(uint32 id, int seq) { if (aa_stack){ - if (saa->sof_current_level > 1 && value == 0) + if (saa->sof_current_level >= 1 && value == 0) saa->current_level = saa->sof_current_level+1; saa->max_level = saa->sof_max_level; From f6e6f10716f56bda7fb9b422497c5104a6dbaba9 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Sun, 4 May 2014 01:02:04 -0400 Subject: [PATCH 02/10] Fix for npc_types table error setting SlowMitigation to null by default. If you already ran the 4-12 update you do not need to run it again, just run the new one. --- utils/sql/git/required/2014_04_12_SlowMitigation.sql | 2 +- utils/sql/git/required/2014_05_4_SlowMitigationFix.sql | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 utils/sql/git/required/2014_05_4_SlowMitigationFix.sql diff --git a/utils/sql/git/required/2014_04_12_SlowMitigation.sql b/utils/sql/git/required/2014_04_12_SlowMitigation.sql index f2ac0d68d..a497a525b 100644 --- a/utils/sql/git/required/2014_04_12_SlowMitigation.sql +++ b/utils/sql/git/required/2014_04_12_SlowMitigation.sql @@ -2,6 +2,6 @@ UPDATE npc_types SET slow_mitigation = slow_mitigation * 100; -- Change variable type from FLOAT TO INT -ALTER TABLE npc_types MODIFY slow_mitigation smallint(4); +ALTER TABLE npc_types MODIFY slow_mitigation smallint(4) NOT NULL DEFAULT '0'; diff --git a/utils/sql/git/required/2014_05_4_SlowMitigationFix.sql b/utils/sql/git/required/2014_05_4_SlowMitigationFix.sql new file mode 100644 index 000000000..bf657023c --- /dev/null +++ b/utils/sql/git/required/2014_05_4_SlowMitigationFix.sql @@ -0,0 +1,3 @@ +ALTER TABLE npc_types MODIFY slow_mitigation smallint(4) NOT NULL DEFAULT '0'; + + From eb33e8ae111a35fa5e345b74996f20b646f2ba3c Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 5 May 2014 15:29:29 -0400 Subject: [PATCH 03/10] Melee 'facing' code updated to client derived function These new functions are derived from the client The need was because the old function sometimes didn't line up with the client generated messages. --- zone/client_packet.cpp | 2 +- zone/client_process.cpp | 6 ++--- zone/mob.cpp | 49 +++++++++++++++++++++++++++++++++++++++++ zone/mob.h | 2 ++ 4 files changed, 55 insertions(+), 4 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 1a9420dd7..cc5414ac4 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1328,7 +1328,7 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) aa_los_them.y = aa_los_them_mob->GetY(); aa_los_them.z = aa_los_them_mob->GetZ(); los_status = CheckLosFN(aa_los_them_mob); - los_status_facing = aa_los_them_mob->InFrontMob(this, aa_los_them.x, aa_los_them.y); + los_status_facing = IsFacingMob(aa_los_them_mob); } else { diff --git a/zone/client_process.cpp b/zone/client_process.cpp index c28affd28..f245c1d44 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -361,13 +361,13 @@ bool Client::Process() { aa_los_them.z = aa_los_them_mob->GetZ(); los_status = CheckLosFN(auto_attack_target); aa_los_me_heading = GetHeading(); - los_status_facing = aa_los_them_mob->InFrontMob(this, aa_los_them.x, aa_los_them.y); + los_status_facing = IsFacingMob(aa_los_them_mob); } // If only our heading changes, we can skip the CheckLosFN call // but above we still need to update los_status_facing if (aa_los_me_heading != GetHeading()) { aa_los_me_heading = GetHeading(); - los_status_facing = aa_los_them_mob->InFrontMob(this, aa_los_them.x, aa_los_them.y); + los_status_facing = IsFacingMob(aa_los_them_mob); } } else @@ -381,7 +381,7 @@ bool Client::Process() { aa_los_them.y = aa_los_them_mob->GetY(); aa_los_them.z = aa_los_them_mob->GetZ(); los_status = CheckLosFN(auto_attack_target); - los_status_facing = aa_los_them_mob->InFrontMob(this, aa_los_them.x, aa_los_them.y); + los_status_facing = IsFacingMob(aa_los_them_mob); } if (!CombatRange(auto_attack_target)) diff --git a/zone/mob.cpp b/zone/mob.cpp index 6d5907014..cef5bd605 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -5046,3 +5046,52 @@ void Mob::ProcessSpecialAbilities(const std::string str) { } } } + +// derived from client to keep these functions more consistent +// if anything seems weird, blame SoE +bool Mob::IsFacingMob(Mob *other) +{ + float angle = HeadingAngleToMob(other); + // what the client uses appears to be 2x our internal heading + float heading = GetHeading() * 2.0; + + if (angle > 472.0 && heading < 40.0) + angle = heading; + if (angle < 40.0 && heading > 472.0) + angle = heading; + + if (fabs(angle - heading) <= 80.0) + return true; + + return false; +} + +// All numbers derived from the client +float Mob::HeadingAngleToMob(Mob *other) +{ + float mob_x = other->GetX(); + float mob_y = other->GetY(); + float this_x = GetX(); + float this_y = GetY(); + + float y_diff = fabs(this_y - mob_y); + float x_diff = fabs(this_x - mob_x); + if (y_diff < 0.0000009999999974752427) + y_diff = 0.0000009999999974752427; + + float angle = atan2(x_diff, y_diff) * 180.0 * 0.3183099014828645; // angle, nice "pi" + + // return the right thing based on relative quadrant + // I'm sure this could be improved for readability, but whatever + if (this_y >= mob_y) { + if (mob_x >= this_x) + return (90.0 - angle + 90.0) * 511.5 * 0.0027777778; + if (mob_x <= this_x) + return (angle + 180.0) * 511.5 * 0.0027777778; + } + if (this_y > mob_y || mob_x > this_x) + return angle * 511.5 * 0.0027777778; + else + return (90.0 - angle + 270.0) * 511.5 * 0.0027777778; +} + diff --git a/zone/mob.h b/zone/mob.h index 92b999d9d..1df559d16 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -125,6 +125,8 @@ public: // less than 56 is in front, greater than 56 is usually where the client generates the messages inline bool InFrontMob(Mob *other = 0, float ourx = 0.0f, float oury = 0.0f) const { return (!other || other == this) ? true : MobAngle(other, ourx, oury) < 56.0f; } + bool IsFacingMob(Mob *other); // kind of does the same as InFrontMob, but derived from client + float HeadingAngleToMob(Mob *other); // to keep consistent with client generated messages virtual void RangedAttack(Mob* other) { } virtual void ThrowingAttack(Mob* other) { } uint16 GetThrownDamage(int16 wDmg, int32& TotalDmg, int& minDmg); From 84f99b6d6b47f9c38016a8dadc573ea992425ddf Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 5 May 2014 15:48:19 -0400 Subject: [PATCH 04/10] Added pointer check --- zone/mob.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zone/mob.cpp b/zone/mob.cpp index cef5bd605..c2cf34650 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -5051,6 +5051,8 @@ void Mob::ProcessSpecialAbilities(const std::string str) { // if anything seems weird, blame SoE bool Mob::IsFacingMob(Mob *other) { + if (!other) + return false; float angle = HeadingAngleToMob(other); // what the client uses appears to be 2x our internal heading float heading = GetHeading() * 2.0; From 2cf546accd638d05135efe00631d0bd4ab6931e1 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 5 May 2014 18:23:55 -0400 Subject: [PATCH 05/10] Fix #150 --- tests/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index aef5124c9..aba365486 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -32,9 +32,9 @@ IF(UNIX) TARGET_LINK_LIBRARIES(tests "${CMAKE_DL_LIBS}") TARGET_LINK_LIBRARIES(tests "z") TARGET_LINK_LIBRARIES(tests "m") - IF(NOT DARWIN) - TARGET_LINK_LIBRARIES(loginserver "rt") - ENDIF(NOT DARWIN) + IF(NOT DARWIN) + TARGET_LINK_LIBRARIES(tests "rt") + ENDIF(NOT DARWIN) TARGET_LINK_LIBRARIES(tests "pthread") ADD_DEFINITIONS(-fPIC) ENDIF(UNIX) From 391eee428994429fa064d323668a34c6696df296 Mon Sep 17 00:00:00 2001 From: Uleat Date: Mon, 5 May 2014 20:42:31 -0400 Subject: [PATCH 06/10] Test fix for 'random' zone crashes..particularly relating to MGB use. --- changelog.txt | 3 +++ zone/effects.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/changelog.txt b/changelog.txt index 869ff369c..465ddd10c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 05/05/2014 == +Uleat: Test fix to eliminate seemingly random crashes when an AE spell is being used. (Possible access to uninstantiated pointers during client connection process when someone casts a beneficial AE spell within range of a connecting client.) + == 04/29/2014 == KLS: Implemented new map code based on some of Derision's earlier work. Old maps still work with this system and don't need to be regenerated. We're still working on a new azone solution for better/more efficient maps. diff --git a/zone/effects.cpp b/zone/effects.cpp index f2a8db2a6..dd72408f3 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -748,6 +748,9 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_ for (auto it = mob_list.begin(); it != mob_list.end(); ++it) { curmob = it->second; + // test to fix possible cause of random zone crashes..external methods accessing client properties before they're initialized + if (curmob->IsClient() && !curmob->CastToClient()->Connected()) + continue; if (curmob == center) //do not affect center continue; if (curmob == caster && !affect_caster) //watch for caster too From 5c0a75071c2288115a516887e6ce2bf3a65cb26b Mon Sep 17 00:00:00 2001 From: JJ Date: Mon, 5 May 2014 21:18:08 -0400 Subject: [PATCH 07/10] SQL file rename (added '0') --- ...5_4_SlowMitigationFix.sql => 2014_05_04_SlowMitigationFix.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename utils/sql/git/required/{2014_05_4_SlowMitigationFix.sql => 2014_05_04_SlowMitigationFix.sql} (100%) diff --git a/utils/sql/git/required/2014_05_4_SlowMitigationFix.sql b/utils/sql/git/required/2014_05_04_SlowMitigationFix.sql similarity index 100% rename from utils/sql/git/required/2014_05_4_SlowMitigationFix.sql rename to utils/sql/git/required/2014_05_04_SlowMitigationFix.sql From 6477de8c4f5a1afa62a52359894004a0ecd31801 Mon Sep 17 00:00:00 2001 From: Uleat Date: Mon, 5 May 2014 21:59:21 -0400 Subject: [PATCH 08/10] Fix for test... (conn_state != client_state) --- changelog.txt | 1 + zone/effects.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 465ddd10c..a349f4795 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- == 05/05/2014 == +Uleat: Oops! Wrong state check (conn_state != client_state) Uleat: Test fix to eliminate seemingly random crashes when an AE spell is being used. (Possible access to uninstantiated pointers during client connection process when someone casts a beneficial AE spell within range of a connecting client.) == 04/29/2014 == diff --git a/zone/effects.cpp b/zone/effects.cpp index dd72408f3..c298974db 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -749,7 +749,7 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_ for (auto it = mob_list.begin(); it != mob_list.end(); ++it) { curmob = it->second; // test to fix possible cause of random zone crashes..external methods accessing client properties before they're initialized - if (curmob->IsClient() && !curmob->CastToClient()->Connected()) + if (curmob->IsClient() && !curmob->CastToClient()->ClientFinishedLoading()) continue; if (curmob == center) //do not affect center continue; From 7b1a084d39a9598813372fa6ce8c98c702cf73f8 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Wed, 7 May 2014 22:46:00 -0400 Subject: [PATCH 09/10] AA/Item/Spell that allow pets to flurry and critical will now also apply to owners swarm pets consistent with live. --- changelog.txt | 3 +++ zone/MobAI.cpp | 11 +++++++++-- zone/attack.cpp | 11 +++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/changelog.txt b/changelog.txt index a349f4795..0e5a15763 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 05/07/2014 == +Kayen: AA/Item/Spells that allow pets to critical and flurry will now work on the owners swarm pets consistent with live. + == 05/05/2014 == Uleat: Oops! Wrong state check (conn_state != client_state) Uleat: Test fix to eliminate seemingly random crashes when an AE spell is being used. (Possible access to uninstantiated pointers during client connection process when someone casts a beneficial AE spell within range of a connecting client.) diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index aa791318a..88c0309c0 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -1213,11 +1213,18 @@ void Mob::AI_Process() { } } - if (IsPet()) { - Mob *owner = GetOwner(); + if (IsPet() || (IsNPC() && CastToNPC()->GetSwarmOwner())) { + Mob *owner = nullptr; + + if (IsPet()) + owner = GetOwner(); + else + owner = entity_list.GetMobID(CastToNPC()->GetSwarmOwner()); + if (owner) { int16 flurry_chance = owner->aabonuses.PetFlurry + owner->spellbonuses.PetFlurry + owner->itembonuses.PetFlurry; + if (flurry_chance && (MakeRandomInt(0, 99) < flurry_chance)) Flurry(nullptr); } diff --git a/zone/attack.cpp b/zone/attack.cpp index fbcec2f59..06ad5439f 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -4226,11 +4226,13 @@ void Mob::TryPetCriticalHit(Mob *defender, uint16 skill, int32 &damage) if (damage < 1) //We can't critical hit if we don't hit. return; - if (!IsPet()) + if (IsPet()) + owner = GetOwner(); + else if ((IsNPC() && CastToNPC()->GetSwarmOwner())) + owner = entity_list.GetMobID(CastToNPC()->GetSwarmOwner()); + else return; - owner = GetOwner(); - if (!owner) return; @@ -4267,7 +4269,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 // code in here, but could lead to some confusion otherwise - if (IsPet() && GetOwner()->IsClient()) { + if (IsPet() && GetOwner()->IsClient() || (IsNPC() && CastToNPC()->GetSwarmOwner())) { TryPetCriticalHit(defender,skill,damage); return; } @@ -4456,6 +4458,7 @@ void Mob::DoRiposte(Mob* defender) { //Double Riposte effect, allows for a chance to do RIPOSTE with a skill specfic special attack (ie Return Kick). //Coded narrowly: Limit to one per client. Limit AA only. [1 = Skill Attack Chance, 2 = Skill] + DoubleRipChance = defender->aabonuses.GiveDoubleRiposte[1]; if(DoubleRipChance && (DoubleRipChance >= MakeRandomInt(0, 100))) { From 670c5e2e1ab34b6bfd12b180bc0264fd90e2dc8c Mon Sep 17 00:00:00 2001 From: KimLS Date: Fri, 9 May 2014 15:06:33 -0700 Subject: [PATCH 10/10] Fix for crash in loading loot drops when you hit the actual lootdrop entry limit of 1260 --- common/shareddb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/shareddb.cpp b/common/shareddb.cpp index a49cec4e8..03d6c4c52 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -2011,7 +2011,7 @@ void SharedDatabase::LoadLootDrops(void *data, uint32 size) { current_id = id; } - if(current_entry > 1260) { + if(current_entry >= 1260) { continue; }