Add fix for scenario where a client traveled far distance quickly and mob scanning is too slow; this takes care of all scenarios

This commit is contained in:
Akkadius 2020-07-07 01:19:02 -05:00
parent 520ac3ae46
commit 4e6c3b524f
2 changed files with 17 additions and 13 deletions

View File

@ -256,9 +256,9 @@ bool Client::Process() {
* Used in aggro checks * Used in aggro checks
*/ */
if (mob_close_scan_timer.Check()) { if (mob_close_scan_timer.Check()) {
entity_list.ScanCloseMobs(close_mobs, this); entity_list.ScanCloseMobs(close_mobs, this, true);
} }
bool may_use_attacks = false; bool may_use_attacks = false;
/* /*
Things which prevent us from attacking: Things which prevent us from attacking:
@ -757,7 +757,7 @@ void Client::BulkSendInventoryItems()
if (ob.tellp() == last_pos) if (ob.tellp() == last_pos)
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id); LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
last_pos = ob.tellp(); last_pos = ob.tellp();
} }
@ -836,7 +836,7 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
else { else {
cur_fac_level = GetModCharacterFactionLevel(fac); cur_fac_level = GetModCharacterFactionLevel(fac);
} }
if (cur_fac_level < ml.faction_required) if (cur_fac_level < ml.faction_required)
continue; continue;
@ -1170,7 +1170,7 @@ void Client::OPMoveCoin(const EQApplicationPacket* app)
{ {
return; return;
} }
// could just do a range, but this is clearer and explicit // could just do a range, but this is clearer and explicit
if if
( (

View File

@ -2716,18 +2716,22 @@ void EntityList::ScanCloseMobs(
} }
float distance = DistanceSquared(scanning_mob->GetPosition(), mob->GetPosition()); float distance = DistanceSquared(scanning_mob->GetPosition(), mob->GetPosition());
if (distance <= scan_range) { if (distance <= scan_range || mob->GetAggroRange() >= scan_range) {
close_mobs.insert(std::pair<uint16, Mob *>(mob->GetID(), mob)); close_mobs.insert(std::pair<uint16, Mob *>(mob->GetID(), mob));
if (add_self_to_other_lists) { if (add_self_to_other_lists) {
mob->close_mobs.insert(std::pair<uint16, Mob *>(scanning_mob->GetID(), scanning_mob)); bool has_mob = false;
}
}
else if (mob->GetAggroRange() >= scan_range) {
close_mobs.insert(std::pair<uint16, Mob *>(mob->GetID(), mob));
if (add_self_to_other_lists) { for (auto &cm: mob->close_mobs) {
mob->close_mobs.insert(std::pair<uint16, Mob *>(scanning_mob->GetID(), scanning_mob)); if (scanning_mob->GetID() == cm.first) {
has_mob = true;
break;
}
}
if (!has_mob) {
mob->close_mobs.insert(std::pair<uint16, Mob *>(scanning_mob->GetID(), scanning_mob));
}
} }
} }
} }