mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-19 13:28:25 +00:00
Merge remote-tracking branch 'remotes/origin/master' into logging_changes
Conflicts: world/client.cpp world/worlddb.cpp zone/aggro.cpp zone/bot.cpp zone/client.cpp zone/client_packet.cpp zone/client_process.cpp zone/doors.cpp zone/entity.cpp zone/inventory.cpp zone/mob_ai.cpp zone/perl_client.cpp zone/spells.cpp zone/waypoints.cpp zone/zone.cpp zone/zonedb.cpp zone/zoning.cpp
This commit is contained in:
+124
-106
@@ -68,7 +68,7 @@ Entity::Entity()
|
||||
|
||||
Entity::~Entity()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
Client *Entity::CastToClient()
|
||||
@@ -466,14 +466,14 @@ void EntityList::MobProcess()
|
||||
while (it != mob_list.end()) {
|
||||
uint16 id = it->first;
|
||||
Mob *mob = it->second;
|
||||
|
||||
|
||||
size_t sz = mob_list.size();
|
||||
bool p_val = mob->Process();
|
||||
size_t a_sz = mob_list.size();
|
||||
|
||||
|
||||
if(a_sz > sz) {
|
||||
//increased size can potentially screw with iterators so reset it to current value
|
||||
//if buckets are re-orderered we may skip a process here and there but since
|
||||
//if buckets are re-orderered we may skip a process here and there but since
|
||||
//process happens so often it shouldn't matter much
|
||||
it = mob_list.find(id);
|
||||
++it;
|
||||
@@ -828,10 +828,11 @@ bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket *app, Client *client)
|
||||
strlen(door->GetDoorName()) > 3) {
|
||||
memset(&nd, 0, sizeof(nd));
|
||||
memcpy(nd.name, door->GetDoorName(), 32);
|
||||
nd.xPos = door->GetX();
|
||||
nd.yPos = door->GetY();
|
||||
nd.zPos = door->GetZ();
|
||||
nd.heading = door->GetHeading();
|
||||
auto position = door->GetPosition();
|
||||
nd.xPos = position.m_X;
|
||||
nd.yPos = position.m_Y;
|
||||
nd.zPos = position.m_Z;
|
||||
nd.heading = position.m_Heading;
|
||||
nd.incline = door->GetIncline();
|
||||
nd.size = door->GetSize();
|
||||
nd.doorId = door->GetDoorID();
|
||||
@@ -1100,7 +1101,7 @@ void EntityList::ChannelMessage(Mob *from, uint8 chan_num, uint8 language,
|
||||
filter = FilterAuctions;
|
||||
//
|
||||
// Only say is limited in range
|
||||
if (chan_num != 8 || client->Dist(*from) < 200)
|
||||
if (chan_num != 8 || Distance(client->GetPosition(), from->GetPosition()) < 200)
|
||||
if (filter == FilterNone || client->GetFilter(filter) != FilterHide)
|
||||
client->ChannelMessageSend(from->GetName(), 0, chan_num, language, lang_skill, buffer);
|
||||
++it;
|
||||
@@ -1423,7 +1424,7 @@ void EntityList::QueueCloseClients(Mob *sender, const EQApplicationPacket *app,
|
||||
|| (filter2 == FilterShowGroupOnly && (sender == ent ||
|
||||
(ent->GetGroup() && ent->GetGroup()->IsGroupMember(sender))))
|
||||
|| (filter2 == FilterShowSelfOnly && ent == sender))
|
||||
&& (ent->DistNoRoot(*sender) <= dist2)) {
|
||||
&& (ComparativeDistance(ent->GetPosition(), sender->GetPosition()) <= dist2)) {
|
||||
ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED);
|
||||
}
|
||||
}
|
||||
@@ -1533,16 +1534,14 @@ Client *EntityList::GetClientByWID(uint32 iWID)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Client *EntityList::GetRandomClient(float x, float y, float z, float Distance, Client *ExcludeClient)
|
||||
Client *EntityList::GetRandomClient(const xyz_location& location, float Distance, Client *ExcludeClient)
|
||||
{
|
||||
std::vector<Client *> ClientsInRange;
|
||||
|
||||
auto it = client_list.begin();
|
||||
while (it != client_list.end()) {
|
||||
if ((it->second != ExcludeClient) && (it->second->DistNoRoot(x, y, z) <= Distance))
|
||||
|
||||
for (auto it = client_list.begin();it != client_list.end(); ++it)
|
||||
if ((it->second != ExcludeClient) && (ComparativeDistance(static_cast<xyz_location>(it->second->GetPosition()), location) <= Distance))
|
||||
ClientsInRange.push_back(it->second);
|
||||
++it;
|
||||
}
|
||||
|
||||
if (ClientsInRange.empty())
|
||||
return nullptr;
|
||||
@@ -1567,7 +1566,7 @@ Corpse *EntityList::GetCorpseByOwnerWithinRange(Client *client, Mob *center, int
|
||||
auto it = corpse_list.begin();
|
||||
while (it != corpse_list.end()) {
|
||||
if (it->second->IsPlayerCorpse())
|
||||
if (center->DistNoRootNoZ(*it->second) < range &&
|
||||
if (ComparativeDistanceNoZ(center->GetPosition(), it->second->GetPosition()) < range &&
|
||||
strcasecmp(it->second->GetOwnerName(), client->GetName()) == 0)
|
||||
return it->second;
|
||||
++it;
|
||||
@@ -1904,7 +1903,7 @@ void EntityList::MessageClose_StringID(Mob *sender, bool skipsender, float dist,
|
||||
|
||||
for (auto it = client_list.begin(); it != client_list.end(); ++it) {
|
||||
c = it->second;
|
||||
if(c && c->DistNoRoot(*sender) <= dist2 && (!skipsender || c != sender))
|
||||
if(c && ComparativeDistance(c->GetPosition(), sender->GetPosition()) <= dist2 && (!skipsender || c != sender))
|
||||
c->Message_StringID(type, string_id, message1, message2, message3, message4, message5, message6, message7, message8, message9);
|
||||
}
|
||||
}
|
||||
@@ -1920,7 +1919,7 @@ void EntityList::FilteredMessageClose_StringID(Mob *sender, bool skipsender,
|
||||
|
||||
for (auto it = client_list.begin(); it != client_list.end(); ++it) {
|
||||
c = it->second;
|
||||
if (c && c->DistNoRoot(*sender) <= dist2 && (!skipsender || c != sender))
|
||||
if (c && ComparativeDistance(c->GetPosition(), sender->GetPosition()) <= dist2 && (!skipsender || c != sender))
|
||||
c->FilteredMessage_StringID(sender, type, filter, string_id,
|
||||
message1, message2, message3, message4, message5,
|
||||
message6, message7, message8, message9);
|
||||
@@ -1968,7 +1967,7 @@ void EntityList::MessageClose(Mob* sender, bool skipsender, float dist, uint32 t
|
||||
|
||||
auto it = client_list.begin();
|
||||
while (it != client_list.end()) {
|
||||
if (it->second->DistNoRoot(*sender) <= dist2 && (!skipsender || it->second != sender))
|
||||
if (ComparativeDistance(it->second->GetPosition(), sender->GetPosition()) <= dist2 && (!skipsender || it->second != sender))
|
||||
it->second->Message(type, buffer);
|
||||
++it;
|
||||
}
|
||||
@@ -2443,7 +2442,7 @@ void EntityList::SendPositionUpdates(Client *client, uint32 cLastUpdate,
|
||||
//bool Grouped = client->HasGroup() && mob->IsClient() && (client->GetGroup() == mob->CastToClient()->GetGroup());
|
||||
|
||||
//if (range == 0 || (iterator.GetData() == alwayssend) || Grouped || (mob->DistNoRootNoZ(*client) <= range)) {
|
||||
if (range == 0 || (it->second == alwayssend) || mob->IsClient() || (mob->DistNoRoot(*client) <= range)) {
|
||||
if (range == 0 || (it->second == alwayssend) || mob->IsClient() || (ComparativeDistance(mob->GetPosition(), client->GetPosition()) <= range)) {
|
||||
mob->MakeSpawnUpdate(ppu);
|
||||
}
|
||||
if(mob && mob->IsClient() && mob->GetID()>0) {
|
||||
@@ -2925,7 +2924,7 @@ bool EntityList::MakeTrackPacket(Client *client)
|
||||
it->second->IsInvisible(client))
|
||||
continue;
|
||||
|
||||
MobDistance = it->second->DistNoZ(*client);
|
||||
MobDistance = DistanceNoZ(it->second->GetPosition(), client->GetPosition());
|
||||
if (MobDistance > distance)
|
||||
continue;
|
||||
|
||||
@@ -2974,7 +2973,8 @@ void EntityList::MessageGroup(Mob *sender, bool skipclose, uint32 type, const ch
|
||||
|
||||
auto it = client_list.begin();
|
||||
while (it != client_list.end()) {
|
||||
if (it->second != sender && (it->second->Dist(*sender) <= dist2 || it->second->GetGroup() == sender->CastToClient()->GetGroup())) {
|
||||
if (it->second != sender &&
|
||||
(Distance(it->second->GetPosition(), sender->GetPosition()) <= dist2 || it->second->GetGroup() == sender->CastToClient()->GetGroup())) {
|
||||
it->second->Message(type, buffer);
|
||||
}
|
||||
++it;
|
||||
@@ -3047,54 +3047,43 @@ void EntityList::AddHealAggro(Mob *target, Mob *caster, uint16 thedam)
|
||||
|
||||
void EntityList::OpenDoorsNear(NPC *who)
|
||||
{
|
||||
auto it = door_list.begin();
|
||||
while (it != door_list.end()) {
|
||||
|
||||
for (auto it = door_list.begin();it != door_list.end(); ++it) {
|
||||
Doors *cdoor = it->second;
|
||||
if (cdoor && !cdoor->IsDoorOpen()) {
|
||||
float zdiff = who->GetZ() - cdoor->GetZ();
|
||||
if (zdiff < 0)
|
||||
zdiff = 0 - zdiff;
|
||||
float curdist = 0;
|
||||
float tmp = who->GetX() - cdoor->GetX();
|
||||
curdist += tmp * tmp;
|
||||
tmp = who->GetY() - cdoor->GetY();
|
||||
curdist += tmp * tmp;
|
||||
if (zdiff < 10 && curdist <= 100)
|
||||
cdoor->NPCOpen(who);
|
||||
}
|
||||
++it;
|
||||
if (!cdoor || cdoor->IsDoorOpen())
|
||||
continue;
|
||||
|
||||
auto diff = who->GetPosition() - cdoor->GetPosition();
|
||||
diff.ABS_XYZ();
|
||||
|
||||
float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y;
|
||||
|
||||
if (diff.m_Z * diff.m_Z < 10 && curdist <= 100)
|
||||
cdoor->NPCOpen(who);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityList::SendAlarm(Trap *trap, Mob *currenttarget, uint8 kos)
|
||||
{
|
||||
float val2 = trap->effectvalue * trap->effectvalue;
|
||||
float preSquareDistance = trap->effectvalue * trap->effectvalue;
|
||||
|
||||
auto it = npc_list.begin();
|
||||
while (it != npc_list.end()) {
|
||||
for (auto it = npc_list.begin();it != npc_list.end(); ++it) {
|
||||
NPC *cur = it->second;
|
||||
float curdist = 0;
|
||||
float tmp = cur->GetX() - trap->x;
|
||||
curdist += tmp*tmp;
|
||||
tmp = cur->GetY() - trap->y;
|
||||
curdist += tmp*tmp;
|
||||
tmp = cur->GetZ() - trap->z;
|
||||
curdist += tmp*tmp;
|
||||
if (!cur->GetOwner() &&
|
||||
/*!cur->CastToMob()->dead && */
|
||||
!cur->IsEngaged() &&
|
||||
curdist <= val2 )
|
||||
{
|
||||
if (kos) {
|
||||
uint8 factioncon = currenttarget->GetReverseFactionCon(cur);
|
||||
if (factioncon == FACTION_THREATENLY || factioncon == FACTION_SCOWLS) {
|
||||
cur->AddToHateList(currenttarget,1);
|
||||
}
|
||||
} else {
|
||||
|
||||
auto diff = cur->GetPosition() - trap->m_Position;
|
||||
float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y + diff.m_Z * diff.m_Z;
|
||||
|
||||
if (cur->GetOwner() || cur->IsEngaged() || curdist > preSquareDistance )
|
||||
continue;
|
||||
|
||||
if (kos) {
|
||||
uint8 factioncon = currenttarget->GetReverseFactionCon(cur);
|
||||
if (factioncon == FACTION_THREATENLY || factioncon == FACTION_SCOWLS) {
|
||||
cur->AddToHateList(currenttarget,1);
|
||||
}
|
||||
}
|
||||
++it;
|
||||
}
|
||||
else
|
||||
cur->AddToHateList(currenttarget,1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3131,7 +3120,7 @@ struct quest_proximity_event {
|
||||
int area_type;
|
||||
};
|
||||
|
||||
void EntityList::ProcessMove(Client *c, float x, float y, float z)
|
||||
void EntityList::ProcessMove(Client *c, const xyz_location& location)
|
||||
{
|
||||
float last_x = c->ProximityX();
|
||||
float last_y = c->ProximityY();
|
||||
@@ -3153,9 +3142,9 @@ void EntityList::ProcessMove(Client *c, float x, float y, float z)
|
||||
last_z < l->min_z || last_z > l->max_z) {
|
||||
old_in = false;
|
||||
}
|
||||
if (x < l->min_x || x > l->max_x ||
|
||||
y < l->min_y || y > l->max_y ||
|
||||
z < l->min_z || z > l->max_z) {
|
||||
if (location.m_X < l->min_x || location.m_X > l->max_x ||
|
||||
location.m_Y < l->min_y || location.m_Y > l->max_y ||
|
||||
location.m_Z < l->min_z || location.m_Z > l->max_z) {
|
||||
new_in = false;
|
||||
}
|
||||
|
||||
@@ -3188,9 +3177,9 @@ void EntityList::ProcessMove(Client *c, float x, float y, float z)
|
||||
old_in = false;
|
||||
}
|
||||
|
||||
if (x < a.min_x || x > a.max_x ||
|
||||
y < a.min_y || y > a.max_y ||
|
||||
z < a.min_z || z > a.max_z ) {
|
||||
if (location.m_X < a.min_x || location.m_X > a.max_x ||
|
||||
location.m_Y < a.min_y || location.m_Y > a.max_y ||
|
||||
location.m_Z < a.min_z || location.m_Z > a.max_z ) {
|
||||
new_in = false;
|
||||
}
|
||||
|
||||
@@ -3520,6 +3509,32 @@ bool EntityList::LimitCheckName(const char *npc_name)
|
||||
return true;
|
||||
}
|
||||
|
||||
void EntityList::RadialSetLogging(Mob *around, bool enabled, bool clients,
|
||||
bool non_clients, float range)
|
||||
{
|
||||
float range2 = range * range;
|
||||
|
||||
auto it = mob_list.begin();
|
||||
while (it != mob_list.end()) {
|
||||
Mob *mob = it->second;
|
||||
|
||||
++it;
|
||||
|
||||
if (mob->IsClient()) {
|
||||
if (!clients)
|
||||
continue;
|
||||
} else {
|
||||
if (!non_clients)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ComparativeDistance(around->GetPosition(), mob->GetPosition()) > range2)
|
||||
continue;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void EntityList::UpdateHoTT(Mob *target)
|
||||
{
|
||||
auto it = client_list.begin();
|
||||
@@ -3564,7 +3579,7 @@ int16 EntityList::CountTempPets(Mob *owner)
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
|
||||
owner->SetTempPetCount(count);
|
||||
|
||||
return count;
|
||||
@@ -3630,7 +3645,7 @@ void EntityList::QuestJournalledSayClose(Mob *sender, Client *QuestInitiator,
|
||||
// Use the old method for all other nearby clients
|
||||
for (auto it = client_list.begin(); it != client_list.end(); ++it) {
|
||||
c = it->second;
|
||||
if(c && (c != QuestInitiator) && c->DistNoRoot(*sender) <= dist2)
|
||||
if(c && (c != QuestInitiator) && ComparativeDistance(c->GetPosition(), sender->GetPosition()) <= dist2)
|
||||
c->Message_StringID(10, GENERIC_SAY, mobname, message);
|
||||
}
|
||||
}
|
||||
@@ -3755,51 +3770,54 @@ void EntityList::GroupMessage(uint32 gid, const char *from, const char *message)
|
||||
}
|
||||
}
|
||||
|
||||
uint16 EntityList::CreateGroundObject(uint32 itemid, float x, float y, float z,
|
||||
float heading, uint32 decay_time)
|
||||
uint16 EntityList::CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time)
|
||||
{
|
||||
const Item_Struct *is = database.GetItem(itemid);
|
||||
if (is) {
|
||||
ItemInst *i = new ItemInst(is, is->MaxCharges);
|
||||
if (i) {
|
||||
Object *object = new Object(i, x, y, z, heading,decay_time);
|
||||
entity_list.AddObject(object, true);
|
||||
if (!is)
|
||||
return 0;
|
||||
|
||||
safe_delete(i);
|
||||
if (object)
|
||||
return object->GetID();
|
||||
}
|
||||
return 0; // fell through itemstruct
|
||||
}
|
||||
return 0; // fell through everything, this is bad/incomplete from perl
|
||||
ItemInst *i = new ItemInst(is, is->MaxCharges);
|
||||
if (!i)
|
||||
return 0;
|
||||
|
||||
Object *object = new Object(i, position.m_X, position.m_Y, position.m_Z, position.m_Heading,decay_time);
|
||||
entity_list.AddObject(object, true);
|
||||
|
||||
safe_delete(i);
|
||||
if (!object)
|
||||
return 0;
|
||||
|
||||
return object->GetID();
|
||||
}
|
||||
|
||||
uint16 EntityList::CreateGroundObjectFromModel(const char *model, float x,
|
||||
float y, float z, float heading, uint8 type, uint32 decay_time)
|
||||
uint16 EntityList::CreateGroundObjectFromModel(const char *model, const xyz_heading& position, uint8 type, uint32 decay_time)
|
||||
{
|
||||
if (model) {
|
||||
Object *object = new Object(model, x, y, z, heading, type);
|
||||
entity_list.AddObject(object, true);
|
||||
if (!model)
|
||||
return 0;
|
||||
|
||||
if (object)
|
||||
return object->GetID();
|
||||
}
|
||||
return 0; // fell through everything, this is bad/incomplete from perl
|
||||
Object *object = new Object(model, position.m_X, position.m_Y, position.m_Z, position.m_Heading, type);
|
||||
entity_list.AddObject(object, true);
|
||||
|
||||
if (!object)
|
||||
return 0;
|
||||
|
||||
return object->GetID();
|
||||
}
|
||||
|
||||
uint16 EntityList::CreateDoor(const char *model, float x, float y, float z,
|
||||
float heading, uint8 opentype, uint16 size)
|
||||
uint16 EntityList::CreateDoor(const char *model, const xyz_heading& position, uint8 opentype, uint16 size)
|
||||
{
|
||||
if (model) {
|
||||
Doors *door = new Doors(model, x, y, z, heading, opentype, size);
|
||||
RemoveAllDoors();
|
||||
zone->LoadZoneDoors(zone->GetShortName(), zone->GetInstanceVersion());
|
||||
entity_list.AddDoor(door);
|
||||
entity_list.RespawnAllDoors();
|
||||
if (!model)
|
||||
return 0; // fell through everything, this is bad/incomplete from perl
|
||||
|
||||
Doors *door = new Doors(model, position, opentype, size);
|
||||
RemoveAllDoors();
|
||||
zone->LoadZoneDoors(zone->GetShortName(), zone->GetInstanceVersion());
|
||||
entity_list.AddDoor(door);
|
||||
entity_list.RespawnAllDoors();
|
||||
|
||||
if (door)
|
||||
return door->GetEntityID();
|
||||
|
||||
if (door)
|
||||
return door->GetEntityID();
|
||||
}
|
||||
return 0; // fell through everything, this is bad/incomplete from perl
|
||||
}
|
||||
|
||||
@@ -3829,7 +3847,7 @@ Mob *EntityList::GetTargetForMez(Mob *caster)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (caster->DistNoRoot(*d) > 22250) { //only pick targets within 150 range
|
||||
if (ComparativeDistance(caster->GetPosition(), d->GetPosition()) > 22250) { //only pick targets within 150 range
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
@@ -4339,7 +4357,7 @@ void EntityList::UpdateFindableNPCState(NPC *n, bool Remove)
|
||||
auto it = client_list.begin();
|
||||
while (it != client_list.end()) {
|
||||
Client *c = it->second;
|
||||
if (c && (c->GetClientVersion() >= EQClientSoD))
|
||||
if (c && (c->GetClientVersion() >= ClientVersion::SoD))
|
||||
c->QueuePacket(outapp);
|
||||
|
||||
++it;
|
||||
|
||||
Reference in New Issue
Block a user