From 640aea24bc2c769cffc013289c74a61ba0446e22 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 24 Nov 2014 23:22:10 -0800 Subject: [PATCH 001/253] xyz_heading, xyz_location, and xy_location built --- zone/CMakeLists.txt | 4 +- zone/position.cpp | 106 ++++++++++++++++++++++++++++++++++++++++++++ zone/position.h | 80 +++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 zone/position.cpp create mode 100644 zone/position.h diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index 8cd086405..f7573ecdb 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -16,7 +16,7 @@ SET(zone_sources command.cpp corpse.cpp doors.cpp - effects.cpp + effects.cpp embparser.cpp embparser_api.cpp embperl.cpp @@ -92,6 +92,7 @@ SET(zone_sources perlpacket.cpp petitions.cpp pets.cpp + position.cpp qglobals.cpp queryserv.cpp questmgr.cpp @@ -182,6 +183,7 @@ SET(zone_headers perlpacket.h petitions.h pets.h + position.h qglobals.h quest_interface.h queryserv.h diff --git a/zone/position.cpp b/zone/position.cpp new file mode 100644 index 000000000..9264f18cd --- /dev/null +++ b/zone/position.cpp @@ -0,0 +1,106 @@ +#include "position.h" + +xy_location::xy_location(float x, float y) : + m_X(x), + m_Y(y) { +} + +const xy_location xy_location::operator -(const xy_location& rhs) { + xy_location minus{m_X - rhs.m_X, m_Y - rhs.m_Y}; + return minus; +} + +xyz_heading::xyz_heading(float x, float y, float z, float heading) : + m_X(x), + m_Y(y), + m_Z(z), + m_Heading(heading) { +} + +xyz_heading::xyz_heading(const xyz_heading& locationDir) : + m_X(locationDir.m_X), + m_Y(locationDir.m_Y), + m_Z(locationDir.m_Z), + m_Heading(locationDir.m_Heading) { +} + +xyz_heading::xyz_heading(const xyz_location& locationDir, float heading) : + m_X(locationDir.m_X), + m_Y(locationDir.m_Y), + m_Z(locationDir.m_Z), + m_Heading(heading) { +} + +xyz_heading::xyz_heading(const xy_location& locationDir, float z, float heading) : + m_X(locationDir.m_X), + m_Y(locationDir.m_Y), + m_Z(z), + m_Heading(heading) { +} + + +xyz_heading::xyz_heading(const xyz_location locationDir, float heading) : + m_X(locationDir.m_X), + m_Y(locationDir.m_Y), + m_Z(locationDir.m_Z), + m_Heading(heading) { +} + +xyz_heading::xyz_heading(const xy_location locationDir, float z, float heading) : + m_X(locationDir.m_X), + m_Y(locationDir.m_Y), + m_Z(z), + m_Heading(heading) { +} + +xyz_heading::operator xyz_location() const { + return xyz_location{m_X,m_Y,m_Z}; +} + +xyz_heading::operator xy_location() const { + return xy_location{m_X,m_Y}; +} + +const xyz_heading xyz_heading::operator +(const xyz_location& rhs) { + return xyz_heading{m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z + rhs.m_Z, m_Heading}; +} + +const xyz_heading xyz_heading::operator +(const xy_location& rhs) { + return xyz_heading{m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z, m_Heading}; +} + +const xyz_heading xyz_heading::operator -(const xyz_location& rhs) { + return xyz_heading{m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z, m_Heading}; +} + + +xyz_location::xyz_location(float x, float y, float z) : + m_X(x), + m_Y(y), + m_Z(z) { +} + +xyz_location::xyz_location(double x, double y, double z) : + m_X(static_cast(x)), + m_Y(static_cast(y)), + m_Z(static_cast(z)) { +} + +xyz_location::operator xy_location() const { + return xy_location{m_X, m_Y}; +} + +const xyz_location xyz_location::operator -(const xyz_location& rhs) { + return xyz_location{m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z}; +} + +void xyz_location::ABS_XYZ(void) { + if (m_X < 0) + m_X = -m_X; + + if (m_Y < 0) + m_Y = -m_Y; + + if (m_Z < 0) + m_Z = -m_Z; +} diff --git a/zone/position.h b/zone/position.h new file mode 100644 index 000000000..6258e901f --- /dev/null +++ b/zone/position.h @@ -0,0 +1,80 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef POSITION_H +#define POSITION_H + +class xy_location { +public: + float m_X; + float m_Y; + + xy_location(float x = 0.0f, float y = 0.0f); + + const xy_location operator -(const xy_location& rhs); +}; + +class xyz_location { +public: + float m_X; + float m_Y; + float m_Z; + + static const xyz_location& Origin() {static xyz_location origin; return origin;} + + xyz_location(float x = 0.0f, float y = 0.0f, float z = 0.0f); + xyz_location(double x, double y, double z); + + operator xy_location() const; + + const xyz_location operator -(const xyz_location& rhs); + + void ABS_XYZ(); + bool isOrigin() const { return m_X == 0 && m_Y == 0 && m_Z == 0;} + +}; + +class xyz_heading { +public: + float m_X; + float m_Y; + float m_Z; + + float m_Heading; + + static const xyz_heading& Origin() {static xyz_heading origin; return origin;} + + xyz_heading(float x = 0.0f, float y = 0.0f, float z = 0.0f, float heading = 0.0f); + xyz_heading(const xyz_heading& locationDir); + xyz_heading(const xyz_location& locationDir, float heading = 0.0f); + xyz_heading(const xyz_location locationDir, float heading = 0.0f); + explicit xyz_heading(const xy_location& locationDir, float z, float heading); + explicit xyz_heading(const xy_location locationDir, float z, float heading); + + operator xyz_location() const; + operator xy_location() const; + + const xyz_heading operator +(const xyz_location& rhs); + const xyz_heading operator +(const xy_location& rhs); + + const xyz_heading operator -(const xyz_location& rhs); + + bool isOrigin() const { return m_X == 0.0f && m_Y == 0.0f && m_Z == 0.0f;} +}; + + +#endif From 53602e3c61172a9d4c5f644c544d968b96f1b16e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 25 Nov 2014 20:16:04 -0800 Subject: [PATCH 002/253] heading, x_pos, y_pos, and z_pos replaced with m_Position in Mob --- zone/beacon.cpp | 8 +- zone/bot.cpp | 6 +- zone/client.cpp | 24 ++--- zone/client_packet.cpp | 53 +++++----- zone/client_process.cpp | 38 ++++---- zone/corpse.cpp | 42 ++++---- zone/forage.cpp | 8 +- zone/mob.cpp | 102 +++++++++---------- zone/mob.h | 42 ++++---- zone/mob_ai.cpp | 2 +- zone/spells.cpp | 46 ++++----- zone/waypoints.cpp | 210 ++++++++++++++++++++-------------------- zone/zoning.cpp | 56 +++++------ 13 files changed, 318 insertions(+), 319 deletions(-) diff --git a/zone/beacon.cpp b/zone/beacon.cpp index 9b88dd524..4713e7c63 100644 --- a/zone/beacon.cpp +++ b/zone/beacon.cpp @@ -58,10 +58,10 @@ Beacon::Beacon(Mob *at_mob, int lifetime) caster_id = 0; // copy location - x_pos = at_mob->GetX(); - y_pos = at_mob->GetY(); - z_pos = at_mob->GetZ(); - heading = at_mob->GetHeading(); + m_Position.m_X = at_mob->GetX(); + m_Position.m_Y = at_mob->GetY(); + m_Position.m_Z = at_mob->GetZ(); + m_Position.m_Heading = at_mob->GetHeading(); if(lifetime) { diff --git a/zone/bot.cpp b/zone/bot.cpp index a68273fae..2a8921dd7 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -4122,9 +4122,9 @@ void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) { this->GetBotOwner()->CastToClient()->Message(13, "%s save failed!", this->GetCleanName()); // Spawn the bot at the bow owner's loc - this->x_pos = botCharacterOwner->GetX(); - this->y_pos = botCharacterOwner->GetY(); - this->z_pos = botCharacterOwner->GetZ(); + this->m_Position.m_X = botCharacterOwner->GetX(); + this->m_Position.m_Y = botCharacterOwner->GetY(); + this->m_Position.m_Z = botCharacterOwner->GetZ(); // Make the bot look at the bot owner FaceTarget(botCharacterOwner); diff --git a/zone/client.cpp b/zone/client.cpp index 9541959ba..2c6c73b8a 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -399,9 +399,9 @@ Client::~Client() { { m_pp.zone_id = m_pp.binds[0].zoneId; m_pp.zoneInstance = m_pp.binds[0].instance_id; - x_pos = m_pp.binds[0].x; - y_pos = m_pp.binds[0].y; - z_pos = m_pp.binds[0].z; + m_Position.m_X = m_pp.binds[0].x; + m_Position.m_Y = m_pp.binds[0].y; + m_Position.m_Z = m_pp.binds[0].z; } // we save right now, because the client might be zoning and the world @@ -525,11 +525,11 @@ bool Client::Save(uint8 iCommitNow) { return false; /* Wrote current basics to PP for saves */ - m_pp.x = x_pos; - m_pp.y = y_pos; - m_pp.z = z_pos; + m_pp.x = m_Position.m_X; + m_pp.y = m_Position.m_Y; + m_pp.z = m_Position.m_Z; m_pp.guildrank = guildrank; - m_pp.heading = heading; + m_pp.heading = m_Position.m_Heading; /* Mana and HP */ if (GetHP() <= 0) { @@ -3820,7 +3820,7 @@ void Client::Sacrifice(Client *caster) void Client::SendOPTranslocateConfirm(Mob *Caster, uint16 SpellID) { - if(!Caster || PendingTranslocate) + if(!Caster || PendingTranslocate) return; const SPDat_Spell_Struct &Spell = spells[SpellID]; @@ -4273,7 +4273,7 @@ bool Client::GroupFollow(Client* inviter) { { GetMerc()->MercJoinClientGroup(); } - + if (inviter->IsLFP()) { // If the player who invited us to a group is LFP, have them update world now that we have joined their group. @@ -5832,7 +5832,7 @@ void Client::ProcessInspectRequest(Client* requestee, Client* requester) { const Item_Struct *aug_weap = inst->GetOrnamentationAug(ornamentationAugtype)->GetItem(); strcpy(insr->itemnames[L], item->Name); insr->itemicons[L] = aug_weap->Icon; - } + } else { strcpy(insr->itemnames[L], item->Name); insr->itemicons[L] = item->Icon; @@ -7460,7 +7460,7 @@ void Client::SendMercPersonalInfo() uint32 altCurrentType = 19; //TODO: Implement alternate currency purchases involving mercs! MercTemplate *mercData = &zone->merc_templates[GetMercInfo().MercTemplateID]; - + int stancecount = 0; stancecount += zone->merc_stance_list[GetMercInfo().MercTemplateID].size(); if(stancecount > MAX_MERC_STANCES || mercCount > MAX_MERC || mercTypeCount > MAX_MERC_GRADES) @@ -7562,7 +7562,7 @@ void Client::SendMercPersonalInfo() } if (MERC_DEBUG > 0) Message(7, "Mercenary Debug: SendMercPersonalInfo Send Successful"); - + SendMercMerchantResponsePacket(0); } else diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 000ed8fcc..06611b413 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1472,10 +1472,10 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) /* Set Mob variables for spawn */ class_ = m_pp.class_; level = m_pp.level; - x_pos = m_pp.x; - y_pos = m_pp.y; - z_pos = m_pp.z; - heading = m_pp.heading; + m_Position.m_X = m_pp.x; + m_Position.m_Y = m_pp.y; + m_Position.m_Z = m_pp.z; + m_Position.m_Heading = m_pp.heading; race = m_pp.race; base_race = m_pp.race; gender = m_pp.gender; @@ -4380,9 +4380,9 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) float dist = 0; float tmp; - tmp = x_pos - ppu->x_pos; + tmp = m_Position.m_X - ppu->x_pos; dist += tmp*tmp; - tmp = y_pos - ppu->y_pos; + tmp = m_Position.m_Y - ppu->y_pos; dist += tmp*tmp; dist = sqrt(dist); @@ -4534,9 +4534,9 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) //If the player has moved more than units for x or y, then we'll store //his pre-PPU x and y for /rewind, in case he gets stuck. if ((rewind_x_diff > 750) || (rewind_y_diff > 750)) { - rewind_x = x_pos; - rewind_y = y_pos; - rewind_z = z_pos; + rewind_x = m_Position.m_X; + rewind_y = m_Position.m_Y; + rewind_z = m_Position.m_Z; } //If the PPU was a large jump, such as a cross zone gate or Call of Hero, @@ -4563,13 +4563,13 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) delta_z = ppu->delta_z; delta_heading = ppu->delta_heading; - if(IsTracking() && ((x_pos!=ppu->x_pos) || (y_pos!=ppu->y_pos))){ + if(IsTracking() && ((m_Position.m_X!=ppu->x_pos) || (m_Position.m_Y!=ppu->y_pos))){ if(MakeRandomFloat(0, 100) < 70)//should be good CheckIncreaseSkill(SkillTracking, nullptr, -20); } // Break Hide if moving without sneaking and set rewind timer if moved - if(ppu->y_pos != y_pos || ppu->x_pos != x_pos){ + if(ppu->y_pos != m_Position.m_Y || ppu->x_pos != m_Position.m_X){ if((hidden || improved_hidden) && !sneaking){ hidden = false; improved_hidden = false; @@ -4589,13 +4589,14 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) // Outgoing client packet float tmpheading = EQ19toFloat(ppu->heading); - if (!FCMP(ppu->y_pos, y_pos) || !FCMP(ppu->x_pos, x_pos) || !FCMP(tmpheading, heading) || ppu->animation != animation) + if (!FCMP(ppu->y_pos, m_Position.m_Y) || !FCMP(ppu->x_pos, m_Position.m_X) || !FCMP(tmpheading, m_Position.m_Heading) || ppu->animation != animation) { - x_pos = ppu->x_pos; - y_pos = ppu->y_pos; - z_pos = ppu->z_pos; - animation = ppu->animation; - heading = tmpheading; + m_Position.m_X = ppu->x_pos; + m_Position.m_Y = ppu->y_pos; + m_Position.m_Z = ppu->z_pos; + m_Position.m_Heading = tmpheading; + animation = ppu->animation; + EQApplicationPacket* outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); PlayerPositionUpdateServer_Struct* ppu = (PlayerPositionUpdateServer_Struct*)outapp->pBuffer; @@ -4609,7 +4610,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) if(zone->watermap) { - if(zone->watermap->InLiquid(x_pos, y_pos, z_pos)) + if(zone->watermap->InLiquid(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)) { CheckIncreaseSkill(SkillSwimming, nullptr, -17); } @@ -6607,7 +6608,7 @@ void Client::Handle_OP_GroupFollow2(const EQApplicationPacket *app) GroupGeneric_Struct* gf = (GroupGeneric_Struct*)app->pBuffer; Mob* inviter = entity_list.GetClientByName(gf->name1); - + // Inviter and Invitee are in the same zone if (inviter != nullptr && inviter->IsClient()) { @@ -6622,7 +6623,7 @@ void Client::Handle_OP_GroupFollow2(const EQApplicationPacket *app) { // Inviter is in another zone - Remove merc from group now if any LeaveGroup(); - + ServerPacket* pack = new ServerPacket(ServerOP_GroupFollow, sizeof(ServerGroupFollow_Struct)); ServerGroupFollow_Struct *sgfs = (ServerGroupFollow_Struct *)pack->pBuffer; sgfs->CharacterID = CharacterID(); @@ -8019,7 +8020,7 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) InspectResponse_Struct* insr = (InspectResponse_Struct*)outapp->pBuffer; Mob* tmp = entity_list.GetMob(insr->TargetID); const Item_Struct* item = nullptr; - + int ornamentationAugtype = RuleI(Character, OrnamentationAugmentType); for (int16 L = EmuConstants::EQUIPMENT_BEGIN; L <= MainWaist; L++) { const ItemInst* inst = GetInv().GetItem(L); @@ -12807,9 +12808,9 @@ void Client::Handle_OP_SwapSpell(const EQApplicationPacket *app) m_pp.spell_book[swapspell->from_slot] = m_pp.spell_book[swapspell->to_slot]; m_pp.spell_book[swapspell->to_slot] = swapspelltemp; - /* Save Spell Swaps */ + /* Save Spell Swaps */ if (!database.SaveCharacterSpell(this->CharacterID(), m_pp.spell_book[swapspell->from_slot], swapspell->from_slot)){ - database.DeleteCharacterSpell(this->CharacterID(), m_pp.spell_book[swapspell->from_slot], swapspell->from_slot); + database.DeleteCharacterSpell(this->CharacterID(), m_pp.spell_book[swapspell->from_slot], swapspell->from_slot); } if (!database.SaveCharacterSpell(this->CharacterID(), swapspelltemp, swapspell->to_slot)){ database.DeleteCharacterSpell(this->CharacterID(), swapspelltemp, swapspell->to_slot); @@ -13595,7 +13596,7 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app) } Translocate_Struct *its = (Translocate_Struct*)app->pBuffer; - if (!PendingTranslocate) + if (!PendingTranslocate) return; if ((RuleI(Spells, TranslocateTimeLimit) > 0) && (time(nullptr) > (TranslocateTime + RuleI(Spells, TranslocateTimeLimit)))) { @@ -13616,7 +13617,7 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app) // to the bind coords it has from the PlayerProfile, but with the X and Y reversed. I suspect they are // reversed in the pp, and since spells like Gate are handled serverside, this has not mattered before. if (((SpellID == 1422) || (SpellID == 1334) || (SpellID == 3243)) && - (zone->GetZoneID() == PendingTranslocateData.zone_id && + (zone->GetZoneID() == PendingTranslocateData.zone_id && zone->GetInstanceID() == PendingTranslocateData.instance_id)) { PendingTranslocate = false; @@ -13627,7 +13628,7 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app) ////Was sending the packet back to initiate client zone... ////but that could be abusable, so lets go through proper channels MovePC(PendingTranslocateData.zone_id, PendingTranslocateData.instance_id, - PendingTranslocateData.x, PendingTranslocateData.y, + PendingTranslocateData.x, PendingTranslocateData.y, PendingTranslocateData.z, PendingTranslocateData.heading, 0, ZoneSolicited); } } diff --git a/zone/client_process.cpp b/zone/client_process.cpp index c4eb01f4a..42b1316ef 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -188,7 +188,7 @@ bool Client::Process() { GetMerc()->Save(); GetMerc()->Depop(); } - + Raid *myraid = entity_list.GetRaidByClient(this); if (myraid) { @@ -581,7 +581,7 @@ bool Client::Process() { if(projectile_timer.Check()) SpellProjectileEffect(); - + if(spellbonuses.GravityEffect == 1) { if(gravity_timer.Check()) DoGravityEffect(); @@ -800,32 +800,32 @@ void Client::OnDisconnect(bool hard_disconnect) { if (MyRaid) MyRaid->MemberZoned(this); - parse->EventPlayer(EVENT_DISCONNECT, this, "", 0); + parse->EventPlayer(EVENT_DISCONNECT, this, "", 0); /* QS: PlayerLogConnectDisconnect */ if (RuleB(QueryServ, PlayerLogConnectDisconnect)){ std::string event_desc = StringFormat("Disconnect :: in zoneid:%i instid:%i", this->GetZoneID(), this->GetInstanceID()); QServ->PlayerLogEvent(Player_Log_Connect_State, this->CharacterID(), event_desc); - } + } } - Mob *Other = trade->With(); + Mob *Other = trade->With(); if(Other) { - mlog(TRADING__CLIENT, "Client disconnected during a trade. Returning their items."); + mlog(TRADING__CLIENT, "Client disconnected during a trade. Returning their items."); FinishTrade(this); if(Other->IsClient()) Other->CastToClient()->FinishTrade(Other); /* Reset both sides of the trade */ - trade->Reset(); + trade->Reset(); Other->trade->Reset(); } database.SetFirstLogon(CharacterID(), 0); //We change firstlogon status regardless of if a player logs out to zone or not, because we only want to trigger it on their first login from world. - /* Remove ourself from all proximities */ + /* Remove ourself from all proximities */ ClearAllProximities(); EQApplicationPacket *outapp = new EQApplicationPacket(OP_LogoutReply); @@ -1570,7 +1570,7 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) if (from_bucket == &m_pp.platinum_shared) amount_to_add = 0 - amount_to_take; - database.SetSharedPlatinum(AccountID(),amount_to_add); + database.SetSharedPlatinum(AccountID(),amount_to_add); } } else{ @@ -1756,7 +1756,7 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app) } SetSkill(skill, t_level); - } else { + } else { switch(skill) { case SkillBrewing: case SkillMakePoison: @@ -1958,7 +1958,7 @@ void Client::DoEnduranceUpkeep() { int upkeep_sum = 0; int cost_redux = spellbonuses.EnduranceReduction + itembonuses.EnduranceReduction + aabonuses.EnduranceReduction; - + bool has_effect = false; uint32 buffs_i; uint32 buff_count = GetMaxTotalSlots(); @@ -2144,9 +2144,9 @@ void Client::HandleRespawnFromHover(uint32 Option) if (corpse) { - x_pos = corpse->GetX(); - y_pos = corpse->GetY(); - z_pos = corpse->GetZ(); + m_Position.m_X = corpse->GetX(); + m_Position.m_Y = corpse->GetY(); + m_Position.m_Z = corpse->GetZ(); } EQApplicationPacket* outapp = new EQApplicationPacket(OP_ZonePlayerToBind, sizeof(ZonePlayerToBind_Struct) + 10); @@ -2199,10 +2199,10 @@ void Client::HandleRespawnFromHover(uint32 Option) SetMana(GetMaxMana()); SetEndurance(GetMaxEndurance()); - x_pos = chosen->x; - y_pos = chosen->y; - z_pos = chosen->z; - heading = chosen->heading; + m_Position.m_X = chosen->x; + m_Position.m_Y = chosen->y; + m_Position.m_Z = chosen->z; + m_Position.m_Heading = chosen->heading; ClearHover(); entity_list.RefreshClientXTargets(this); @@ -2212,7 +2212,7 @@ void Client::HandleRespawnFromHover(uint32 Option) //After they've respawned into the same zone, trigger EVENT_RESPAWN parse->EventPlayer(EVENT_RESPAWN, this, static_cast(itoa(Option)), is_rez ? 1 : 0); - //Pop Rez option from the respawn options list; + //Pop Rez option from the respawn options list; //easiest way to make sure it stays at the end and //doesn't disrupt adding/removing scripted options respawn_options.pop_back(); diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 8be978350..5c56be256 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -249,15 +249,15 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( 0, // uint8 in_qglobal, 0, // uint8 in_maxlevel, 0 // uint32 in_scalerate - ), + ), corpse_decay_timer(RuleI(Character, CorpseDecayTimeMS)), corpse_res_timer(RuleI(Character, CorpseResTimeMS)), corpse_delay_timer(RuleI(NPC, CorpseUnlockTimer)), corpse_graveyard_timer(RuleI(Zone, GraveyardTimeMS)), - loot_cooldown_timer(10) + loot_cooldown_timer(10) { int i; - + PlayerProfile_Struct *pp = &client->GetPP(); ItemInst *item; @@ -287,7 +287,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( platinum = 0; strcpy(orgname, pp->name); - strcpy(name, pp->name); + strcpy(name, pp->name); /* become_npc was not being initialized which led to some pretty funky things with newly created corpses */ become_npc = false; @@ -295,8 +295,8 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( SetPKItem(0); /* Check Rule to see if we can leave corpses */ - if(!RuleB(Character, LeaveNakedCorpses) || - RuleB(Character, LeaveCorpses) && + if(!RuleB(Character, LeaveNakedCorpses) || + RuleB(Character, LeaveCorpses) && GetLevel() >= RuleI(Character, DeathItemLossLevel)) { // cash // Let's not move the cash when 'RespawnFromHover = true' && 'client->GetClientVersion() < EQClientSoF' since the client doesn't. @@ -589,7 +589,7 @@ bool Corpse::Save() { ItemList::iterator cur, end; cur = itemlist.begin(); end = itemlist.end(); - for (; cur != end; ++cur) { + for (; cur != end; ++cur) { ServerLootItem_Struct* item = *cur; item->equip_slot = ServerToCorpseSlot(item->equip_slot); // temp hack until corpse blobs are removed memcpy((char*)&dbpc->items[x++], (char*)item, sizeof(ServerLootItem_Struct)); @@ -597,11 +597,11 @@ bool Corpse::Save() { /* Create New Corpse*/ if (corpse_db_id == 0) { - corpse_db_id = database.SaveCharacterCorpse(char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, x_pos, y_pos, z_pos, heading); + corpse_db_id = database.SaveCharacterCorpse(char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_Position.m_Heading); } /* Update Corpse Data */ else{ - corpse_db_id = database.UpdateCharacterCorpse(corpse_db_id, char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, x_pos, y_pos, z_pos, heading, IsRezzed()); + corpse_db_id = database.UpdateCharacterCorpse(corpse_db_id, char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_Position.m_Heading, IsRezzed()); } safe_delete_array(dbpc); @@ -611,8 +611,8 @@ bool Corpse::Save() { void Corpse::Delete() { if (IsPlayerCorpse() && corpse_db_id != 0) - database.DeleteCharacterCorpse(corpse_db_id); - + database.DeleteCharacterCorpse(corpse_db_id); + corpse_db_id = 0; player_corpse_depop = true; } @@ -717,7 +717,7 @@ void Corpse::RemoveItem(uint16 lootslot) { } void Corpse::RemoveItem(ServerLootItem_Struct* item_data){ - uint8 material; + uint8 material; ItemList::iterator cur,end; cur = itemlist.begin(); end = itemlist.end(); @@ -925,7 +925,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a } RemoveCash(); - Save(); + Save(); } outapp->priority = 6; @@ -1081,7 +1081,7 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) { } if (item != 0) { - if (item_data){ + if (item_data){ inst = database.CreateItem(item, item_data ? item_data->charges : 0, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5); } else { @@ -1156,7 +1156,7 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) { /* Delete needs to be before RemoveItem because its deletes the pointer for item_data/bag_item_data */ database.DeleteItemOffCharacterCorpse(this->corpse_db_id, item_data->equip_slot, item_data->item_id); /* Delete Item Instance */ - RemoveItem(item_data->lootslot); + RemoveItem(item_data->lootslot); } /* Remove Bag Contents */ @@ -1164,9 +1164,9 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app) { for (int i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++) { if (bag_item_data[i]) { /* Delete needs to be before RemoveItem because its deletes the pointer for item_data/bag_item_data */ - database.DeleteItemOffCharacterCorpse(this->corpse_db_id, bag_item_data[i]->equip_slot, bag_item_data[i]->item_id); + database.DeleteItemOffCharacterCorpse(this->corpse_db_id, bag_item_data[i]->equip_slot, bag_item_data[i]->item_id); /* Delete Item Instance */ - RemoveItem(bag_item_data[i]); + RemoveItem(bag_item_data[i]); } } } @@ -1241,7 +1241,7 @@ void Corpse::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { ns->spawn.NPC = 2; } -void Corpse::QueryLoot(Client* to) { +void Corpse::QueryLoot(Client* to) { int x = 0, y = 0; // x = visible items, y = total items to->Message(0, "Coin: %ip, %ig, %is, %ic", platinum, gold, silver, copper); @@ -1415,10 +1415,10 @@ void Corpse::LoadPlayerCorpseDecayTime(uint32 corpse_db_id){ /* ** Corpse slot translations are needed until corpse database blobs are converted -** +** ** To account for the addition of MainPowerSource, MainGeneral9 and MainGeneral10 into ** the contiguous possessions slot enumeration, the following designations will be used: -** +** ** Designatiom Server Corpse Offset ** -------------------------------------------------- ** MainCharm 0 0 0 @@ -1518,4 +1518,4 @@ int16 Corpse::CorpseToServerSlot(int16 corpse_slot) return corpse_slot; } */ -} \ No newline at end of file +} diff --git a/zone/forage.cpp b/zone/forage.cpp index d1008031a..24482017c 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -225,15 +225,15 @@ bool Client::CanFish() { HeadingDegrees = (int) ((GetHeading()*360)/256); HeadingDegrees = HeadingDegrees % 360; - RodX = x_pos + RodLength * sin(HeadingDegrees * M_PI/180.0f); - RodY = y_pos + RodLength * cos(HeadingDegrees * M_PI/180.0f); + RodX = m_Position.m_X + RodLength * sin(HeadingDegrees * M_PI/180.0f); + RodY = m_Position.m_Y + RodLength * cos(HeadingDegrees * M_PI/180.0f); // Do BestZ to find where the line hanging from the rod intersects the water (if it is water). // and go 1 unit into the water. Map::Vertex dest; dest.x = RodX; dest.y = RodY; - dest.z = z_pos+10; + dest.z = m_Position.m_Z+10; RodZ = zone->zonemap->FindBestZ(dest, nullptr) + 4; bool in_lava = zone->watermap->InLava(RodX, RodY, RodZ); @@ -243,7 +243,7 @@ bool Client::CanFish() { Message_StringID(MT_Skills, FISHING_LAVA); //Trying to catch a fire elemental or something? return false; } - if((!in_water) || (z_pos-RodZ)>LineLength) { //Didn't hit the water OR the water is too far below us + if((!in_water) || (m_Position.m_Z-RodZ)>LineLength) { //Didn't hit the water OR the water is too far below us Message_StringID(MT_Skills, FISHING_LAND); //Trying to catch land sharks perhaps? return false; } diff --git a/zone/mob.cpp b/zone/mob.cpp index a7d141b30..cb2f6e35d 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -157,10 +157,10 @@ Mob::Mob(const char* in_name, if (runspeed < 0 || runspeed > 20) runspeed = 1.25f; - heading = in_heading; - x_pos = in_x_pos; - y_pos = in_y_pos; - z_pos = in_z_pos; + m_Position.m_Heading = in_heading; + m_Position.m_X = in_x_pos; + m_Position.m_Y = in_y_pos; + m_Position.m_Z = in_z_pos; light = in_light; texture = in_texture; helmtexture = in_helmtexture; @@ -373,7 +373,7 @@ Mob::Mob(const char* in_name, m_targetable = true; targetring_x = 0.0f; - targetring_y = 0.0f; + targetring_y = 0.0f; targetring_z = 0.0f; flymode = FlyMode3; @@ -882,10 +882,10 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) strn0cpy(ns->spawn.lastName, lastname, sizeof(ns->spawn.lastName)); } - ns->spawn.heading = FloatToEQ19(heading); - ns->spawn.x = FloatToEQ19(x_pos);//((int32)x_pos)<<3; - ns->spawn.y = FloatToEQ19(y_pos);//((int32)y_pos)<<3; - ns->spawn.z = FloatToEQ19(z_pos);//((int32)z_pos)<<3; + ns->spawn.heading = FloatToEQ19(m_Position.m_Heading); + ns->spawn.x = FloatToEQ19(m_Position.m_X);//((int32)x_pos)<<3; + ns->spawn.y = FloatToEQ19(m_Position.m_Y);//((int32)y_pos)<<3; + ns->spawn.z = FloatToEQ19(m_Position.m_Z);//((int32)z_pos)<<3; ns->spawn.spawnId = GetID(); ns->spawn.curHp = static_cast(GetHPRatio()); ns->spawn.max_hp = 100; //this field needs a better name @@ -1211,13 +1211,13 @@ void Mob::SendPosUpdate(uint8 iSendToSelf) { void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){ memset(spu,0xff,sizeof(PlayerPositionUpdateServer_Struct)); spu->spawn_id = GetID(); - spu->x_pos = FloatToEQ19(x_pos); - spu->y_pos = FloatToEQ19(y_pos); - spu->z_pos = FloatToEQ19(z_pos); + spu->x_pos = FloatToEQ19(m_Position.m_X); + spu->y_pos = FloatToEQ19(m_Position.m_Y); + spu->z_pos = FloatToEQ19(m_Position.m_Z); spu->delta_x = NewFloatToEQ13(0); spu->delta_y = NewFloatToEQ13(0); spu->delta_z = NewFloatToEQ13(0); - spu->heading = FloatToEQ19(heading); + spu->heading = FloatToEQ19(m_Position.m_Heading); spu->animation = 0; spu->delta_heading = NewFloatToEQ13(0); spu->padding0002 =0; @@ -1230,13 +1230,13 @@ void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){ // this is for SendPosUpdate() void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) { spu->spawn_id = GetID(); - spu->x_pos = FloatToEQ19(x_pos); - spu->y_pos = FloatToEQ19(y_pos); - spu->z_pos = FloatToEQ19(z_pos); + spu->x_pos = FloatToEQ19(m_Position.m_X); + spu->y_pos = FloatToEQ19(m_Position.m_Y); + spu->z_pos = FloatToEQ19(m_Position.m_Z); spu->delta_x = NewFloatToEQ13(delta_x); spu->delta_y = NewFloatToEQ13(delta_y); spu->delta_z = NewFloatToEQ13(delta_z); - spu->heading = FloatToEQ19(heading); + spu->heading = FloatToEQ19(m_Position.m_Heading); spu->padding0002 =0; spu->padding0006 =7; spu->padding0014 =0x7f; @@ -1361,11 +1361,11 @@ void Mob::GMMove(float x, float y, float z, float heading, bool SendUpdate) { entity_list.ProcessMove(CastToNPC(), x, y, z); } - x_pos = x; - y_pos = y; - z_pos = z; - if (heading != 0.01) - this->heading = heading; + m_Position.m_X = x; + m_Position.m_Y = y; + m_Position.m_Z = z; + if (m_Position.m_Heading != 0.01) + this->m_Position.m_Heading = heading; if(IsNPC()) CastToNPC()->SaveGuardSpot(true); if(SendUpdate) @@ -2062,9 +2062,9 @@ bool Mob::CanThisClassBlock(void) const } float Mob::Dist(const Mob &other) const { - float xDiff = other.x_pos - x_pos; - float yDiff = other.y_pos - y_pos; - float zDiff = other.z_pos - z_pos; + float xDiff = other.m_Position.m_X - m_Position.m_X; + float yDiff = other.m_Position.m_Y - m_Position.m_Y; + float zDiff = other.m_Position.m_Z - m_Position.m_Z; return sqrtf( (xDiff * xDiff) + (yDiff * yDiff) @@ -2072,17 +2072,17 @@ float Mob::Dist(const Mob &other) const { } float Mob::DistNoZ(const Mob &other) const { - float xDiff = other.x_pos - x_pos; - float yDiff = other.y_pos - y_pos; + float xDiff = other.m_Position.m_X - m_Position.m_X; + float yDiff = other.m_Position.m_Y - m_Position.m_Y; return sqrtf( (xDiff * xDiff) + (yDiff * yDiff) ); } float Mob::DistNoRoot(const Mob &other) const { - float xDiff = other.x_pos - x_pos; - float yDiff = other.y_pos - y_pos; - float zDiff = other.z_pos - z_pos; + float xDiff = other.m_Position.m_X - m_Position.m_X; + float yDiff = other.m_Position.m_Y - m_Position.m_Y; + float zDiff = other.m_Position.m_Z - m_Position.m_Z; return ( (xDiff * xDiff) + (yDiff * yDiff) @@ -2090,9 +2090,9 @@ float Mob::DistNoRoot(const Mob &other) const { } float Mob::DistNoRoot(float x, float y, float z) const { - float xDiff = x - x_pos; - float yDiff = y - y_pos; - float zDiff = z - z_pos; + float xDiff = x - m_Position.m_X; + float yDiff = y - m_Position.m_Y; + float zDiff = z - m_Position.m_Z; return ( (xDiff * xDiff) + (yDiff * yDiff) @@ -2100,15 +2100,15 @@ float Mob::DistNoRoot(float x, float y, float z) const { } float Mob::DistNoRootNoZ(float x, float y) const { - float xDiff = x - x_pos; - float yDiff = y - y_pos; + float xDiff = x - m_Position.m_X; + float yDiff = y - m_Position.m_Y; return ( (xDiff * xDiff) + (yDiff * yDiff) ); } float Mob::DistNoRootNoZ(const Mob &other) const { - float xDiff = other.x_pos - x_pos; - float yDiff = other.y_pos - y_pos; + float xDiff = other.m_Position.m_X - m_Position.m_X; + float yDiff = other.m_Position.m_Y - m_Position.m_Y; return ( (xDiff * xDiff) + (yDiff * yDiff) ); } @@ -2253,7 +2253,7 @@ bool Mob::HateSummon() { entity_list.MessageClose(this, true, 500, MT_Say, "%s says,'You will not evade me, %s!' ", GetCleanName(), target->GetCleanName() ); if (target->IsClient()) { - target->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), x_pos, y_pos, z_pos, target->GetHeading(), 0, SummonPC); + target->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, target->GetHeading(), 0, SummonPC); } else { #ifdef BOTS @@ -2266,7 +2266,7 @@ bool Mob::HateSummon() { } #endif //BOTS - target->GMMove(x_pos, y_pos, z_pos, target->GetHeading()); + target->GMMove(m_Position.m_X, m_Position.m_Y, m_Position.m_Z, target->GetHeading()); } return true; @@ -2614,9 +2614,9 @@ void Mob::Warp( float x, float y, float z ) entity_list.ProcessMove(CastToNPC(), x, y, z); } - x_pos = x; - y_pos = y; - z_pos = z; + m_Position.m_X = x; + m_Position.m_Y = y; + m_Position.m_Z = z; Mob* target = GetTarget(); if (target) { @@ -2829,9 +2829,9 @@ float Mob::FindGroundZ(float new_x, float new_y, float z_offset) if (zone->zonemap != nullptr) { Map::Vertex me; - me.x = new_x; - me.y = new_y; - me.z = z_pos+z_offset; + me.x = m_Position.m_X; + me.y = m_Position.m_Y; + me.z = m_Position.m_Z + z_offset; Map::Vertex hit; float best_z = zone->zonemap->FindBestZ(me, &hit); if (best_z != -999999) @@ -2849,9 +2849,9 @@ float Mob::GetGroundZ(float new_x, float new_y, float z_offset) if (zone->zonemap != 0) { Map::Vertex me; - me.x = new_x; - me.y = new_y; - me.z = z_pos+z_offset; + me.x = m_Position.m_X; + me.y = m_Position.m_Y; + me.z = m_Position.m_Z+z_offset; Map::Vertex hit; float best_z = zone->zonemap->FindBestZ(me, &hit); if (best_z != -999999) @@ -3068,7 +3068,7 @@ bool Mob::TrySpellTrigger(Mob *target, uint32 spell_id, int effect) { if(!target || !IsValidSpell(spell_id)) return false; - + int spell_trig = 0; // Count all the percentage chances to trigger for all effects for(int i = 0; i < EFFECT_COUNT; i++) @@ -5060,7 +5060,7 @@ int32 Mob::GetSpellStat(uint32 spell_id, const char *identifier, uint8 slot) if (slot < 4){ if (id == "components") { spells[spell_id].components[slot];} - else if (id == "component_counts") {spells[spell_id].component_counts[slot];} + else if (id == "component_counts") {spells[spell_id].component_counts[slot];} else if (id == "NoexpendReagent") {spells[spell_id].NoexpendReagent[slot];} } @@ -5138,7 +5138,7 @@ int32 Mob::GetSpellStat(uint32 spell_id, const char *identifier, uint8 slot) else if (id == "max_dist") {stat = static_cast(spells[spell_id].max_dist); } else if (id == "min_range") {stat = static_cast(spells[spell_id].min_range); } else if (id == "DamageShieldType") {stat = spells[spell_id].DamageShieldType; } - + return stat; } diff --git a/zone/mob.h b/zone/mob.h index a4dd2d665..9b57bbc6a 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -23,6 +23,7 @@ #include "entity.h" #include "hate_list.h" #include "pathing.h" +#include "position.h" #include #include #include @@ -176,7 +177,7 @@ public: bool IsInvisible(Mob* other = 0) const; void SetInvisible(uint8 state); bool AttackAnimation(SkillUseTypes &skillinuse, int Hand, const ItemInst* weapon); - + //Song bool UseBardSpellLogic(uint16 spell_id = 0xffff, int slot = -1); bool ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, uint16 slot); @@ -392,10 +393,10 @@ public: ((static_cast(cur_mana) / max_mana) * 100); } virtual int32 CalcMaxMana(); uint32 GetNPCTypeID() const { return npctype_id; } - inline const float GetX() const { return x_pos; } - inline const float GetY() const { return y_pos; } - inline const float GetZ() const { return z_pos; } - inline const float GetHeading() const { return heading; } + inline const float GetX() const { return m_Position.m_X; } + inline const float GetY() const { return m_Position.m_Y; } + inline const float GetZ() const { return m_Position.m_Z; } + inline const float GetHeading() const { return m_Position.m_Heading; } inline const float GetSize() const { return size; } inline const float GetBaseSize() const { return base_size; } inline const float GetTarX() const { return tarx; } @@ -437,8 +438,8 @@ public: void MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu); void SendPosition(); void SetFlyMode(uint8 flymode); - inline void Teleport(Map::Vertex NewPosition) { x_pos = NewPosition.x; y_pos = NewPosition.y; - z_pos = NewPosition.z; }; + inline void Teleport(Map::Vertex NewPosition) { m_Position.m_X = NewPosition.x; m_Position.m_Y = NewPosition.y; + m_Position.m_Z = NewPosition.z; }; //AI static uint32 GetLevelCon(uint8 mylevel, uint8 iOtherLevel); @@ -459,8 +460,8 @@ public: bool IsEngaged() { return(!hate_list.IsEmpty()); } bool HateSummon(); void FaceTarget(Mob* MobToFace = 0); - void SetHeading(float iHeading) { if(heading != iHeading) { pLastChange = Timer::GetCurrentTime(); - heading = iHeading; } } + void SetHeading(float iHeading) { if(m_Position.m_Heading != iHeading) { pLastChange = Timer::GetCurrentTime(); + m_Position.m_Heading = iHeading; } } void WipeHateList(); void AddFeignMemory(Client* attacker); void RemoveFromFeignMemory(Client* attacker); @@ -566,10 +567,10 @@ public: int16 CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, bool best_focus=false); uint8 IsFocusEffect(uint16 spellid, int effect_index, bool AA=false,uint32 aa_effect=0); - void SendIllusionPacket(uint16 in_race, uint8 in_gender = 0xFF, uint8 in_texture = 0xFF, uint8 in_helmtexture = 0xFF, - uint8 in_haircolor = 0xFF, uint8 in_beardcolor = 0xFF, uint8 in_eyecolor1 = 0xFF, uint8 in_eyecolor2 = 0xFF, - uint8 in_hairstyle = 0xFF, uint8 in_luclinface = 0xFF, uint8 in_beard = 0xFF, uint8 in_aa_title = 0xFF, - uint32 in_drakkin_heritage = 0xFFFFFFFF, uint32 in_drakkin_tattoo = 0xFFFFFFFF, + void SendIllusionPacket(uint16 in_race, uint8 in_gender = 0xFF, uint8 in_texture = 0xFF, uint8 in_helmtexture = 0xFF, + uint8 in_haircolor = 0xFF, uint8 in_beardcolor = 0xFF, uint8 in_eyecolor1 = 0xFF, uint8 in_eyecolor2 = 0xFF, + uint8 in_hairstyle = 0xFF, uint8 in_luclinface = 0xFF, uint8 in_beard = 0xFF, uint8 in_aa_title = 0xFF, + uint32 in_drakkin_heritage = 0xFFFFFFFF, uint32 in_drakkin_tattoo = 0xFFFFFFFF, uint32 in_drakkin_details = 0xFFFFFFFF, float in_size = -1.0f); virtual void Stun(int duration); virtual void UnStun(); @@ -617,7 +618,7 @@ public: bool CanBlockSpell() const { return(spellbonuses.BlockNextSpell); } bool DoHPToManaCovert(uint16 mana_cost = 0); int32 ApplySpellEffectiveness(Mob* caster, int16 spell_id, int32 value, bool IsBard = false); - int8 GetDecayEffectValue(uint16 spell_id, uint16 spelleffect); + int8 GetDecayEffectValue(uint16 spell_id, uint16 spelleffect); int32 GetExtraSpellAmt(uint16 spell_id, int32 extra_spell_amt, int32 base_spell_dmg); void MeleeLifeTap(int32 damage); bool PassCastRestriction(bool UseCastRestriction = true, int16 value = 0, bool IsDamage = true); @@ -678,9 +679,9 @@ public: inline int16 GetTempPetCount() const { return count_TempPet; } inline void SetTempPetCount(int16 i) { count_TempPet = i; } bool HasPetAffinity() { if (aabonuses.GivePetGroupTarget || itembonuses.GivePetGroupTarget || spellbonuses.GivePetGroupTarget) return true; return false; } - inline bool IsPetOwnerClient() const { return pet_owner_client; } + inline bool IsPetOwnerClient() const { return pet_owner_client; } inline void SetPetOwnerClient(bool value) { pet_owner_client = value; } - inline bool IsTempPet() const { return _IsTempPet; } + inline bool IsTempPet() const { return _IsTempPet; } inline void SetTempPet(bool value) { _IsTempPet = value; } inline const bodyType GetBodyType() const { return bodytype; } @@ -806,7 +807,7 @@ public: void SetDontCureMeBefore(uint32 time) { pDontCureMeBefore = time; } // calculate interruption of spell via movement of mob - void SaveSpellLoc() {spell_x = x_pos; spell_y = y_pos; spell_z = z_pos; } + void SaveSpellLoc() {spell_x = m_Position.m_X; spell_y = m_Position.m_Y; spell_z = m_Position.m_Z; } inline float GetSpellX() const {return spell_x;} inline float GetSpellY() const {return spell_y;} inline float GetSpellZ() const {return spell_z;} @@ -860,7 +861,7 @@ public: Shielders_Struct shielder[MAX_SHIELDERS]; Trade* trade; - + inline float GetCWPX() const { return(cur_wp_x); } inline float GetCWPY() const { return(cur_wp_y); } inline float GetCWPZ() const { return(cur_wp_z); } @@ -998,10 +999,7 @@ protected: uint8 level; uint8 orig_level; uint32 npctype_id; - float x_pos; - float y_pos; - float z_pos; - float heading; + xyz_heading m_Position; uint16 animation; float base_size; float size; diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 614ba984d..67b0e6678 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1792,7 +1792,7 @@ void NPC::AI_DoMovement() { CP2Moved = CalculateNewPosition2(guard_x, guard_y, guard_z, walksp); else { - if(!((x_pos == guard_x) && (y_pos == guard_y) && (z_pos == guard_z))) + if(!((m_Position.m_X == guard_x) && (m_Position.m_Y == guard_y) && (m_Position.m_Z == guard_z))) { bool WaypointChanged, NodeReached; Map::Vertex Goal = UpdatePath(guard_x, guard_y, guard_z, walksp, WaypointChanged, NodeReached); diff --git a/zone/spells.cpp b/zone/spells.cpp index 69ded563c..f50d74bbf 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -297,7 +297,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, uint16 slot, sprintf(temp, "%d", spell_id); parse->EventNPC(EVENT_CAST_BEGIN, CastToNPC(), nullptr, temp, 0); } - + //To prevent NPC ghosting when spells are cast from scripts if (IsNPC() && IsMoving() && cast_time > 0) SendPosition(); @@ -1607,7 +1607,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce { if(!spell_target) return false; - + ae_center = spell_target; CastAction = AETarget; } @@ -1626,7 +1626,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce { if(!spell_target) return false; - + ae_center = spell_target; CastAction = AETarget; } @@ -2072,7 +2072,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 } else { // regular PB AE or targeted AE spell - spell_target is null if PB if(spell_target) // this must be an AETarget spell - { + { bool cast_on_target = true; if (spells[spell_id].targettype == ST_TargetAENoPlayersPets && spell_target->IsPetOwnerClient()) cast_on_target = false; @@ -2181,7 +2181,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 ConeDirectional(spell_id, resist_adjust); break; } - + case Beam: { BeamDirectional(spell_id, resist_adjust); @@ -3704,7 +3704,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r if (IsValidSpell(spells[spell_id].RecourseLink)) SpellFinished(spells[spell_id].RecourseLink, this, 10, 0, -1, spells[spells[spell_id].RecourseLink].ResistDiff); - + if (IsDetrimentalSpell(spell_id)) { CheckNumHitsRemaining(NUMHIT_OutgoingSpells); @@ -3831,9 +3831,9 @@ void Corpse::CastRezz(uint16 spellid, Mob* Caster) rezz->zone_id = zone->GetZoneID(); rezz->instance_id = zone->GetInstanceID(); rezz->spellid = spellid; - rezz->x = this->x_pos; - rezz->y = this->y_pos; - rezz->z = this->z_pos; + rezz->x = this->m_Position.m_X; + rezz->y = this->m_Position.m_Y; + rezz->z = this->m_Position.m_Z; rezz->unknown000 = 0x00000000; rezz->unknown020 = 0x00000000; rezz->unknown088 = 0x00000000; @@ -4495,7 +4495,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use if(partial_modifier <= 0) { return 100; - } + } else if(partial_modifier >= 100) { return 0; @@ -4816,7 +4816,7 @@ void Client::UnmemSpell(int slot, bool update_client) m_pp.mem_spells[slot] = 0xFFFFFFFF; database.DeleteCharacterMemorizedSpell(this->CharacterID(), m_pp.mem_spells[slot], slot); - + if(update_client) { MemorizeSpell(slot, m_pp.mem_spells[slot], memSpellForget); @@ -4860,8 +4860,8 @@ void Client::UnscribeSpell(int slot, bool update_client) mlog(CLIENT__SPELLS, "Spell %d erased from spell book slot %d", m_pp.spell_book[slot], slot); m_pp.spell_book[slot] = 0xFFFFFFFF; - - database.DeleteCharacterSpell(this->CharacterID(), m_pp.spell_book[slot], slot); + + database.DeleteCharacterSpell(this->CharacterID(), m_pp.spell_book[slot], slot); if(update_client) { EQApplicationPacket* outapp = new EQApplicationPacket(OP_DeleteSpell, sizeof(DeleteSpell_Struct)); @@ -4889,7 +4889,7 @@ void Client::UntrainDisc(int slot, bool update_client) if(slot >= MAX_PP_DISCIPLINES || slot < 0) return; - mlog(CLIENT__SPELLS, "Discipline %d untrained from slot %d", m_pp.disciplines.values[slot], slot); + mlog(CLIENT__SPELLS, "Discipline %d untrained from slot %d", m_pp.disciplines.values[slot], slot); m_pp.disciplines.values[slot] = 0; database.DeleteCharacterDisc(this->CharacterID(), slot); @@ -5438,27 +5438,27 @@ void Mob::BeamDirectional(uint16 spell_id, int16 resist_adjust) if (IsBeneficialSpell(spell_id) && IsClient()) beneficial_targets = true; - + std::list targets_in_range; std::list::iterator iter; entity_list.GetTargetsForConeArea(this, spells[spell_id].min_range, spells[spell_id].range, spells[spell_id].range / 2, targets_in_range); iter = targets_in_range.begin(); - + float dX = 0; float dY = 0; float dZ = 0; - + CalcDestFromHeading(GetHeading(), spells[spell_id].range, 5, GetX(), GetY(), dX, dY, dZ); dZ = GetZ(); - + //FIND SLOPE: Put it into the form y = mx + b float m = (dY - GetY()) / (dX - GetX()); float b = (GetY() * dX - dY * GetX()) / (dX - GetX()); - + while(iter != targets_in_range.end()) { - if (!(*iter) || (beneficial_targets && ((*iter)->IsNPC() && !(*iter)->IsPetOwnerClient())) + if (!(*iter) || (beneficial_targets && ((*iter)->IsNPC() && !(*iter)->IsPetOwnerClient())) || (*iter)->BehindMob(this, (*iter)->GetX(),(*iter)->GetY())){ ++iter; continue; @@ -5466,7 +5466,7 @@ void Mob::BeamDirectional(uint16 spell_id, int16 resist_adjust) //# shortest distance from line to target point float d = abs( (*iter)->GetY() - m * (*iter)->GetX() - b) / sqrt(m * m + 1); - + if (d <= spells[spell_id].aoerange) { if(CheckLosFN((*iter)) || spells[spell_id].npc_no_los) { @@ -5513,7 +5513,7 @@ void Mob::ConeDirectional(uint16 spell_id, int16 resist_adjust) } float heading_to_target = (CalculateHeadingToTarget((*iter)->GetX(), (*iter)->GetY()) * 360.0f / 256.0f); - + while(heading_to_target < 0.0f) heading_to_target += 360.0f; @@ -5544,4 +5544,4 @@ void Mob::ConeDirectional(uint16 spell_id, int16 resist_adjust) ++iter; } -} \ No newline at end of file +} diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index cfefe73f3..4cb3b2e84 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -437,10 +437,10 @@ void NPC::SaveGuardSpot(bool iClearGuardSpot) { guard_heading = 0; } else { - guard_x = x_pos; - guard_y = y_pos; - guard_z = z_pos; - guard_heading = heading; + guard_x = m_Position.m_X; + guard_y = m_Position.m_Y; + guard_z = m_Position.m_Z; + guard_heading = m_Position.m_Heading; if(guard_heading == 0) guard_heading = 0.0001; //hack to make IsGuarding simpler mlog(AI__WAYPOINTS, "Setting guard position to (%.3f, %.3f, %.3f)", guard_x, guard_y, guard_z); @@ -452,7 +452,7 @@ void NPC::NextGuardPosition() { SetHeading(guard_heading); mlog(AI__WAYPOINTS, "Unable to move to next guard position. Probably rooted."); } - else if((x_pos == guard_x) && (y_pos == guard_y) && (z_pos == guard_z)) + else if((m_Position.m_X == guard_x) && (m_Position.m_Y == guard_y) && (m_Position.m_Z == guard_z)) { if(moved) { @@ -480,7 +480,7 @@ void Mob::SaveSpawnSpot() { }*/ float Mob::CalculateDistance(float x, float y, float z) { - return (float)sqrtf( ((x_pos-x)*(x_pos-x)) + ((y_pos-y)*(y_pos-y)) + ((z_pos-z)*(z_pos-z)) ); + return (float)sqrtf( ((m_Position.m_X-x)*(m_Position.m_X-x)) + ((m_Position.m_Y-y)*(m_Position.m_Y-y)) + ((m_Position.m_Z-z)*(m_Position.m_Z-z)) ); } /* @@ -491,13 +491,13 @@ uint8 NPC::CalculateHeadingToNextWaypoint() { float Mob::CalculateHeadingToTarget(float in_x, float in_y) { float angle; - if (in_x-x_pos > 0) - angle = - 90 + atan((float)(in_y-y_pos) / (float)(in_x-x_pos)) * 180 / M_PI; - else if (in_x-x_pos < 0) - angle = + 90 + atan((float)(in_y-y_pos) / (float)(in_x-x_pos)) * 180 / M_PI; + if (in_x-m_Position.m_X > 0) + angle = - 90 + atan((float)(in_y-m_Position.m_Y) / (float)(in_x-m_Position.m_X)) * 180 / M_PI; + else if (in_x-m_Position.m_X < 0) + angle = + 90 + atan((float)(in_y-m_Position.m_Y) / (float)(in_x-m_Position.m_X)) * 180 / M_PI; else // Added? { - if (in_y-y_pos > 0) + if (in_y-m_Position.m_Y > 0) angle = 0; else angle = 180; @@ -513,16 +513,16 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b if(GetID()==0) return true; - if ((x_pos-x == 0) && (y_pos-y == 0)) {//spawn is at target coords - if(z_pos-z != 0) { - z_pos = z; + if ((m_Position.m_X-x == 0) && (m_Position.m_Y-y == 0)) {//spawn is at target coords + if(m_Position.m_Z-z != 0) { + m_Position.m_Z = z; mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f): Jumping pure Z.", x, y, z); return true; } mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f) inWater=%d: We are there.", x, y, z, inWater); return false; } - else if ((ABS(x_pos - x) < 0.1) && (ABS(y_pos - y) < 0.1)) + else if ((ABS(m_Position.m_X - x) < 0.1) && (ABS(m_Position.m_Y - y) < 0.1)) { mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f): X/Y difference <0.1, Jumping to target.", x, y, z); @@ -530,25 +530,25 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b entity_list.ProcessMove(CastToNPC(), x, y, z); } - x_pos = x; - y_pos = y; - z_pos = z; + m_Position.m_X = x; + m_Position.m_Y = y; + m_Position.m_Z = z; return true; } int compare_steps = IsBoat() ? 1 : 20; if(tar_ndx < compare_steps && tarx==x && tary==y) { - float new_x = x_pos + tar_vx*tar_vector; - float new_y = y_pos + tar_vy*tar_vector; - float new_z = z_pos + tar_vz*tar_vector; + float new_x = m_Position.m_X + tar_vx*tar_vector; + float new_y = m_Position.m_Y + tar_vy*tar_vector; + float new_z = m_Position.m_Z + tar_vz*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } - x_pos = new_x; - y_pos = new_y; - z_pos = new_z; + m_Position.m_X = new_x; + m_Position.m_Y = new_y; + m_Position.m_Z = new_z; mlog(AI__WAYPOINTS, "Calculating new position2 to (%.3f, %.3f, %.3f), old vector (%.3f, %.3f, %.3f)", x, y, z, tar_vx, tar_vy, tar_vz); @@ -563,25 +563,25 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) { - Map::Vertex dest(x_pos, y_pos, z_pos); + Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; - mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); + mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z); if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { - if((ABS(x - x_pos) < 0.5) && (ABS(y - y_pos) < 0.5)) + if((ABS(x - m_Position.m_X) < 0.5) && (ABS(y - m_Position.m_Y) < 0.5)) { - if(ABS(z-z_pos) <= RuleR(Map, FixPathingZMaxDeltaMoving)) - z_pos = z; + if(ABS(z-m_Position.m_Z) <= RuleR(Map, FixPathingZMaxDeltaMoving)) + m_Position.m_Z = z; else - z_pos = newz + 1; + m_Position.m_Z = newz + 1; } else - z_pos = newz + 1; + m_Position.m_Z = newz + 1; } } } @@ -600,9 +600,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b tary=y; tarz=z; - float nx = this->x_pos; - float ny = this->y_pos; - float nz = this->z_pos; + float nx = this->m_Position.m_X; + float ny = this->m_Position.m_Y; + float nz = this->m_Position.m_Z; // float nh = this->heading; tar_vx = x - nx; @@ -635,19 +635,19 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b tar_vy = tar_vy/numsteps; tar_vz = tar_vz/numsteps; - float new_x = x_pos + tar_vx; - float new_y = y_pos + tar_vy; - float new_z = z_pos + tar_vz; + float new_x = m_Position.m_X + tar_vx; + float new_y = m_Position.m_Y + tar_vy; + float new_z = m_Position.m_Z + tar_vz; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } - x_pos = new_x; - y_pos = new_y; - z_pos = new_z; + m_Position.m_X = new_x; + m_Position.m_Y = new_y; + m_Position.m_Z = new_z; + m_Position.m_Heading = CalculateHeadingToTarget(x, y); tar_ndx=22-numsteps; - heading = CalculateHeadingToTarget(x, y); - mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", x_pos, y_pos, z_pos, numsteps); + mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", m_Position.m_X, m_Position.m_Y, m_Position.m_Z, numsteps); } else { @@ -655,9 +655,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b entity_list.ProcessMove(CastToNPC(), x, y, z); } - x_pos = x; - y_pos = y; - z_pos = z; + m_Position.m_X = x; + m_Position.m_Y = y; + m_Position.m_Z = z; mlog(AI__WAYPOINTS, "Only a single step to get there... jumping."); @@ -667,18 +667,18 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b else { tar_vector/=20; - float new_x = x_pos + tar_vx*tar_vector; - float new_y = y_pos + tar_vy*tar_vector; - float new_z = z_pos + tar_vz*tar_vector; + float new_x = m_Position.m_X + tar_vx*tar_vector; + float new_y = m_Position.m_Y + tar_vy*tar_vector; + float new_z = m_Position.m_Z + tar_vz*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } - x_pos = new_x; - y_pos = new_y; - z_pos = new_z; - heading = CalculateHeadingToTarget(x, y); - mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", x_pos, y_pos, z_pos, numsteps); + m_Position.m_X = new_x; + m_Position.m_Y = new_y; + m_Position.m_Z = new_z; + m_Position.m_Heading = CalculateHeadingToTarget(x, y); + mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", m_Position.m_X, m_Position.m_Y, m_Position.m_Z, numsteps); } uint8 NPCFlyMode = 0; @@ -692,25 +692,25 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) { - Map::Vertex dest(x_pos, y_pos, z_pos); + Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); float newz = zone->zonemap->FindBestZ(dest, nullptr); + 2.0f; - mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); + mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z); if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { - if(ABS(x - x_pos) < 0.5 && ABS(y - y_pos) < 0.5) + if(ABS(x - m_Position.m_X) < 0.5 && ABS(y - m_Position.m_Y) < 0.5) { - if(ABS(z - z_pos) <= RuleR(Map, FixPathingZMaxDeltaMoving)) - z_pos = z; + if(ABS(z - m_Position.m_Z) <= RuleR(Map, FixPathingZMaxDeltaMoving)) + m_Position.m_Z = z; else - z_pos = newz + 1; + m_Position.m_Z = newz + 1; } else - z_pos = newz+1; + m_Position.m_Z = newz+1; } } } @@ -718,9 +718,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b SetMoving(true); moved=true; - delta_x=x_pos-nx; - delta_y=y_pos-ny; - delta_z=z_pos-nz; + delta_x=m_Position.m_X-nx; + delta_y=m_Position.m_Y-ny; + delta_z=m_Position.m_Z-nz; delta_heading=0; if (IsClient()) @@ -746,9 +746,9 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec if(GetID()==0) return true; - float nx = x_pos; - float ny = y_pos; - float nz = z_pos; + float nx = m_Position.m_X; + float ny = m_Position.m_Y; + float nz = m_Position.m_Z; // if NPC is rooted if (speed == 0.0) { @@ -780,30 +780,30 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec // -------------------------------------------------------------------------- test_vector=sqrtf (x*x + y*y + z*z); tar_vector = speed / sqrtf (tar_vx*tar_vx + tar_vy*tar_vy + tar_vz*tar_vz); - heading = CalculateHeadingToTarget(x, y); + m_Position.m_Heading = CalculateHeadingToTarget(x, y); if (tar_vector >= 1.0) { if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } - x_pos = x; - y_pos = y; - z_pos = z; + m_Position.m_X = x; + m_Position.m_Y = y; + m_Position.m_Z = z; mlog(AI__WAYPOINTS, "Close enough, jumping to waypoint"); } else { - float new_x = x_pos + tar_vx*tar_vector; - float new_y = y_pos + tar_vy*tar_vector; - float new_z = z_pos + tar_vz*tar_vector; + float new_x = m_Position.m_X + tar_vx*tar_vector; + float new_y = m_Position.m_Y + tar_vy*tar_vector; + float new_z = m_Position.m_Z + tar_vz*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } - x_pos = new_x; - y_pos = new_y; - z_pos = new_z; - mlog(AI__WAYPOINTS, "Next position (%.3f, %.3f, %.3f)", x_pos, y_pos, z_pos); + m_Position.m_X = new_x; + m_Position.m_Y = new_y; + m_Position.m_Z = new_z; + mlog(AI__WAYPOINTS, "Next position (%.3f, %.3f, %.3f)", m_Position.m_X, m_Position.m_Y, m_Position.m_Z); } uint8 NPCFlyMode = 0; @@ -817,25 +817,25 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) { - Map::Vertex dest(x_pos, y_pos, z_pos); + Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; - mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); + mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z); if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { - if(ABS(x - x_pos) < 0.5 && ABS(y - y_pos) < 0.5) + if(ABS(x - m_Position.m_X) < 0.5 && ABS(y - m_Position.m_Y) < 0.5) { - if(ABS(z - z_pos) <= RuleR(Map, FixPathingZMaxDeltaMoving)) - z_pos = z; + if(ABS(z - m_Position.m_Z) <= RuleR(Map, FixPathingZMaxDeltaMoving)) + m_Position.m_Z = z; else - z_pos = newz + 1; + m_Position.m_Z = newz + 1; } else - z_pos = newz+1; + m_Position.m_Z = newz+1; } } } @@ -845,9 +845,9 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec tar_ndx=0; this->SetMoving(true); moved=true; - delta_x=(x_pos-nx); - delta_y=(y_pos-ny); - delta_z=(z_pos-nz); + delta_x=(m_Position.m_X-nx); + delta_y=(m_Position.m_Y-ny); + delta_z=(m_Position.m_Z-nz); delta_heading=0;//(heading-nh)*8; SendPosUpdate(); } @@ -948,9 +948,9 @@ void Mob::SendTo(float new_x, float new_y, float new_z) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } - x_pos = new_x; - y_pos = new_y; - z_pos = new_z; + m_Position.m_X = new_x; + m_Position.m_Y = new_y; + m_Position.m_Z = new_z; mlog(AI__WAYPOINTS, "Sent To (%.3f, %.3f, %.3f)", new_x, new_y, new_z); if(flymode == FlyMode1) @@ -961,20 +961,20 @@ void Mob::SendTo(float new_x, float new_y, float new_z) { if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo) ) { if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) { - Map::Vertex dest(x_pos, y_pos, z_pos); + Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); float newz = zone->zonemap->FindBestZ(dest, nullptr); - mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); + mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z); if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check. - z_pos = newz + 1; + m_Position.m_Z = newz + 1; } } else - z_pos += 0.1; + m_Position.m_Z += 0.1; } void Mob::SendToFixZ(float new_x, float new_y, float new_z) { @@ -982,9 +982,9 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z + 0.1); } - x_pos = new_x; - y_pos = new_y; - z_pos = new_z + 0.1; + m_Position.m_X = new_x; + m_Position.m_Y = new_y; + m_Position.m_Z = new_z + 0.1; //fix up pathing Z, this shouldent be needed IF our waypoints //are corrected instead @@ -992,16 +992,16 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) { if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo)) { if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) { - Map::Vertex dest(x_pos, y_pos, z_pos); + Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); float newz = zone->zonemap->FindBestZ(dest, nullptr); - mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); + mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.m_X,m_Position.m_Y,m_Position.m_Z); if( (newz > -2000) && ABS(newz-dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check. - z_pos = newz + 1; + m_Position.m_Z = newz + 1; } } } diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 6ac85cff6..fe6bcf557 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -347,16 +347,16 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc //set the player's coordinates in the new zone so they have them //when they zone into it - x_pos = dest_x; //these coordinates will now be saved when ~client is called - y_pos = dest_y; - z_pos = dest_z; - heading = dest_h; // Cripp: fix for zone heading + m_Position.m_X = dest_x; //these coordinates will now be saved when ~client is called + m_Position.m_Y = dest_y; + m_Position.m_Z = dest_z; + m_Position.m_Heading = dest_h; // Cripp: fix for zone heading m_pp.heading = dest_h; m_pp.zone_id = zone_id; m_pp.zoneInstance = instance_id; //Force a save so its waiting for them when they zone - Save(2); + Save(2); if (zone_id == zone->GetZoneID() && instance_id == zone->GetInstanceID()) { // No need to ask worldserver if we're zoning to ourselves (most @@ -500,9 +500,9 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z SetHeading(heading); break; case GMSummon: - zonesummon_x = x_pos = x; - zonesummon_y = y_pos = y; - zonesummon_z = z_pos = z; + zonesummon_x = m_Position.m_X = x; + zonesummon_y = m_Position.m_Y = y; + zonesummon_z = m_Position.m_Z = z; SetHeading(heading); zonesummon_id = zoneID; @@ -518,31 +518,31 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z zonesummon_ignorerestrictions = ignorerestrictions; break; case GateToBindPoint: - x = x_pos = m_pp.binds[0].x; - y = y_pos = m_pp.binds[0].y; - z = z_pos = m_pp.binds[0].z; + x = m_Position.m_X = m_pp.binds[0].x; + y = m_Position.m_Y = m_pp.binds[0].y; + z = m_Position.m_Z = m_pp.binds[0].z; heading = m_pp.binds[0].heading; break; case ZoneToBindPoint: - x = x_pos = m_pp.binds[0].x; - y = y_pos = m_pp.binds[0].y; - z = z_pos = m_pp.binds[0].z; + x = m_Position.m_X = m_pp.binds[0].x; + y = m_Position.m_Y = m_pp.binds[0].y; + z = m_Position.m_Z = m_pp.binds[0].z; heading = m_pp.binds[0].heading; zonesummon_ignorerestrictions = 1; LogFile->write(EQEMuLog::Debug, "Player %s has died and will be zoned to bind point in zone: %s at LOC x=%f, y=%f, z=%f, heading=%f", GetName(), pZoneName, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, m_pp.binds[0].heading); break; case SummonPC: - zonesummon_x = x_pos = x; - zonesummon_y = y_pos = y; - zonesummon_z = z_pos = z; + zonesummon_x = m_Position.m_X = x; + zonesummon_y = m_Position.m_Y = y; + zonesummon_z = m_Position.m_Z = z; SetHeading(heading); break; case Rewind: - LogFile->write(EQEMuLog::Debug, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), x_pos, y_pos, z_pos, rewind_x, rewind_y, rewind_z, zone->GetShortName()); - zonesummon_x = x_pos = x; - zonesummon_y = y_pos = y; - zonesummon_z = z_pos = z; + LogFile->write(EQEMuLog::Debug, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, rewind_x, rewind_y, rewind_z, zone->GetShortName()); + zonesummon_x = m_Position.m_X = x; + zonesummon_y = m_Position.m_Y = y; + zonesummon_z = m_Position.m_Z = z; SetHeading(heading); break; default: @@ -652,10 +652,10 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z else { if(zoneID == GetZoneID()) { //properly handle proximities - entity_list.ProcessMove(this, x_pos, y_pos, z_pos); - proximity_x = x_pos; - proximity_y = y_pos; - proximity_z = z_pos; + entity_list.ProcessMove(this, m_Position.m_X, m_Position.m_Y, m_Position.m_Z); + proximity_x = m_Position.m_X; + proximity_y = m_Position.m_Y; + proximity_z = m_Position.m_Z; //send out updates to people in zone. SendPosition(); @@ -723,9 +723,9 @@ void Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y if (to_zone == -1) { m_pp.binds[0].zoneId = zone->GetZoneID(); m_pp.binds[0].instance_id = (zone->GetInstanceID() != 0 && zone->IsInstancePersistent()) ? zone->GetInstanceID() : 0; - m_pp.binds[0].x = x_pos; - m_pp.binds[0].y = y_pos; - m_pp.binds[0].z = z_pos; + m_pp.binds[0].x = m_Position.m_X; + m_pp.binds[0].y = m_Position.m_Y; + m_pp.binds[0].z = m_Position.m_Z; } else { m_pp.binds[0].zoneId = to_zone; From 096cbaf1bba58dfdc59022cba8cb0ce7eaaa66d9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 25 Nov 2014 20:43:09 -0800 Subject: [PATCH 003/253] delta_x, delta_y, delta_z, and int delta_heading converted to m_Delta --- zone/client_packet.cpp | 5 +---- zone/client_process.cpp | 4 +--- zone/mob.cpp | 18 ++++++------------ zone/mob.h | 7 ++----- zone/mob_ai.cpp | 5 +---- zone/waypoints.cpp | 10 ++-------- 6 files changed, 13 insertions(+), 36 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 06611b413..b81ef24ea 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4558,10 +4558,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) } // Update internal state - delta_x = ppu->delta_x; - delta_y = ppu->delta_y; - delta_z = ppu->delta_z; - delta_heading = ppu->delta_heading; + m_Delta = {ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading}; if(IsTracking() && ((m_Position.m_X!=ppu->x_pos) || (m_Position.m_Y!=ppu->y_pos))){ if(MakeRandomFloat(0, 100) < 70)//should be good diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 42b1316ef..cf106ae65 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -543,9 +543,7 @@ bool Client::Process() { else { animation = 0; - delta_x = 0; - delta_y = 0; - delta_z = 0; + m_Delta = {0.0f, 0.0f, 0.0f, m_Delta.m_Heading}; SendPosUpdate(2); } } diff --git a/zone/mob.cpp b/zone/mob.cpp index cb2f6e35d..6574d481d 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -255,10 +255,7 @@ Mob::Mob(const char* in_name, } } - delta_heading = 0; - delta_x = 0; - delta_y = 0; - delta_z = 0; + m_Delta = xyz_heading::Origin(); animation = 0; logging_enabled = false; @@ -1233,9 +1230,9 @@ void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) { spu->x_pos = FloatToEQ19(m_Position.m_X); spu->y_pos = FloatToEQ19(m_Position.m_Y); spu->z_pos = FloatToEQ19(m_Position.m_Z); - spu->delta_x = NewFloatToEQ13(delta_x); - spu->delta_y = NewFloatToEQ13(delta_y); - spu->delta_z = NewFloatToEQ13(delta_z); + spu->delta_x = NewFloatToEQ13(m_Delta.m_X); + spu->delta_y = NewFloatToEQ13(m_Delta.m_Y); + spu->delta_z = NewFloatToEQ13(m_Delta.m_Z); spu->heading = FloatToEQ19(m_Position.m_Heading); spu->padding0002 =0; spu->padding0006 =7; @@ -1245,7 +1242,7 @@ void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) { spu->animation = animation; else spu->animation = pRunAnimSpeed;//animation; - spu->delta_heading = NewFloatToEQ13(static_cast(delta_heading)); + spu->delta_heading = NewFloatToEQ13(m_Delta.m_Heading); } void Mob::ShowStats(Client* client) @@ -2947,10 +2944,7 @@ void Mob::TriggerDefensiveProcs(const ItemInst* weapon, Mob *on, uint16 hand, in } void Mob::SetDeltas(float dx, float dy, float dz, float dh) { - delta_x = dx; - delta_y = dy; - delta_z = dz; - delta_heading = static_cast(dh); + m_Delta = {dx,dy,dz,dh}; } void Mob::SetEntityVariable(const char *id, const char *m_var) diff --git a/zone/mob.h b/zone/mob.h index 9b57bbc6a..eb6e6e99f 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -421,7 +421,7 @@ public: //Movement void Warp( float x, float y, float z ); inline bool IsMoving() const { return moving; } - virtual void SetMoving(bool move) { moving = move; delta_x = 0; delta_y = 0; delta_z = 0; delta_heading = 0; } + virtual void SetMoving(bool move) { moving = move; m_Delta = xyz_heading::Origin(); } virtual void GoToBind(uint8 bindnum = 0) { } virtual void Gate(); float GetWalkspeed() const { return(_GetMovementSpeed(-47)); } @@ -1047,10 +1047,7 @@ protected: char clean_name[64]; char lastname[64]; - int32 delta_heading; - float delta_x; - float delta_y; - float delta_z; + xyz_heading m_Delta; uint8 light; diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 67b0e6678..da579a2db 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -493,10 +493,7 @@ void Mob::AI_Start(uint32 iMoveDelay) { pAssistRange = 70; hate_list.Wipe(); - delta_heading = 0; - delta_x = 0; - delta_y = 0; - delta_z = 0; + m_Delta = xyz_heading::Origin(); pRunAnimSpeed = 0; pLastChange = Timer::GetCurrentTime(); } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 4cb3b2e84..9dae8d41f 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -718,10 +718,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b SetMoving(true); moved=true; - delta_x=m_Position.m_X-nx; - delta_y=m_Position.m_Y-ny; - delta_z=m_Position.m_Z-nz; - delta_heading=0; + m_Delta = {m_Position.m_X - nx, m_Position.m_Y - ny, m_Position.m_Z - nz, 0.0f}; if (IsClient()) SendPosUpdate(1); @@ -845,10 +842,7 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec tar_ndx=0; this->SetMoving(true); moved=true; - delta_x=(m_Position.m_X-nx); - delta_y=(m_Position.m_Y-ny); - delta_z=(m_Position.m_Z-nz); - delta_heading=0;//(heading-nh)*8; + m_Delta = {m_Position.m_X - nx, m_Position.m_Y - ny, m_Position.m_Z - nz, 0.0f}; SendPosUpdate(); } tar_ndx++; From 5115a29bb77921062b43fd0d16d8080e086ee3b3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 25 Nov 2014 21:06:13 -0800 Subject: [PATCH 004/253] spell_x,spell_y, spell_z converted to m_SpellLocation, xyz_location --- zone/mob.h | 10 +++++----- zone/spells.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/zone/mob.h b/zone/mob.h index eb6e6e99f..493288c51 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -807,10 +807,10 @@ public: void SetDontCureMeBefore(uint32 time) { pDontCureMeBefore = time; } // calculate interruption of spell via movement of mob - void SaveSpellLoc() {spell_x = m_Position.m_X; spell_y = m_Position.m_Y; spell_z = m_Position.m_Z; } - inline float GetSpellX() const {return spell_x;} - inline float GetSpellY() const {return spell_y;} - inline float GetSpellZ() const {return spell_z;} + void SaveSpellLoc() {m_SpellLocation = m_Position; } + inline float GetSpellX() const {return m_SpellLocation.m_X;} + inline float GetSpellY() const {return m_SpellLocation.m_Y;} + inline float GetSpellZ() const {return m_SpellLocation.m_Z;} inline bool IsGrouped() const { return isgrouped; } void SetGrouped(bool v); inline bool IsRaidGrouped() const { return israidgrouped; } @@ -1069,7 +1069,7 @@ protected: //spell casting vars Timer spellend_timer; uint16 casting_spell_id; - float spell_x, spell_y, spell_z; + xyz_location m_SpellLocation; int attacked_count; bool delaytimer; uint16 casting_spell_targetid; diff --git a/zone/spells.cpp b/zone/spells.cpp index f50d74bbf..52bb094fa 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -350,7 +350,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, uint16 slot, casting_spell_type = type; SaveSpellLoc(); - mlog(SPELLS__CASTING, "Casting %d Started at (%.3f,%.3f,%.3f)", spell_id, spell_x, spell_y, spell_z); + mlog(SPELLS__CASTING, "Casting %d Started at (%.3f,%.3f,%.3f)", spell_id, m_SpellLocation.m_X, m_SpellLocation.m_Y, m_SpellLocation.m_Z); // if this spell doesn't require a target, or if it's an optional target // and a target wasn't provided, then it's us; unless TGB is on and this From 65ad5b5c996ff658c36b63c7ae3e8465bd540a9b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 25 Nov 2014 21:45:41 -0800 Subject: [PATCH 005/253] Removed use of initializer lists. so less pretty --- zone/client_packet.cpp | 2 +- zone/client_process.cpp | 2 +- zone/mob.cpp | 2 +- zone/position.cpp | 16 ++++++++-------- zone/waypoints.cpp | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index b81ef24ea..3c440a8ff 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4558,7 +4558,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) } // Update internal state - m_Delta = {ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading}; + m_Delta = xyz_heading(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading); if(IsTracking() && ((m_Position.m_X!=ppu->x_pos) || (m_Position.m_Y!=ppu->y_pos))){ if(MakeRandomFloat(0, 100) < 70)//should be good diff --git a/zone/client_process.cpp b/zone/client_process.cpp index cf106ae65..14f26f4df 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -543,7 +543,7 @@ bool Client::Process() { else { animation = 0; - m_Delta = {0.0f, 0.0f, 0.0f, m_Delta.m_Heading}; + m_Delta = xyz_heading(0.0f, 0.0f, 0.0f, m_Delta.m_Heading); SendPosUpdate(2); } } diff --git a/zone/mob.cpp b/zone/mob.cpp index 6574d481d..ac8baa99e 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2944,7 +2944,7 @@ void Mob::TriggerDefensiveProcs(const ItemInst* weapon, Mob *on, uint16 hand, in } void Mob::SetDeltas(float dx, float dy, float dz, float dh) { - m_Delta = {dx,dy,dz,dh}; + m_Delta = xyz_heading(dx,dy,dz,dh); } void Mob::SetEntityVariable(const char *id, const char *m_var) diff --git a/zone/position.cpp b/zone/position.cpp index 9264f18cd..4cb7dfd53 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -6,7 +6,7 @@ xy_location::xy_location(float x, float y) : } const xy_location xy_location::operator -(const xy_location& rhs) { - xy_location minus{m_X - rhs.m_X, m_Y - rhs.m_Y}; + xy_location minus(m_X - rhs.m_X, m_Y - rhs.m_Y); return minus; } @@ -54,23 +54,23 @@ xyz_heading::xyz_heading(const xy_location locationDir, float z, float heading) } xyz_heading::operator xyz_location() const { - return xyz_location{m_X,m_Y,m_Z}; + return xyz_location(m_X,m_Y,m_Z); } xyz_heading::operator xy_location() const { - return xy_location{m_X,m_Y}; + return xy_location(m_X,m_Y); } const xyz_heading xyz_heading::operator +(const xyz_location& rhs) { - return xyz_heading{m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z + rhs.m_Z, m_Heading}; + return xyz_heading(m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z + rhs.m_Z, m_Heading); } const xyz_heading xyz_heading::operator +(const xy_location& rhs) { - return xyz_heading{m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z, m_Heading}; + return xyz_heading(m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z, m_Heading); } const xyz_heading xyz_heading::operator -(const xyz_location& rhs) { - return xyz_heading{m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z, m_Heading}; + return xyz_heading(m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z, m_Heading); } @@ -87,11 +87,11 @@ xyz_location::xyz_location(double x, double y, double z) : } xyz_location::operator xy_location() const { - return xy_location{m_X, m_Y}; + return xy_location(m_X, m_Y); } const xyz_location xyz_location::operator -(const xyz_location& rhs) { - return xyz_location{m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z}; + return xyz_location(m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z); } void xyz_location::ABS_XYZ(void) { diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 9dae8d41f..f786eeb57 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -718,7 +718,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b SetMoving(true); moved=true; - m_Delta = {m_Position.m_X - nx, m_Position.m_Y - ny, m_Position.m_Z - nz, 0.0f}; + m_Delta = xyz_heading(m_Position.m_X - nx, m_Position.m_Y - ny, m_Position.m_Z - nz, 0.0f); if (IsClient()) SendPosUpdate(1); @@ -842,7 +842,7 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec tar_ndx=0; this->SetMoving(true); moved=true; - m_Delta = {m_Position.m_X - nx, m_Position.m_Y - ny, m_Position.m_Z - nz, 0.0f}; + m_Delta = xyz_heading(m_Position.m_X - nx, m_Position.m_Y - ny, m_Position.m_Z - nz, 0.0f); SendPosUpdate(); } tar_ndx++; From d25c5b1fa03282eb2576cf4f0371a3c46fd6bea9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 25 Nov 2014 23:24:17 -0800 Subject: [PATCH 006/253] cur_wp_x, cur_wp_y, cur_wp_z, cur_wp_heading replaced with m_CurrentWayPoint --- zone/mob.cpp | 4 +--- zone/mob.h | 14 ++++++-------- zone/mob_ai.cpp | 10 +++++----- zone/waypoints.cpp | 20 +++++++------------- 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index ac8baa99e..3087ccfb7 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -317,9 +317,7 @@ Mob::Mob(const char* in_name, wandertype=0; pausetype=0; cur_wp = 0; - cur_wp_x = 0; - cur_wp_y = 0; - cur_wp_z = 0; + m_CurrentWayPoint = xyz_heading::Origin(); cur_wp_pause = 0; patrol=0; follow=0; diff --git a/zone/mob.h b/zone/mob.h index 493288c51..f1e79d1a1 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -862,10 +862,10 @@ public: Shielders_Struct shielder[MAX_SHIELDERS]; Trade* trade; - inline float GetCWPX() const { return(cur_wp_x); } - inline float GetCWPY() const { return(cur_wp_y); } - inline float GetCWPZ() const { return(cur_wp_z); } - inline float GetCWPH() const { return(cur_wp_heading); } + inline float GetCWPX() const { return(m_CurrentWayPoint.m_X); } + inline float GetCWPY() const { return(m_CurrentWayPoint.m_Y); } + inline float GetCWPZ() const { return(m_CurrentWayPoint.m_Z); } + inline float GetCWPH() const { return(m_CurrentWayPoint.m_Heading); } inline float GetCWPP() const { return(static_cast(cur_wp_pause)); } inline int GetCWP() const { return(cur_wp); } void SetCurrentWP(uint16 waypoint) { cur_wp = waypoint; } @@ -1189,11 +1189,9 @@ protected: int pausetype; int cur_wp; - float cur_wp_x; - float cur_wp_y; - float cur_wp_z; + xyz_heading m_CurrentWayPoint; int cur_wp_pause; - float cur_wp_heading; + int patrol; float fear_walkto_x; diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index da579a2db..e36ffb11a 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1724,15 +1724,15 @@ void NPC::AI_DoMovement() { } // endif (movetimercompleted==true) else if (!(AIwalking_timer->Enabled())) { // currently moving - if (cur_wp_x == GetX() && cur_wp_y == GetY()) + if (m_CurrentWayPoint.m_X == GetX() && m_CurrentWayPoint.m_Y == GetY()) { // are we there yet? then stop mlog(AI__WAYPOINTS, "We have reached waypoint %d (%.3f,%.3f,%.3f) on grid %d", cur_wp, GetX(), GetY(), GetZ(), GetGrid()); SetWaypointPause(); if(GetAppearance() != eaStanding) SetAppearance(eaStanding, false); SetMoving(false); - if (cur_wp_heading >= 0.0) { - SetHeading(cur_wp_heading); + if (m_CurrentWayPoint.m_Heading >= 0.0) { + SetHeading(m_CurrentWayPoint.m_Heading); } SendPosition(); @@ -1748,12 +1748,12 @@ void NPC::AI_DoMovement() { else { // not at waypoint yet, so keep moving if(!RuleB(Pathing, AggroReturnToGrid) || !zone->pathing || (DistractedFromGrid == 0)) - CalculateNewPosition2(cur_wp_x, cur_wp_y, cur_wp_z, walksp, true); + CalculateNewPosition2(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z, walksp, true); else { bool WaypointChanged; bool NodeReached; - Map::Vertex Goal = UpdatePath(cur_wp_x, cur_wp_y, cur_wp_z, walksp, WaypointChanged, NodeReached); + Map::Vertex Goal = UpdatePath(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z, walksp, WaypointChanged, NodeReached); if(WaypointChanged) tar_ndx = 20; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index f786eeb57..678504c1c 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -122,7 +122,7 @@ void NPC::ResumeWandering() return; } - if (cur_wp_x == GetX() && cur_wp_y == GetY()) + if (m_CurrentWayPoint.m_X == GetX() && m_CurrentWayPoint.m_Y == GetY()) { // are we we at a waypoint? if so, trigger event and start to next char temp[100]; itoa(cur_wp,temp,10); //do this before updating to next waypoint @@ -201,11 +201,8 @@ void NPC::MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot) mlog(AI__WAYPOINTS, "Setting guard position to (%.3f, %.3f, %.3f)", guard_x, guard_y, guard_z); } - cur_wp_x = mtx; - cur_wp_y = mty; - cur_wp_z = mtz; + m_CurrentWayPoint = xyz_heading(mtx, mty, mtz, mth); cur_wp_pause = 0; - cur_wp_heading = mth; pLastFightingDelayMoving = 0; if(AIwalking_timer->Enabled()) AIwalking_timer->Start(100); @@ -221,26 +218,23 @@ void NPC::UpdateWaypoint(int wp_index) cur = Waypoints.begin(); cur += wp_index; - cur_wp_x = cur->x; - cur_wp_y = cur->y; - cur_wp_z = cur->z; + m_CurrentWayPoint = xyz_heading(cur->x, cur->y, cur->z, cur->heading); cur_wp_pause = cur->pause; - cur_wp_heading = cur->heading; - mlog(AI__WAYPOINTS, "Next waypoint %d: (%.3f, %.3f, %.3f, %.3f)", wp_index, cur_wp_x, cur_wp_y, cur_wp_z, cur_wp_heading); + mlog(AI__WAYPOINTS, "Next waypoint %d: (%.3f, %.3f, %.3f, %.3f)", wp_index, m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z, m_CurrentWayPoint.m_Heading); //fix up pathing Z if(zone->HasMap() && RuleB(Map, FixPathingZAtWaypoints)) { if(!RuleB(Watermap, CheckForWaterAtWaypoints) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(cur_wp_x, cur_wp_y, cur_wp_z))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z))) { - Map::Vertex dest(cur_wp_x, cur_wp_y, cur_wp_z); + Map::Vertex dest(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z); float newz = zone->zonemap->FindBestZ(dest, nullptr); if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaWaypoint)) - cur_wp_z = newz + 1; + m_CurrentWayPoint.m_Z = newz + 1; } } From cab1f986f18b5d902fdbcf98489703ac120b8e60 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 25 Nov 2014 23:44:02 -0800 Subject: [PATCH 007/253] targetring_x, targetring_y, targetring_z replaced with m_TargetRing as an xyz_location --- zone/client_packet.cpp | 8 ++------ zone/mob.cpp | 4 +--- zone/mob.h | 10 ++++------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 3c440a8ff..4c5017917 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3984,9 +3984,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app) CastSpell_Struct* castspell = (CastSpell_Struct*)app->pBuffer; - targetring_x = castspell->x_pos; - targetring_y = castspell->y_pos; - targetring_z = castspell->z_pos; + m_TargetRing = xyz_location(castspell->x_pos, castspell->y_pos, castspell->z_pos); #ifdef _EQDEBUG LogFile->write(EQEMuLog::Debug, "cs_unknown2: %u %i", (uint8)castspell->cs_unknown[0], castspell->cs_unknown[0]); @@ -4018,9 +4016,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app) return; } - targetring_x = castspell->x_pos; - targetring_y = castspell->y_pos; - targetring_z = castspell->z_pos; + m_TargetRing = xyz_location(castspell->x_pos, castspell->y_pos, castspell->z_pos); CastSpell(spell_to_cast, castspell->target_id, castspell->slot); } diff --git a/zone/mob.cpp b/zone/mob.cpp index 3087ccfb7..bc9d7885f 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -367,9 +367,7 @@ Mob::Mob(const char* in_name, nimbus_effect3 = 0; m_targetable = true; - targetring_x = 0.0f; - targetring_y = 0.0f; - targetring_z = 0.0f; + m_TargetRing = xyz_location::Origin(); flymode = FlyMode3; // Pathing diff --git a/zone/mob.h b/zone/mob.h index f1e79d1a1..a00eb56bb 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -290,9 +290,9 @@ public: inline virtual uint32 GetNimbusEffect2() const { return nimbus_effect2; } inline virtual uint32 GetNimbusEffect3() const { return nimbus_effect3; } void RemoveNimbusEffect(int effectid); - inline float GetTargetRingX() const { return targetring_x; } - inline float GetTargetRingY() const { return targetring_y; } - inline float GetTargetRingZ() const { return targetring_z; } + inline float GetTargetRingX() const { return m_TargetRing.m_X; } + inline float GetTargetRingY() const { return m_TargetRing.m_Y; } + inline float GetTargetRingZ() const { return m_TargetRing.m_Z; } inline bool HasEndurUpkeep() const { return endur_upkeep; } inline void SetEndurUpkeep(bool val) { endur_upkeep = val; } @@ -1241,9 +1241,7 @@ protected: float tar_vz; float test_vector; - float targetring_x; - float targetring_y; - float targetring_z; + xyz_location m_TargetRing; uint32 m_spellHitsLeft[38]; // Used to track which spells will have their numhits incremented when spell finishes casting, 38 Buffslots int flymode; From 09f75c09b85d8f480a89a3b66b82f506deb1f91f Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 00:56:07 -0800 Subject: [PATCH 008/253] rewind_x, rewind_y,rewind_z replaced with m_RewindLocation of type xyz_location --- zone/client_packet.cpp | 20 +++++++------------- zone/mob.cpp | 4 +--- zone/mob.h | 6 ++---- zone/zoning.cpp | 2 +- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 4c5017917..9f7d533b2 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4521,28 +4521,22 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) float rewind_x_diff = 0; float rewind_y_diff = 0; - rewind_x_diff = ppu->x_pos - rewind_x; + rewind_x_diff = ppu->x_pos - m_RewindLocation.m_X; rewind_x_diff *= rewind_x_diff; - rewind_y_diff = ppu->y_pos - rewind_y; + rewind_y_diff = ppu->y_pos - m_RewindLocation.m_Y; rewind_y_diff *= rewind_y_diff; //We only need to store updated values if the player has moved. //If the player has moved more than units for x or y, then we'll store //his pre-PPU x and y for /rewind, in case he gets stuck. - if ((rewind_x_diff > 750) || (rewind_y_diff > 750)) { - rewind_x = m_Position.m_X; - rewind_y = m_Position.m_Y; - rewind_z = m_Position.m_Z; - } + if ((rewind_x_diff > 750) || (rewind_y_diff > 750)) + m_RewindLocation = m_Position; //If the PPU was a large jump, such as a cross zone gate or Call of Hero, //just update rewind coords to the new ppu coords. This will prevent exploitation. - if ((rewind_x_diff > 5000) || (rewind_y_diff > 5000)) { - rewind_x = ppu->x_pos; - rewind_y = ppu->y_pos; - rewind_z = ppu->z_pos; - } + if ((rewind_x_diff > 5000) || (rewind_y_diff > 5000)) + m_RewindLocation = xyz_location(ppu->x_pos, ppu->y_pos, ppu->z_pos); if(proximity_timer.Check()) { entity_list.ProcessMove(this, ppu->x_pos, ppu->y_pos, ppu->z_pos); @@ -11585,7 +11579,7 @@ void Client::Handle_OP_Rewind(const EQApplicationPacket *app) Message_StringID(MT_System, REWIND_WAIT); } else { - CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), rewind_x, rewind_y, rewind_z, 0, 2, Rewind); + CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_RewindLocation.m_X, m_RewindLocation.m_Y, m_RewindLocation.m_Z, 0, 2, Rewind); rewind_timer.Start(30000, true); } } diff --git a/zone/mob.cpp b/zone/mob.cpp index bc9d7885f..5d495e84f 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -118,9 +118,7 @@ Mob::Mob(const char* in_name, AI_Init(); SetMoving(false); moved=false; - rewind_x = 0; //Stored x_pos for /rewind - rewind_y = 0; //Stored y_pos for /rewind - rewind_z = 0; //Stored z_pos for /rewind + m_RewindLocation = xyz_location::Origin(); move_tic_count = 0; _egnode = nullptr; diff --git a/zone/mob.h b/zone/mob.h index a00eb56bb..6e227763c 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1056,7 +1056,6 @@ protected: uint8 pRunAnimSpeed; bool m_is_running; - Timer attack_timer; Timer attack_dw_timer; Timer ranged_timer; @@ -1091,9 +1090,8 @@ protected: uint8 projectile_increment[MAX_SPELL_PROJECTILE]; float projectile_x[MAX_SPELL_PROJECTILE], projectile_y[MAX_SPELL_PROJECTILE], projectile_z[MAX_SPELL_PROJECTILE]; - float rewind_x; - float rewind_y; - float rewind_z; + xyz_location m_RewindLocation; + Timer rewind_timer; // Currently 3 max nimbus particle effects at a time diff --git a/zone/zoning.cpp b/zone/zoning.cpp index fe6bcf557..b05b6a6e1 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -539,7 +539,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z SetHeading(heading); break; case Rewind: - LogFile->write(EQEMuLog::Debug, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, rewind_x, rewind_y, rewind_z, zone->GetShortName()); + LogFile->write(EQEMuLog::Debug, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_RewindLocation.m_X, m_RewindLocation.m_Y, m_RewindLocation.m_Z, zone->GetShortName()); zonesummon_x = m_Position.m_X = x; zonesummon_y = m_Position.m_Y = y; zonesummon_z = m_Position.m_Z = z; From a6177859fffd33cd9f97486dd87c8fe09b9ec8e6 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 14:57:12 -0800 Subject: [PATCH 009/253] fear_walkto_x, fear_walkto_y, fear_walkto_z replaced with m_FearWalkTarget converted to xyz_location --- zone/fearpath.cpp | 12 ++---------- zone/mob.cpp | 7 +------ zone/mob.h | 4 +--- zone/mob_ai.cpp | 12 ++++++------ 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/zone/fearpath.cpp b/zone/fearpath.cpp index 47fc53a96..8addf3f9a 100644 --- a/zone/fearpath.cpp +++ b/zone/fearpath.cpp @@ -167,9 +167,7 @@ void Mob::CalculateNewFearpoint() if(Route.size() > 0) { - fear_walkto_x = Loc.x; - fear_walkto_y = Loc.y; - fear_walkto_z = Loc.z; + m_FearWalkTarget = xyz_location(Loc.x, Loc.y, Loc.z); curfp = true; mlog(PATHING__DEBUG, "Feared to node %i (%8.3f, %8.3f, %8.3f)", Node, Loc.x, Loc.y, Loc.z); @@ -199,14 +197,8 @@ void Mob::CalculateNewFearpoint() } } if (curfp) - { - fear_walkto_x = ranx; - fear_walkto_y = rany; - fear_walkto_z = ranz; - } + m_FearWalkTarget = xyz_location(ranx, rany, ranz); else //Break fear - { BuffFadeByEffect(SE_Fear); - } } diff --git a/zone/mob.cpp b/zone/mob.cpp index 5d495e84f..989f7cde1 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -98,6 +98,7 @@ Mob::Mob(const char* in_name, bardsong_timer(6000), gravity_timer(1000), viral_timer(0), + m_FearWalkTarget(-999999.0f,-999999.0f,-999999.0f), flee_timer(FLEE_CHECK_TIMER) { @@ -110,9 +111,6 @@ Mob::Mob(const char* in_name, tarx=0; tary=0; tarz=0; - fear_walkto_x = -999999; - fear_walkto_y = -999999; - fear_walkto_z = -999999; curfp = false; AI_Init(); @@ -321,9 +319,6 @@ Mob::Mob(const char* in_name, follow=0; follow_dist = 100; // Default Distance for Follow flee_mode = false; - fear_walkto_x = -999999; - fear_walkto_y = -999999; - fear_walkto_z = -999999; curfp = false; flee_timer.Start(); diff --git a/zone/mob.h b/zone/mob.h index 6e227763c..fb60240ff 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1192,9 +1192,7 @@ protected: int patrol; - float fear_walkto_x; - float fear_walkto_y; - float fear_walkto_z; + xyz_location m_FearWalkTarget; bool curfp; // Pathing diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index e36ffb11a..e2fa84560 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -785,17 +785,17 @@ void Client::AI_Process() if(AImovement_timer->Check()) { animation = GetRunspeed() * 21; // Check if we have reached the last fear point - if((ABS(GetX()-fear_walkto_x) < 0.1) && (ABS(GetY()-fear_walkto_y) <0.1)) { + if((ABS(GetX()-m_FearWalkTarget.m_X) < 0.1) && (ABS(GetY()-m_FearWalkTarget.m_Y) <0.1)) { // Calculate a new point to run to CalculateNewFearpoint(); } if(!RuleB(Pathing, Fear) || !zone->pathing) - CalculateNewPosition2(fear_walkto_x, fear_walkto_y, fear_walkto_z, GetFearSpeed(), true); + CalculateNewPosition2(m_FearWalkTarget.m_X, m_FearWalkTarget.m_Y, m_FearWalkTarget.m_Z, GetFearSpeed(), true); else { bool WaypointChanged, NodeReached; - Map::Vertex Goal = UpdatePath(fear_walkto_x, fear_walkto_y, fear_walkto_z, + Map::Vertex Goal = UpdatePath(m_FearWalkTarget.m_X, m_FearWalkTarget.m_Y, m_FearWalkTarget.m_Z, GetFearSpeed(), WaypointChanged, NodeReached); if(WaypointChanged) @@ -1053,17 +1053,17 @@ void Mob::AI_Process() { } else { if(AImovement_timer->Check()) { // Check if we have reached the last fear point - if((ABS(GetX()-fear_walkto_x) < 0.1) && (ABS(GetY()-fear_walkto_y) <0.1)) { + if((ABS(GetX()-m_FearWalkTarget.m_X) < 0.1) && (ABS(GetY()-m_FearWalkTarget.m_Y) <0.1)) { // Calculate a new point to run to CalculateNewFearpoint(); } if(!RuleB(Pathing, Fear) || !zone->pathing) - CalculateNewPosition2(fear_walkto_x, fear_walkto_y, fear_walkto_z, GetFearSpeed(), true); + CalculateNewPosition2(m_FearWalkTarget.m_X, m_FearWalkTarget.m_Y, m_FearWalkTarget.m_Z, GetFearSpeed(), true); else { bool WaypointChanged, NodeReached; - Map::Vertex Goal = UpdatePath(fear_walkto_x, fear_walkto_y, fear_walkto_z, + Map::Vertex Goal = UpdatePath(m_FearWalkTarget.m_X, m_FearWalkTarget.m_Y, m_FearWalkTarget.m_Z, GetFearSpeed(), WaypointChanged, NodeReached); if(WaypointChanged) From 75543e68e3f86d58432a3f130d8fdfc1cba0d84b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 15:10:49 -0800 Subject: [PATCH 010/253] tarx, tary, tarz converted to m_TargetLocation as xyz_location --- zone/mob.cpp | 4 +--- zone/mob.h | 10 ++++------ zone/waypoints.cpp | 6 ++---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 989f7cde1..3e617511b 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -99,6 +99,7 @@ Mob::Mob(const char* in_name, gravity_timer(1000), viral_timer(0), m_FearWalkTarget(-999999.0f,-999999.0f,-999999.0f), + m_TargetLocation(0.0f, 0.0f, 0.0f), flee_timer(FLEE_CHECK_TIMER) { @@ -108,9 +109,6 @@ Mob::Mob(const char* in_name, tar_vx=0; tar_vy=0; tar_vz=0; - tarx=0; - tary=0; - tarz=0; curfp = false; AI_Init(); diff --git a/zone/mob.h b/zone/mob.h index fb60240ff..d3b72fdcf 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -399,9 +399,9 @@ public: inline const float GetHeading() const { return m_Position.m_Heading; } inline const float GetSize() const { return size; } inline const float GetBaseSize() const { return base_size; } - inline const float GetTarX() const { return tarx; } - inline const float GetTarY() const { return tary; } - inline const float GetTarZ() const { return tarz; } + inline const float GetTarX() const { return m_TargetLocation.m_X; } + inline const float GetTarY() const { return m_TargetLocation.m_Y; } + inline const float GetTarZ() const { return m_TargetLocation.m_Z; } inline const float GetTarVX() const { return tar_vx; } inline const float GetTarVY() const { return tar_vy; } inline const float GetTarVZ() const { return tar_vz; } @@ -1227,9 +1227,7 @@ protected: bool pet_owner_client; //Flags regular and pets as belonging to a client EGNode *_egnode; //the EG node we are in - float tarx; - float tary; - float tarz; + xyz_location m_TargetLocation; uint8 tar_ndx; float tar_vector; float tar_vx; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 678504c1c..7a407cd9f 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -531,7 +531,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b } int compare_steps = IsBoat() ? 1 : 20; - if(tar_ndx < compare_steps && tarx==x && tary==y) { + if(tar_ndx < compare_steps && m_TargetLocation.m_X==x && m_TargetLocation.m_Y==y) { float new_x = m_Position.m_X + tar_vx*tar_vector; float new_y = m_Position.m_Y + tar_vy*tar_vector; @@ -590,9 +590,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b } else { tar_ndx=0; } - tarx=x; - tary=y; - tarz=z; + m_TargetLocation = xyz_location(x, y, z); float nx = this->m_Position.m_X; float ny = this->m_Position.m_Y; From 408fdc71781b79ba1704d4ec5b62c29128f43f40 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 15:58:29 -0800 Subject: [PATCH 011/253] tarv_x, tarv_y. tarv_z converted to xyz_location --- zone/mob.cpp | 6 ++--- zone/mob.h | 10 ++++----- zone/waypoints.cpp | 56 +++++++++++++++++++++++----------------------- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 3e617511b..4db71440c 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -99,16 +99,14 @@ Mob::Mob(const char* in_name, gravity_timer(1000), viral_timer(0), m_FearWalkTarget(-999999.0f,-999999.0f,-999999.0f), - m_TargetLocation(0.0f, 0.0f, 0.0f), + m_TargetLocation(xyz_location::Origin()), + m_TargetV(xyz_location::Origin()), flee_timer(FLEE_CHECK_TIMER) { targeted = 0; tar_ndx=0; tar_vector=0; - tar_vx=0; - tar_vy=0; - tar_vz=0; curfp = false; AI_Init(); diff --git a/zone/mob.h b/zone/mob.h index d3b72fdcf..bbab7eaa5 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -402,9 +402,9 @@ public: inline const float GetTarX() const { return m_TargetLocation.m_X; } inline const float GetTarY() const { return m_TargetLocation.m_Y; } inline const float GetTarZ() const { return m_TargetLocation.m_Z; } - inline const float GetTarVX() const { return tar_vx; } - inline const float GetTarVY() const { return tar_vy; } - inline const float GetTarVZ() const { return tar_vz; } + inline const float GetTarVX() const { return m_TargetV.m_X; } + inline const float GetTarVY() const { return m_TargetV.m_Y; } + inline const float GetTarVZ() const { return m_TargetV.m_Z; } inline const float GetTarVector() const { return tar_vector; } inline const uint8 GetTarNDX() const { return tar_ndx; } bool IsBoat() const; @@ -1230,9 +1230,7 @@ protected: xyz_location m_TargetLocation; uint8 tar_ndx; float tar_vector; - float tar_vx; - float tar_vy; - float tar_vz; + xyz_location m_TargetV; float test_vector; xyz_location m_TargetRing; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 7a407cd9f..306714260 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -533,9 +533,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b int compare_steps = IsBoat() ? 1 : 20; if(tar_ndx < compare_steps && m_TargetLocation.m_X==x && m_TargetLocation.m_Y==y) { - float new_x = m_Position.m_X + tar_vx*tar_vector; - float new_y = m_Position.m_Y + tar_vy*tar_vector; - float new_z = m_Position.m_Z + tar_vz*tar_vector; + float new_x = m_Position.m_X + m_TargetV.m_X*tar_vector; + float new_y = m_Position.m_Y + m_TargetV.m_Y*tar_vector; + float new_z = m_Position.m_Z + m_TargetV.m_Z*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } @@ -544,7 +544,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b m_Position.m_Y = new_y; m_Position.m_Z = new_z; - mlog(AI__WAYPOINTS, "Calculating new position2 to (%.3f, %.3f, %.3f), old vector (%.3f, %.3f, %.3f)", x, y, z, tar_vx, tar_vy, tar_vz); + mlog(AI__WAYPOINTS, "Calculating new position2 to (%.3f, %.3f, %.3f), old vector (%.3f, %.3f, %.3f)", x, y, z, m_TargetV.m_X, m_TargetV.m_Y, m_TargetV.m_Z); uint8 NPCFlyMode = 0; @@ -597,19 +597,19 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b float nz = this->m_Position.m_Z; // float nh = this->heading; - tar_vx = x - nx; - tar_vy = y - ny; - tar_vz = z - nz; + m_TargetV.m_X = x - nx; + m_TargetV.m_Y = y - ny; + m_TargetV.m_Z = z - nz; //pRunAnimSpeed = (int8)(speed*NPC_RUNANIM_RATIO); //speed *= NPC_SPEED_MULTIPLIER; - mlog(AI__WAYPOINTS, "Calculating new position2 to (%.3f, %.3f, %.3f), new vector (%.3f, %.3f, %.3f) rate %.3f, RAS %d", x, y, z, tar_vx, tar_vy, tar_vz, speed, pRunAnimSpeed); + mlog(AI__WAYPOINTS, "Calculating new position2 to (%.3f, %.3f, %.3f), new vector (%.3f, %.3f, %.3f) rate %.3f, RAS %d", x, y, z, m_TargetV.m_X, m_TargetV.m_Y, m_TargetV.m_Z, speed, pRunAnimSpeed); // -------------------------------------------------------------------------- // 2: get unit vector // -------------------------------------------------------------------------- - float mag = sqrtf (tar_vx*tar_vx + tar_vy*tar_vy + tar_vz*tar_vz); + float mag = sqrtf (m_TargetV.m_X*m_TargetV.m_X + m_TargetV.m_Y*m_TargetV.m_Y + m_TargetV.m_Z*m_TargetV.m_Z); tar_vector = speed / mag; // mob move fix @@ -622,14 +622,14 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b { if (numsteps>1) { - tar_vector=1.0f ; - tar_vx = tar_vx/numsteps; - tar_vy = tar_vy/numsteps; - tar_vz = tar_vz/numsteps; + tar_vector=1.0f ; + m_TargetV.m_X = m_TargetV.m_X/numsteps; + m_TargetV.m_Y = m_TargetV.m_Y/numsteps; + m_TargetV.m_Z = m_TargetV.m_Z/numsteps; - float new_x = m_Position.m_X + tar_vx; - float new_y = m_Position.m_Y + tar_vy; - float new_z = m_Position.m_Z + tar_vz; + float new_x = m_Position.m_X + m_TargetV.m_X; + float new_y = m_Position.m_Y + m_TargetV.m_Y; + float new_z = m_Position.m_Z + m_TargetV.m_Z; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } @@ -659,9 +659,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b else { tar_vector/=20; - float new_x = m_Position.m_X + tar_vx*tar_vector; - float new_y = m_Position.m_Y + tar_vy*tar_vector; - float new_z = m_Position.m_Z + tar_vz*tar_vector; + float new_x = m_Position.m_X + m_TargetV.m_X*tar_vector; + float new_y = m_Position.m_Y + m_TargetV.m_Y*tar_vector; + float new_z = m_Position.m_Z + m_TargetV.m_Z*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } @@ -753,22 +753,22 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec } float old_test_vector=test_vector; - tar_vx = x - nx; - tar_vy = y - ny; - tar_vz = z - nz; + m_TargetV.m_X = x - nx; + m_TargetV.m_Y = y - ny; + m_TargetV.m_Z = z - nz; - if (tar_vx == 0 && tar_vy == 0) + if (m_TargetV.m_X == 0 && m_TargetV.m_Y == 0) return false; pRunAnimSpeed = (uint8)(speed*NPC_RUNANIM_RATIO); speed *= NPC_SPEED_MULTIPLIER; - mlog(AI__WAYPOINTS, "Calculating new position to (%.3f, %.3f, %.3f) vector (%.3f, %.3f, %.3f) rate %.3f RAS %d", x, y, z, tar_vx, tar_vy, tar_vz, speed, pRunAnimSpeed); + mlog(AI__WAYPOINTS, "Calculating new position to (%.3f, %.3f, %.3f) vector (%.3f, %.3f, %.3f) rate %.3f RAS %d", x, y, z, m_TargetV.m_X, m_TargetV.m_Y, m_TargetV.m_Z, speed, pRunAnimSpeed); // -------------------------------------------------------------------------- // 2: get unit vector // -------------------------------------------------------------------------- test_vector=sqrtf (x*x + y*y + z*z); - tar_vector = speed / sqrtf (tar_vx*tar_vx + tar_vy*tar_vy + tar_vz*tar_vz); + tar_vector = speed / sqrtf (m_TargetV.m_X*m_TargetV.m_X + m_TargetV.m_Y*m_TargetV.m_Y + m_TargetV.m_Z*m_TargetV.m_Z); m_Position.m_Heading = CalculateHeadingToTarget(x, y); if (tar_vector >= 1.0) { @@ -782,9 +782,9 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec mlog(AI__WAYPOINTS, "Close enough, jumping to waypoint"); } else { - float new_x = m_Position.m_X + tar_vx*tar_vector; - float new_y = m_Position.m_Y + tar_vy*tar_vector; - float new_z = m_Position.m_Z + tar_vz*tar_vector; + float new_x = m_Position.m_X + m_TargetV.m_X*tar_vector; + float new_y = m_Position.m_Y + m_TargetV.m_Y*tar_vector; + float new_z = m_Position.m_Z + m_TargetV.m_Z*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } From f63c5ab6ba4e9220bcfbeb3ee900098208db904a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 17:21:33 -0800 Subject: [PATCH 012/253] Added overloads for to_string to handle xyz_heading, xyz_location, and xy_location --- zone/position.cpp | 15 +++++++++++++++ zone/position.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/zone/position.cpp b/zone/position.cpp index 4cb7dfd53..a5f0cf5f1 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -1,4 +1,6 @@ #include "position.h" +#include +#include "../common/string_util.h" xy_location::xy_location(float x, float y) : m_X(x), @@ -104,3 +106,16 @@ void xyz_location::ABS_XYZ(void) { if (m_Z < 0) m_Z = -m_Z; } + +std::string to_string(const xyz_heading &position) { + return StringFormat("(%.3f, %.3f, %.3f, %.3f)", position.m_X,position.m_Y,position.m_Z,position.m_Heading); +} + +std::string to_string(const xyz_location &position){ + return StringFormat("(%.3f, %.3f, %.3f)", position.m_X,position.m_Y,position.m_Z); +} + +std::string to_string(const xy_location &position){ + return StringFormat("(%.3f, %.3f)", position.m_X,position.m_Y); +} + diff --git a/zone/position.h b/zone/position.h index 6258e901f..900d2cdfe 100644 --- a/zone/position.h +++ b/zone/position.h @@ -18,6 +18,8 @@ #ifndef POSITION_H #define POSITION_H +#include + class xy_location { public: float m_X; @@ -76,5 +78,8 @@ public: bool isOrigin() const { return m_X == 0.0f && m_Y == 0.0f && m_Z == 0.0f;} }; +std::string to_string(const xyz_heading &position); +std::string to_string(const xyz_location &position); +std::string to_string(const xy_location &position); #endif From d9d89ba9b340dceba6d36f62df81cb40faea5dca Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 17:34:45 -0800 Subject: [PATCH 013/253] GetCWPX(), GetCWPY(), GetCWPZ(), GetCWPH() converted to GetCurrentWayPoint --- zone/command.cpp | 60 +++++++++++++++++++++++------------------------ zone/lua_mob.cpp | 32 ++++++++++++------------- zone/mob.h | 5 +--- zone/perl_mob.cpp | 10 ++++---- 4 files changed, 52 insertions(+), 55 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 27516d5a5..37d252698 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -2551,7 +2551,7 @@ void command_peekinv(Client *c, const Seperator *sep) peekTrade = 0x20, peekWorld = 0x40 } ; - + if (!c->GetTarget() || !c->GetTarget()->IsClient()) { c->Message(0, "You must have a PC target selected for this command"); return; @@ -2605,10 +2605,10 @@ void command_peekinv(Client *c, const Seperator *sep) instMain = targetClient->GetInv().GetItem(MainPowerSource); itemData = (instMain ? instMain->GetItem() : nullptr); itemLinkCore = nullptr; - + if (itemData) c->MakeItemLink(itemLinkCore, instMain); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instMain->GetItem()->Name, 0x12) : "null"); c->Message((itemData == 0), "WornSlot: %i, Item: %i (%s), Charges: %i", @@ -2625,9 +2625,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instMain); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instMain->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), "InvSlot: %i, Item: %i (%s), Charges: %i", indexMain, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instMain->GetCharges())); @@ -2640,9 +2640,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instSub); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instSub->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), " InvBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", Inventory::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instSub->GetCharges())); @@ -2665,9 +2665,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instMain); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instMain->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), "CursorSlot: %i, Depth: %i, Item: %i (%s), Charges: %i", MainCursor, cursorDepth, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instMain->GetCharges())); @@ -2680,9 +2680,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instSub); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instSub->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), " CursorBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", Inventory::CalcSlotId(MainCursor, indexSub), MainCursor, indexSub, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instSub->GetCharges())); @@ -2700,9 +2700,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instMain); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instMain->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), "TributeSlot: %i, Item: %i (%s), Charges: %i", indexMain, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instMain->GetCharges())); @@ -2717,9 +2717,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instMain); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instMain->GetItem()->Name, 0x12) : "null" ); - + c->Message((itemData == 0), "BankSlot: %i, Item: %i (%s), Charges: %i", indexMain, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instMain->GetCharges())); @@ -2732,9 +2732,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instSub); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instSub->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), " BankBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", Inventory::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instSub->GetCharges())); @@ -2749,9 +2749,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instMain); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instMain->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), "SharedBankSlot: %i, Item: %i (%s), Charges: %i", indexMain, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instMain->GetCharges())); @@ -2764,9 +2764,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instSub); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instSub->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), " SharedBankBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", Inventory::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instSub->GetCharges())); @@ -2782,9 +2782,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instMain); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instMain->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), "TradeSlot: %i, Item: %i (%s), Charges: %i", indexMain, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instMain->GetCharges())); @@ -2797,9 +2797,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instSub); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instSub->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), " TradeBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", Inventory::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instSub->GetCharges())); @@ -2824,9 +2824,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instMain); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instMain->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), "WorldSlot: %i, Item: %i (%s), Charges: %i", (EmuConstants::WORLD_BEGIN + indexMain), ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instMain->GetCharges())); @@ -2839,9 +2839,9 @@ void command_peekinv(Client *c, const Seperator *sep) if (itemData) c->MakeItemLink(itemLinkCore, instSub); - + itemLink = (itemLinkCore ? StringFormat("%c%s%s%c", 0x12, itemLinkCore, instSub->GetItem()->Name, 0x12) : "null"); - + c->Message((itemData == 0), " WorldBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", INVALID_INDEX, indexMain, indexSub, ((itemData == 0) ? 0 : itemData->ID), itemLink.c_str(), ((itemData == 0) ? 0 : instSub->GetCharges())); @@ -7590,7 +7590,7 @@ void command_pf(Client *c, const Seperator *sep) { Mob *who = c->GetTarget(); c->Message(0, "POS: (%.2f, %.2f, %.2f)", who->GetX(), who->GetY(), who->GetZ()); - c->Message(0, "WP: (%.2f, %.2f, %.2f) (%d/%d)", who->GetCWPX(), who->GetCWPY(), who->GetCWPZ(), who->GetCWP(), who->IsNPC()?who->CastToNPC()->GetMaxWp():-1); + c->Message(0, "WP: %s (%d/%d)", to_string(who->GetCurrentWayPoint()).c_str(), who->IsNPC()?who->CastToNPC()->GetMaxWp():-1); c->Message(0, "TAR: (%.2f, %.2f, %.2f)", who->GetTarX(), who->GetTarY(), who->GetTarZ()); c->Message(0, "TARV: (%.2f, %.2f, %.2f)", who->GetTarVX(), who->GetTarVY(), who->GetTarVZ()); c->Message(0, "|TV|=%.2f index=%d", who->GetTarVector(), who->GetTarNDX()); diff --git a/zone/lua_mob.cpp b/zone/lua_mob.cpp index 50a8b50a7..089f311bf 100644 --- a/zone/lua_mob.cpp +++ b/zone/lua_mob.cpp @@ -626,7 +626,7 @@ double Lua_Mob::ResistSpell(int resist_type, int spell_id, Lua_Mob caster, bool return self->ResistSpell(resist_type, spell_id, caster, use_resist_override, resist_override); } -double Lua_Mob::ResistSpell(int resist_type, int spell_id, Lua_Mob caster, bool use_resist_override, int resist_override, +double Lua_Mob::ResistSpell(int resist_type, int spell_id, Lua_Mob caster, bool use_resist_override, int resist_override, bool charisma_check) { Lua_Safe_Call_Real(); return self->ResistSpell(resist_type, spell_id, caster, use_resist_override, resist_override, charisma_check); @@ -669,22 +669,22 @@ double Lua_Mob::GetHeading() { double Lua_Mob::GetWaypointX() { Lua_Safe_Call_Real(); - return self->GetCWPX(); + return self->GetCurrentWayPoint().m_X; } double Lua_Mob::GetWaypointY() { Lua_Safe_Call_Real(); - return self->GetCWPY(); + return self->GetCurrentWayPoint().m_Y; } double Lua_Mob::GetWaypointZ() { Lua_Safe_Call_Real(); - return self->GetCWPZ(); + return self->GetCurrentWayPoint().m_Z; } double Lua_Mob::GetWaypointH() { Lua_Safe_Call_Real(); - return self->GetCWPH(); + return self->GetCurrentWayPoint().m_Heading; } double Lua_Mob::GetWaypointPause() { @@ -772,19 +772,19 @@ bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, in return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot)); } -bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, +bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, int timer_duration) { Lua_Safe_Call_Bool(); - return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot), + return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot), static_cast(timer), static_cast(timer_duration)); } -bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, +bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, int timer_duration, int resist_adjust) { Lua_Safe_Call_Bool(); int16 res = resist_adjust; - return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot), + return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot), static_cast(timer), static_cast(timer_duration), 0, &res); } @@ -836,7 +836,7 @@ Lua_Mob Lua_Mob::GetOwner() { Lua_HateList Lua_Mob::GetHateList() { Lua_Safe_Call_Class(Lua_HateList); Lua_HateList ret; - + auto h_list = self->GetHateList(); auto iter = h_list.begin(); while(iter != h_list.end()) { @@ -1217,7 +1217,7 @@ bool Lua_Mob::EntityVariableExists(const char *name) { void Lua_Mob::Signal(uint32 id) { Lua_Safe_Call_Void(); - + if(self->IsClient()) { self->CastToClient()->Signal(id); } else if(self->IsNPC()) { @@ -1250,7 +1250,7 @@ void Lua_Mob::DoSpecialAttackDamage(Lua_Mob other, int skill, int max_damage, in self->DoSpecialAttackDamage(other, static_cast(skill), max_damage, min_damage, hate_override, reuse_time); } -void Lua_Mob::DoSpecialAttackDamage(Lua_Mob other, int skill, int max_damage, int min_damage, int hate_override, int reuse_time, +void Lua_Mob::DoSpecialAttackDamage(Lua_Mob other, int skill, int max_damage, int min_damage, int hate_override, int reuse_time, bool hit_chance) { Lua_Safe_Call_Void(); self->DoSpecialAttackDamage(other, static_cast(skill), max_damage, min_damage, hate_override, reuse_time, hit_chance); @@ -1281,7 +1281,7 @@ void Lua_Mob::DoThrowingAttackDmg(Lua_Mob other, Lua_ItemInst range_weapon, Lua_ self->DoThrowingAttackDmg(other, range_weapon, item, weapon_damage, chance_mod); } -void Lua_Mob::DoThrowingAttackDmg(Lua_Mob other, Lua_ItemInst range_weapon, Lua_Item item, int weapon_damage, int chance_mod, +void Lua_Mob::DoThrowingAttackDmg(Lua_Mob other, Lua_ItemInst range_weapon, Lua_Item item, int weapon_damage, int chance_mod, int focus) { Lua_Safe_Call_Void(); self->DoThrowingAttackDmg(other, range_weapon, item, weapon_damage, chance_mod, focus); @@ -1332,7 +1332,7 @@ void Lua_Mob::DoArcheryAttackDmg(Lua_Mob other, Lua_ItemInst range_weapon, Lua_I self->DoArcheryAttackDmg(other, range_weapon, ammo, weapon_damage, chance_mod); } -void Lua_Mob::DoArcheryAttackDmg(Lua_Mob other, Lua_ItemInst range_weapon, Lua_ItemInst ammo, int weapon_damage, int chance_mod, +void Lua_Mob::DoArcheryAttackDmg(Lua_Mob other, Lua_ItemInst range_weapon, Lua_ItemInst ammo, int weapon_damage, int chance_mod, int focus) { Lua_Safe_Call_Void(); self->DoArcheryAttackDmg(other, range_weapon, ammo, weapon_damage, chance_mod, focus); @@ -1390,7 +1390,7 @@ void Lua_Mob::ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double void Lua_Mob::ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle, double tilt, double arc) { Lua_Safe_Call_Void(); - self->ProjectileAnimation(to, item_id, is_arrow, static_cast(speed), static_cast(angle), static_cast(tilt), + self->ProjectileAnimation(to, item_id, is_arrow, static_cast(speed), static_cast(angle), static_cast(tilt), static_cast(arc)); } @@ -1630,7 +1630,7 @@ void Lua_Mob::SendSpellEffect(uint32 effect_id, uint32 duration, uint32 finish_d self->SendSpellEffect(effect_id, duration, finish_delay, zone_wide, unk020, perm_effect); } -void Lua_Mob::SendSpellEffect(uint32 effect_id, uint32 duration, uint32 finish_delay, bool zone_wide, uint32 unk020, bool perm_effect, +void Lua_Mob::SendSpellEffect(uint32 effect_id, uint32 duration, uint32 finish_delay, bool zone_wide, uint32 unk020, bool perm_effect, Lua_Client c) { Lua_Safe_Call_Void(); self->SendSpellEffect(effect_id, duration, finish_delay, zone_wide, unk020, perm_effect, c); diff --git a/zone/mob.h b/zone/mob.h index bbab7eaa5..57da56de5 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -862,10 +862,7 @@ public: Shielders_Struct shielder[MAX_SHIELDERS]; Trade* trade; - inline float GetCWPX() const { return(m_CurrentWayPoint.m_X); } - inline float GetCWPY() const { return(m_CurrentWayPoint.m_Y); } - inline float GetCWPZ() const { return(m_CurrentWayPoint.m_Z); } - inline float GetCWPH() const { return(m_CurrentWayPoint.m_Heading); } + inline xyz_heading GetCurrentWayPoint() const { return m_CurrentWayPoint; } inline float GetCWPP() const { return(static_cast(cur_wp_pause)); } inline int GetCWP() const { return(cur_wp); } void SetCurrentWP(uint16 waypoint) { cur_wp = waypoint; } diff --git a/zone/perl_mob.cpp b/zone/perl_mob.cpp index c47b463d3..f41685a1c 100644 --- a/zone/perl_mob.cpp +++ b/zone/perl_mob.cpp @@ -1615,7 +1615,7 @@ XS(XS_Mob_TypesTempPet) else Perl_croak(aTHX_ "target is not of type Mob"); - + if (items < 7) sticktarg = false; else { @@ -3525,7 +3525,7 @@ XS(XS_Mob_GetWaypointX) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetCWPX(); + RETVAL = THIS->GetCurrentWayPoint().m_X; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -3551,7 +3551,7 @@ XS(XS_Mob_GetWaypointY) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetCWPY(); + RETVAL = THIS->GetCurrentWayPoint().m_Y; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -3577,7 +3577,7 @@ XS(XS_Mob_GetWaypointZ) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetCWPZ(); + RETVAL = THIS->GetCurrentWayPoint().m_Z; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -3603,7 +3603,7 @@ XS(XS_Mob_GetWaypointH) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetCWPH(); + RETVAL = THIS->GetCurrentWayPoint().m_Heading; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); From f9e65acf78477cc022fa2070f7bfbb5ee11f2204 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 19:18:06 -0800 Subject: [PATCH 014/253] InWater(y,x,z) converted to InWater(xyz_location) --- zone/command.cpp | 6 ++++-- zone/forage.cpp | 19 ++++++++++--------- zone/water_map.h | 7 ++++--- zone/water_map_v2.cpp | 9 +++++---- zone/water_map_v2.h | 4 ++-- zone/waypoints.cpp | 15 ++++++++------- 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 37d252698..ed551b183 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -7632,15 +7632,17 @@ void command_bestz(Client *c, const Seperator *sep) { if(c->GetTarget()) { z=c->GetTarget()->GetZ(); + auto position = xyz_location(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z); RegionType = zone->watermap->ReturnRegionType(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z); - c->Message(0,"InWater returns %d", zone->watermap->InWater(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z)); + c->Message(0,"InWater returns %d", zone->watermap->InWater(position)); c->Message(0,"InLava returns %d", zone->watermap->InLava(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z)); } else { z=c->GetZ(); + auto position = xyz_location(c->GetX(), c->GetY(), z); RegionType = zone->watermap->ReturnRegionType(c->GetX(), c->GetY(), z); - c->Message(0,"InWater returns %d", zone->watermap->InWater(c->GetX(), c->GetY(), z)); + c->Message(0,"InWater returns %d", zone->watermap->InWater(position)); c->Message(0,"InLava returns %d", zone->watermap->InLava(c->GetX(), c->GetY(), z)); } diff --git a/zone/forage.cpp b/zone/forage.cpp index 24482017c..ad4959ec5 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -216,7 +216,8 @@ bool Client::CanFish() { } if(zone->zonemap != nullptr && zone->watermap != nullptr && RuleB(Watermap, CheckForWaterWhenFishing)) { - float RodX, RodY, RodZ; + + xyz_location rodPosition; // Tweak Rod and LineLength if required const float RodLength = RuleR(Watermap, FishingRodLength); const float LineLength = RuleR(Watermap, FishingLineLength); @@ -225,25 +226,25 @@ bool Client::CanFish() { HeadingDegrees = (int) ((GetHeading()*360)/256); HeadingDegrees = HeadingDegrees % 360; - RodX = m_Position.m_X + RodLength * sin(HeadingDegrees * M_PI/180.0f); - RodY = m_Position.m_Y + RodLength * cos(HeadingDegrees * M_PI/180.0f); + rodPosition.m_X = m_Position.m_X + RodLength * sin(HeadingDegrees * M_PI/180.0f); + rodPosition.m_Y = m_Position.m_Y + RodLength * cos(HeadingDegrees * M_PI/180.0f); // Do BestZ to find where the line hanging from the rod intersects the water (if it is water). // and go 1 unit into the water. Map::Vertex dest; - dest.x = RodX; - dest.y = RodY; + dest.x = rodPosition.m_X; + dest.y = rodPosition.m_Y; dest.z = m_Position.m_Z+10; - RodZ = zone->zonemap->FindBestZ(dest, nullptr) + 4; - bool in_lava = zone->watermap->InLava(RodX, RodY, RodZ); - bool in_water = zone->watermap->InWater(RodX, RodY, RodZ) || zone->watermap->InVWater(RodX, RodY, RodZ); + rodPosition.m_Z = zone->zonemap->FindBestZ(dest, nullptr) + 4; + bool in_lava = zone->watermap->InLava(rodPosition.m_X, rodPosition.m_Y, rodPosition.m_Z); + bool in_water = zone->watermap->InWater(rodPosition) || zone->watermap->InVWater(rodPosition.m_X, rodPosition.m_Y, rodPosition.m_Z); //Message(0, "Rod is at %4.3f, %4.3f, %4.3f, InWater says %d, InLava says %d", RodX, RodY, RodZ, in_water, in_lava); if (in_lava) { Message_StringID(MT_Skills, FISHING_LAVA); //Trying to catch a fire elemental or something? return false; } - if((!in_water) || (m_Position.m_Z-RodZ)>LineLength) { //Didn't hit the water OR the water is too far below us + if((!in_water) || (m_Position.m_Z-rodPosition.m_Z)>LineLength) { //Didn't hit the water OR the water is too far below us Message_StringID(MT_Skills, FISHING_LAND); //Trying to catch land sharks perhaps? return false; } diff --git a/zone/water_map.h b/zone/water_map.h index 2141a3000..0e5ccc141 100644 --- a/zone/water_map.h +++ b/zone/water_map.h @@ -2,6 +2,7 @@ #define EQEMU_WATER_MAP_H #include "../common/types.h" +#include "position.h" #include enum WaterRegionType { @@ -22,14 +23,14 @@ class WaterMap public: WaterMap() { } ~WaterMap() { } - + static WaterMap* LoadWaterMapfile(std::string zone_name); virtual WaterRegionType ReturnRegionType(float y, float x, float z) const { return RegionTypeNormal; } - virtual bool InWater(float y, float x, float z) const { return false; } + virtual bool InWater(const xyz_location& location) const { return false; } virtual bool InVWater(float y, float x, float z) const { return false; } virtual bool InLava(float y, float x, float z) const { return false; } virtual bool InLiquid(float y, float x, float z) const { return false; } - + protected: virtual bool Load(FILE *fp) { return false; } }; diff --git a/zone/water_map_v2.cpp b/zone/water_map_v2.cpp index 29823b96c..b08c9ca89 100644 --- a/zone/water_map_v2.cpp +++ b/zone/water_map_v2.cpp @@ -17,8 +17,8 @@ WaterRegionType WaterMapV2::ReturnRegionType(float y, float x, float z) const { return RegionTypeNormal; } -bool WaterMapV2::InWater(float y, float x, float z) const { - return ReturnRegionType(y, x, z) == RegionTypeWater; +bool WaterMapV2::InWater(const xyz_location& location) const { + return ReturnRegionType(location.m_Y, location.m_X, location.m_Z) == RegionTypeWater; } bool WaterMapV2::InVWater(float y, float x, float z) const { @@ -30,7 +30,8 @@ bool WaterMapV2::InLava(float y, float x, float z) const { } bool WaterMapV2::InLiquid(float y, float x, float z) const { - return InWater(y, x, z) || InLava(y, x, z); + auto location = xyz_location(y, x, z); + return InWater(location) || InLava(y, x, z); } bool WaterMapV2::Load(FILE *fp) { @@ -106,7 +107,7 @@ bool WaterMapV2::Load(FILE *fp) { return false; } - regions.push_back(std::make_pair((WaterRegionType)region_type, + regions.push_back(std::make_pair((WaterRegionType)region_type, OrientedBoundingBox(glm::vec3(x, y, z), glm::vec3(x_rot, y_rot, z_rot), glm::vec3(x_scale, y_scale, z_scale), glm::vec3(x_extent, y_extent, z_extent)))); } diff --git a/zone/water_map_v2.h b/zone/water_map_v2.h index 726e6a798..eef514af5 100644 --- a/zone/water_map_v2.h +++ b/zone/water_map_v2.h @@ -13,11 +13,11 @@ public: ~WaterMapV2(); virtual WaterRegionType ReturnRegionType(float y, float x, float z) const; - virtual bool InWater(float y, float x, float z) const; + virtual bool InWater(const xyz_location& location) const; virtual bool InVWater(float y, float x, float z) const; virtual bool InLava(float y, float x, float z) const; virtual bool InLiquid(float y, float x, float z) const; - + protected: virtual bool Load(FILE *fp); diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 306714260..6f4b3e90a 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -227,7 +227,7 @@ void NPC::UpdateWaypoint(int wp_index) { if(!RuleB(Watermap, CheckForWaterAtWaypoints) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_CurrentWayPoint))) { Map::Vertex dest(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z); @@ -557,7 +557,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X))) { Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); @@ -684,7 +684,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position))) { Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); @@ -806,7 +806,7 @@ bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool chec if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position))) { Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); @@ -900,8 +900,9 @@ void NPC::AssignWaypoints(int32 grid) { if(zone->HasMap() && RuleB(Map, FixPathingZWhenLoading) ) { + auto positon = xyz_location(newwp.x,newwp.y,newwp.z); if(!RuleB(Watermap, CheckWaypointsInWaterWhenLoading) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(newwp.x, newwp.y, newwp.z))) + (zone->HasWaterMap() && !zone->watermap->InWater(positon))) { Map::Vertex dest(newwp.x, newwp.y, newwp.z); @@ -947,7 +948,7 @@ void Mob::SendTo(float new_x, float new_y, float new_z) { if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo) ) { if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position))) { Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); @@ -978,7 +979,7 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) { if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo)) { if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(m_Position.m_X, m_Position.m_Y, m_Position.m_Z))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_Position))) { Map::Vertex dest(m_Position.m_X, m_Position.m_Y, m_Position.m_Z); From c0faaa9c208e6cd8303dcf2c05c435fab888ff2d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 19:20:41 -0800 Subject: [PATCH 015/253] ReturnRegionType converted to xyz_location --- zone/command.cpp | 4 ++-- zone/water_map.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index ed551b183..5f4d16aaf 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -7633,7 +7633,7 @@ void command_bestz(Client *c, const Seperator *sep) { if(c->GetTarget()) { z=c->GetTarget()->GetZ(); auto position = xyz_location(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z); - RegionType = zone->watermap->ReturnRegionType(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z); + RegionType = zone->watermap->ReturnRegionType(position); c->Message(0,"InWater returns %d", zone->watermap->InWater(position)); c->Message(0,"InLava returns %d", zone->watermap->InLava(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z)); @@ -7641,7 +7641,7 @@ void command_bestz(Client *c, const Seperator *sep) { else { z=c->GetZ(); auto position = xyz_location(c->GetX(), c->GetY(), z); - RegionType = zone->watermap->ReturnRegionType(c->GetX(), c->GetY(), z); + RegionType = zone->watermap->ReturnRegionType(position); c->Message(0,"InWater returns %d", zone->watermap->InWater(position)); c->Message(0,"InLava returns %d", zone->watermap->InLava(c->GetX(), c->GetY(), z)); diff --git a/zone/water_map.h b/zone/water_map.h index 0e5ccc141..6d5b70443 100644 --- a/zone/water_map.h +++ b/zone/water_map.h @@ -25,7 +25,7 @@ public: ~WaterMap() { } static WaterMap* LoadWaterMapfile(std::string zone_name); - virtual WaterRegionType ReturnRegionType(float y, float x, float z) const { return RegionTypeNormal; } + virtual WaterRegionType ReturnRegionType(const xyz_location& location) const { return RegionTypeNormal; } virtual bool InWater(const xyz_location& location) const { return false; } virtual bool InVWater(float y, float x, float z) const { return false; } virtual bool InLava(float y, float x, float z) const { return false; } From d8692c1dc7ad5bcc98c3a143d025ea666b9f33b3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 19:22:41 -0800 Subject: [PATCH 016/253] InVWater converted to xyz_location --- zone/forage.cpp | 2 +- zone/water_map.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/forage.cpp b/zone/forage.cpp index ad4959ec5..34bfdbc12 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -238,7 +238,7 @@ bool Client::CanFish() { rodPosition.m_Z = zone->zonemap->FindBestZ(dest, nullptr) + 4; bool in_lava = zone->watermap->InLava(rodPosition.m_X, rodPosition.m_Y, rodPosition.m_Z); - bool in_water = zone->watermap->InWater(rodPosition) || zone->watermap->InVWater(rodPosition.m_X, rodPosition.m_Y, rodPosition.m_Z); + bool in_water = zone->watermap->InWater(rodPosition) || zone->watermap->InVWater(rodPosition); //Message(0, "Rod is at %4.3f, %4.3f, %4.3f, InWater says %d, InLava says %d", RodX, RodY, RodZ, in_water, in_lava); if (in_lava) { Message_StringID(MT_Skills, FISHING_LAVA); //Trying to catch a fire elemental or something? diff --git a/zone/water_map.h b/zone/water_map.h index 6d5b70443..d8428a6ef 100644 --- a/zone/water_map.h +++ b/zone/water_map.h @@ -27,7 +27,7 @@ public: static WaterMap* LoadWaterMapfile(std::string zone_name); virtual WaterRegionType ReturnRegionType(const xyz_location& location) const { return RegionTypeNormal; } virtual bool InWater(const xyz_location& location) const { return false; } - virtual bool InVWater(float y, float x, float z) const { return false; } + virtual bool InVWater(const xyz_location& location) const { return false; } virtual bool InLava(float y, float x, float z) const { return false; } virtual bool InLiquid(float y, float x, float z) const { return false; } From 29573d7d19fe323acd9b21e41e4da7d3062e7b80 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 19:24:28 -0800 Subject: [PATCH 017/253] InLava converted to xyz_location --- zone/command.cpp | 4 ++-- zone/forage.cpp | 2 +- zone/water_map.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 5f4d16aaf..7499edd6b 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -7635,7 +7635,7 @@ void command_bestz(Client *c, const Seperator *sep) { auto position = xyz_location(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z); RegionType = zone->watermap->ReturnRegionType(position); c->Message(0,"InWater returns %d", zone->watermap->InWater(position)); - c->Message(0,"InLava returns %d", zone->watermap->InLava(c->GetTarget()->GetX(), c->GetTarget()->GetY(), z)); + c->Message(0,"InLava returns %d", zone->watermap->InLava(position)); } else { @@ -7643,7 +7643,7 @@ void command_bestz(Client *c, const Seperator *sep) { auto position = xyz_location(c->GetX(), c->GetY(), z); RegionType = zone->watermap->ReturnRegionType(position); c->Message(0,"InWater returns %d", zone->watermap->InWater(position)); - c->Message(0,"InLava returns %d", zone->watermap->InLava(c->GetX(), c->GetY(), z)); + c->Message(0,"InLava returns %d", zone->watermap->InLava(position)); } diff --git a/zone/forage.cpp b/zone/forage.cpp index 34bfdbc12..459fee6a7 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -237,7 +237,7 @@ bool Client::CanFish() { dest.z = m_Position.m_Z+10; rodPosition.m_Z = zone->zonemap->FindBestZ(dest, nullptr) + 4; - bool in_lava = zone->watermap->InLava(rodPosition.m_X, rodPosition.m_Y, rodPosition.m_Z); + bool in_lava = zone->watermap->InLava(rodPosition); bool in_water = zone->watermap->InWater(rodPosition) || zone->watermap->InVWater(rodPosition); //Message(0, "Rod is at %4.3f, %4.3f, %4.3f, InWater says %d, InLava says %d", RodX, RodY, RodZ, in_water, in_lava); if (in_lava) { diff --git a/zone/water_map.h b/zone/water_map.h index d8428a6ef..82de8cc2d 100644 --- a/zone/water_map.h +++ b/zone/water_map.h @@ -28,7 +28,7 @@ public: virtual WaterRegionType ReturnRegionType(const xyz_location& location) const { return RegionTypeNormal; } virtual bool InWater(const xyz_location& location) const { return false; } virtual bool InVWater(const xyz_location& location) const { return false; } - virtual bool InLava(float y, float x, float z) const { return false; } + virtual bool InLava(const xyz_location& location) const { return false; } virtual bool InLiquid(float y, float x, float z) const { return false; } protected: From 6cd614a05e0a81d1cf7df9fb79d7cde171f17935 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 19:32:46 -0800 Subject: [PATCH 018/253] InLiquid converted to xyz_location --- zone/attack.cpp | 197 +++++++++++++++++++++-------------------- zone/client_packet.cpp | 9 +- zone/hate_list.cpp | 18 ++-- zone/mob_ai.cpp | 3 +- zone/pathing.cpp | 8 +- zone/water_map.h | 2 +- 6 files changed, 119 insertions(+), 118 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 51b8bb26a..271a94f53 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -274,21 +274,21 @@ bool Mob::CheckHitChance(Mob* other, SkillUseTypes skillinuse, int Hand, int16 c } //Avoidance Bonuses on defender decreases baseline hit chance by percent. - avoidanceBonus = defender->spellbonuses.AvoidMeleeChanceEffect + - defender->itembonuses.AvoidMeleeChanceEffect + + avoidanceBonus = defender->spellbonuses.AvoidMeleeChanceEffect + + defender->itembonuses.AvoidMeleeChanceEffect + defender->aabonuses.AvoidMeleeChanceEffect + (defender->itembonuses.AvoidMeleeChance / 10.0f); //Item Mod 'Avoidence' Mob *owner = nullptr; - if (defender->IsPet()) + if (defender->IsPet()) owner = defender->GetOwner(); else if ((defender->IsNPC() && defender->CastToNPC()->GetSwarmOwner())) owner = entity_list.GetMobID(defender->CastToNPC()->GetSwarmOwner()); - + if (owner) avoidanceBonus += owner->aabonuses.PetAvoidance + owner->spellbonuses.PetAvoidance + owner->itembonuses.PetAvoidance; - if(defender->IsNPC()) + if(defender->IsNPC()) avoidanceBonus += (defender->CastToNPC()->GetAvoidanceRating() / 10.0f); //Modifier from database //Hit Chance Bonuses on attacker increases baseline hit chance by percent. @@ -312,7 +312,7 @@ bool Mob::CheckHitChance(Mob* other, SkillUseTypes skillinuse, int Hand, int16 c if(attacker->IsNPC()) hitBonus += (attacker->CastToNPC()->GetAccuracyRating() / 10.0f); //Modifier from database - + if(skillinuse == SkillArchery) hitBonus -= hitBonus*RuleR(Combat, ArcheryHitPenalty); @@ -332,7 +332,7 @@ bool Mob::CheckHitChance(Mob* other, SkillUseTypes skillinuse, int Hand, int16 c else if(chancetohit < RuleR(Combat,MinChancetoHit)) { chancetohit = RuleR(Combat,MinChancetoHit); } - + //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 @@ -568,7 +568,7 @@ void Mob::MeleeMitigation(Mob *attacker, int32 &damage, int32 minhit, ExtraAttac armor = (armor / RuleR(Combat, NPCACFactor)); Mob *owner = nullptr; - if (IsPet()) + if (IsPet()) owner = GetOwner(); else if ((CastToNPC()->GetSwarmOwner())) owner = entity_list.GetMobID(CastToNPC()->GetSwarmOwner()); @@ -1302,9 +1302,9 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b } else { //we hit, try to avoid it other->AvoidDamage(this, damage); other->MeleeMitigation(this, damage, min_hit, opts); - if(damage > 0) + if(damage > 0) CommonOutgoingHitSuccess(other, damage, skillinuse); - + mlog(COMBAT__DAMAGE, "Final damage after all reductions: %d", damage); } @@ -1437,7 +1437,7 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att if(dead) return false; //cant die more than once... - if(!spell) + if(!spell) spell = SPELL_UNKNOWN; char buffer[48] = { 0 }; @@ -1462,7 +1462,7 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att #1: Send death packet to everyone */ uint8 killed_level = GetLevel(); - + SendLogoutPackets(); /* Make self become corpse packet */ @@ -1675,8 +1675,8 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att if(LeftCorpse && (GetClientVersionBit() & BIT_SoFAndLater) && RuleB(Character, RespawnFromHover)) { - ClearDraggedCorpses(); - RespawnFromHoverTimer.Start(RuleI(Character, RespawnFromHoverTimer) * 1000); + ClearDraggedCorpses(); + RespawnFromHoverTimer.Start(RuleI(Character, RespawnFromHoverTimer) * 1000); SendRespawnBinds(); } else @@ -1693,19 +1693,19 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att if(r) r->MemberZoned(this); - dead_timer.Start(5000, true); + dead_timer.Start(5000, true); m_pp.zone_id = m_pp.binds[0].zoneId; m_pp.zoneInstance = m_pp.binds[0].instance_id; - database.MoveCharacterToZone(this->CharacterID(), database.GetZoneName(m_pp.zone_id)); - Save(); + database.MoveCharacterToZone(this->CharacterID(), database.GetZoneName(m_pp.zone_id)); + Save(); GoToDeath(); } /* QS: PlayerLogDeaths */ if (RuleB(QueryServ, PlayerLogDeaths)){ const char * killer_name = ""; - if (killerMob && killerMob->GetCleanName()){ killer_name = killerMob->GetCleanName(); } - std::string event_desc = StringFormat("Died in zoneid:%i instid:%i by '%s', spellid:%i, damage:%i", this->GetZoneID(), this->GetInstanceID(), killer_name, spell, damage); + if (killerMob && killerMob->GetCleanName()){ killer_name = killerMob->GetCleanName(); } + std::string event_desc = StringFormat("Died in zoneid:%i instid:%i by '%s', spellid:%i, damage:%i", this->GetZoneID(), this->GetInstanceID(), killer_name, spell, damage); QServ->PlayerLogEvent(Player_Log_Deaths, this->CharacterID(), event_desc); } @@ -1864,7 +1864,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool mlog(COMBAT__DAMAGE, "Damage (%d) is above max (%d). Setting to max.", damage, (max_dmg+eleBane)); damage = (max_dmg+eleBane); } - + damage = mod_npc_damage(damage, skillinuse, Hand, weapon, other); int32 hate = damage; @@ -1943,7 +1943,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool return false; MeleeLifeTap(damage); - + CommonBreakInvisible(); //I doubt this works... @@ -1952,15 +1952,15 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool if(!bRiposte && !other->HasDied()) { TryWeaponProc(nullptr, weapon, other, Hand); //no weapon - + if (!other->HasDied()) TrySpellProc(nullptr, weapon, other, Hand); - + if (damage > 0 && HasSkillProcSuccess() && !other->HasDied()) TrySkillProc(other, skillinuse, 0, true, Hand); } - if(GetHP() > 0 && !other->HasDied()) + if(GetHP() > 0 && !other->HasDied()) TriggerDefensiveProcs(nullptr, other, Hand, damage); // now check ripostes @@ -2020,7 +2020,7 @@ void NPC::Damage(Mob* other, int32 damage, uint16 spell_id, SkillUseTypes attack bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack_skill) { mlog(COMBAT__HITS, "Fatal blow dealt by %s with %d damage, spell %d, skill %d", killerMob->GetName(), damage, spell, attack_skill); - + Mob *oos = nullptr; if(killerMob) { oos = killerMob->GetOwnerOrSelf(); @@ -2075,7 +2075,7 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack if(p_depop == true) return false; - + HasAISpellEffects = false; BuffFadeAll(); uint8 killed_level = GetLevel(); @@ -2248,7 +2248,7 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack parse->EventNPC(EVENT_KILLED_MERIT, this, give_exp_client, "killed", 0); if(RuleB(NPC, EnableMeritBasedFaction)) - give_exp_client->SetFactionLevel(give_exp_client->CharacterID(), GetNPCFactionID(), give_exp_client->GetBaseClass(), + give_exp_client->SetFactionLevel(give_exp_client->CharacterID(), GetNPCFactionID(), give_exp_client->GetBaseClass(), give_exp_client->GetBaseRace(), give_exp_client->GetDeity()); mod_npc_killed_merit(give_exp_client); @@ -2410,9 +2410,9 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack } void Mob::AddToHateList(Mob* other, int32 hate, int32 damage, bool iYellForHelp, bool bFrenzy, bool iBuffTic) { - + assert(other != nullptr); - + if (other == this) return; @@ -2429,12 +2429,12 @@ void Mob::AddToHateList(Mob* other, int32 hate, int32 damage, bool iYellForHelp, if(other){ AddRampage(other); int hatemod = 100 + other->spellbonuses.hatemod + other->itembonuses.hatemod + other->aabonuses.hatemod; - + int32 shieldhatemod = other->spellbonuses.ShieldEquipHateMod + other->itembonuses.ShieldEquipHateMod + other->aabonuses.ShieldEquipHateMod; if (shieldhatemod && other->HasShieldEquiped()) hatemod += shieldhatemod; - + if(hatemod < 1) hatemod = 1; hate = ((hate * (hatemod))/100); @@ -2451,7 +2451,7 @@ void Mob::AddToHateList(Mob* other, int32 hate, int32 damage, bool iYellForHelp, if (other->IsNPC() && (other->IsPet() || other->CastToNPC()->GetSwarmOwner() > 0)) TryTriggerOnValueAmount(false, false, false, true); - + if(IsClient() && !IsAIControlled()) return; @@ -2478,8 +2478,9 @@ void Mob::AddToHateList(Mob* other, int32 hate, int32 damage, bool iYellForHelp, } } + auto otherPosition = xyz_location(other->GetX(), other->GetY(), other->GetZ()); if(IsNPC() && CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) { - if(!zone->watermap->InLiquid(other->GetX(), other->GetY(), other->GetZ())) { + if(!zone->watermap->InLiquid(otherPosition)) { return; } } @@ -2493,9 +2494,9 @@ void Mob::AddToHateList(Mob* other, int32 hate, int32 damage, bool iYellForHelp, if(damage > GetHP()) damage = GetHP(); - if (spellbonuses.ImprovedTaunt[1] && (GetLevel() < spellbonuses.ImprovedTaunt[0]) + if (spellbonuses.ImprovedTaunt[1] && (GetLevel() < spellbonuses.ImprovedTaunt[0]) && other && (buffs[spellbonuses.ImprovedTaunt[2]].casterid != other->GetID())) - hate = (hate*spellbonuses.ImprovedTaunt[1])/100; + hate = (hate*spellbonuses.ImprovedTaunt[1])/100; hate_list.Add(other, hate, damage, bFrenzy, !iBuffTic); @@ -3141,7 +3142,7 @@ int32 Mob::ReduceDamage(int32 damage) slot = spellbonuses.NegateAttacks[1]; if(slot >= 0) { if(--buffs[slot].numhits == 0) { - + if(!TryFadeEffect(slot)) BuffFadeBySlot(slot , true); } @@ -3156,8 +3157,8 @@ int32 Mob::ReduceDamage(int32 damage) //Only mitigate if damage is above the minimium specified. if (spellbonuses.MeleeThresholdGuard[0]){ slot = spellbonuses.MeleeThresholdGuard[1]; - - if (slot >= 0 && (damage > spellbonuses.MeleeThresholdGuard[2])) + + if (slot >= 0 && (damage > spellbonuses.MeleeThresholdGuard[2])) { DisableMeleeRune = true; int damage_to_reduce = damage * spellbonuses.MeleeThresholdGuard[0] / 100; @@ -3188,7 +3189,7 @@ int32 Mob::ReduceDamage(int32 damage) if (spellbonuses.MitigateMeleeRune[2] && (damage_to_reduce > spellbonuses.MitigateMeleeRune[2])) damage_to_reduce = spellbonuses.MitigateMeleeRune[2]; - + if(spellbonuses.MitigateMeleeRune[3] && (damage_to_reduce >= buffs[slot].melee_rune)) { mlog(SPELLS__EFFECT_VALUES, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d" @@ -3201,10 +3202,10 @@ int32 Mob::ReduceDamage(int32 damage) { mlog(SPELLS__EFFECT_VALUES, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d" " damage remaining.", damage_to_reduce, buffs[slot].melee_rune); - + if (spellbonuses.MitigateMeleeRune[3]) buffs[slot].melee_rune = (buffs[slot].melee_rune - damage_to_reduce); - + damage -= damage_to_reduce; } } @@ -3235,7 +3236,7 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi slot = spellbonuses.NegateAttacks[1]; if(slot >= 0) { if(--buffs[slot].numhits == 0) { - + if(!TryFadeEffect(slot)) BuffFadeBySlot(slot , true); } @@ -3250,7 +3251,7 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi // If this is a DoT, use DoT Shielding... if(iBuffTic) { damage -= (damage * itembonuses.DoTShielding / 100); - + if (spellbonuses.MitigateDotRune[0]){ slot = spellbonuses.MitigateDotRune[1]; if(slot >= 0) @@ -3270,7 +3271,7 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi { if (spellbonuses.MitigateDotRune[3]) buffs[slot].dot_rune = (buffs[slot].dot_rune - damage_to_reduce); - + damage -= damage_to_reduce; } } @@ -3283,12 +3284,12 @@ 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. damage -= (damage * itembonuses.SpellShield / 100); - + //Only mitigate if damage is above the minimium specified. if (spellbonuses.SpellThresholdGuard[0]){ slot = spellbonuses.SpellThresholdGuard[1]; - - if (slot >= 0 && (damage > spellbonuses.MeleeThresholdGuard[2])) + + if (slot >= 0 && (damage > spellbonuses.MeleeThresholdGuard[2])) { DisableSpellRune = true; int damage_to_reduce = damage * spellbonuses.SpellThresholdGuard[0] / 100; @@ -3305,8 +3306,8 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi } } } - - + + // Do runes now. if (spellbonuses.MitigateSpellRune[0] && !DisableSpellRune){ slot = spellbonuses.MitigateSpellRune[1]; @@ -3329,10 +3330,10 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi { mlog(SPELLS__EFFECT_VALUES, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d" " damage remaining.", damage_to_reduce, buffs[slot].magic_rune); - + if (spellbonuses.MitigateSpellRune[3]) buffs[slot].magic_rune = (buffs[slot].magic_rune - damage_to_reduce); - + damage -= damage_to_reduce; } } @@ -3340,14 +3341,14 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi if(damage < 1) return 0; - + //Regular runes absorb spell damage (except dots) - Confirmed on live. if (spellbonuses.MeleeRune[0] && spellbonuses.MeleeRune[1] >= 0) - damage = RuneAbsorb(damage, SE_Rune); + damage = RuneAbsorb(damage, SE_Rune); if (spellbonuses.AbsorbMagicAtt[0] && spellbonuses.AbsorbMagicAtt[1] >= 0) damage = RuneAbsorb(damage, SE_AbsorbMagicAtt); - + if(damage < 1) return 0; } @@ -3367,7 +3368,7 @@ int32 Mob::ReduceAllDamage(int32 damage) TryTriggerOnValueAmount(false, true); } } - + CheckNumHitsRemaining(NUMHIT_IncomingDamage); return(damage); @@ -3454,7 +3455,7 @@ bool Client::CheckDoubleAttack(bool tripleAttack) { } bool Client::CheckDoubleRangedAttack() { - + int32 chance = spellbonuses.DoubleRangedAttack + itembonuses.DoubleRangedAttack + aabonuses.DoubleRangedAttack; if(chance && (MakeRandomInt(0, 100) < chance)) @@ -3474,7 +3475,7 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons mlog(COMBAT__DAMAGE, "Avoiding %d damage due to invulnerability.", damage); damage = -5; } - + if( spell_id != SPELL_UNKNOWN || attacker == nullptr ) avoidable = false; @@ -3575,7 +3576,7 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons attacker->CastToClient()->sneaking = false; attacker->SendAppearancePacket(AT_Sneak, 0); } - + //final damage has been determined. SetHP(GetHP() - damage); @@ -3607,7 +3608,7 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons entity_list.MessageClose_StringID(this, true, 100, MT_WornOff, HAS_BEEN_AWAKENED, GetCleanName(), attacker->GetCleanName()); BuffFadeByEffect(SE_Mez); - } + } //check stun chances if bashing if (damage > 0 && ((skill_used == SkillBash || skill_used == SkillKick) && attacker)) { @@ -3905,7 +3906,7 @@ float Mob::GetProcChances(float ProcBonus, uint16 hand) } float Mob::GetDefensiveProcChances(float &ProcBonus, float &ProcChance, uint16 hand, Mob* on) { - + if (!on) return ProcChance; @@ -3961,7 +3962,7 @@ void Mob::TryWeaponProc(const ItemInst* weapon_g, Mob *on, uint16 hand) { LogFile->write(EQEMuLog::Error, "A null Mob object was passed to Mob::TryWeaponProc for evaluation!"); return; } - + if (!IsAttackAllowed(on)) { mlog(COMBAT__PROCS, "Preventing procing off of unattackable things."); return; @@ -3988,7 +3989,7 @@ void Mob::TryWeaponProc(const ItemInst* weapon_g, Mob *on, uint16 hand) { void Mob::TryWeaponProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on, uint16 hand) { - + if (!weapon) return; uint16 skillinuse = 28; @@ -4149,7 +4150,7 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on, uint16 skillinuse = 28; if (weapon) skillinuse = GetSkillByItemType(weapon->ItemType); - + TrySkillProc(on, skillinuse, 0, false, hand); } @@ -4260,7 +4261,7 @@ void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttack //are defined you will have an innate chance to hit at Level 1 regardless of bonuses. //Warning: Do not define these rules if you want live like critical hits. critChance += RuleI(Combat, MeleeBaseCritChance); - + if (IsClient()) { critChance += RuleI(Combat, ClientBaseCritChance); @@ -4313,7 +4314,7 @@ void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttack uint32 critMod = 200; bool crip_success = false; int32 CripplingBlowChance = GetCrippBlowChance(); - + //Crippling Blow Chance: The percent value of the effect is applied //to the your Chance to Critical. (ie You have 10% chance to critical and you //have a 200% Chance to Critical Blow effect, therefore you have a 20% Chance to Critical Blow. @@ -4367,7 +4368,7 @@ bool Mob::TryFinishingBlow(Mob *defender, SkillUseTypes skillinuse) if (defender && !defender->IsClient() && defender->GetHPRatio() < 10){ uint32 FB_Dmg = aabonuses.FinishingBlow[1] + spellbonuses.FinishingBlow[1] + itembonuses.FinishingBlow[1]; - + uint32 FB_Level = 0; FB_Level = aabonuses.FinishingBlowLvl[0]; if (FB_Level < spellbonuses.FinishingBlowLvl[0]) @@ -4510,8 +4511,8 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui if (!spellbonuses.LimitToSkill[skill] && !itembonuses.LimitToSkill[skill] && !aabonuses.LimitToSkill[skill]) return; - /*Allow one proc from each (Spell/Item/AA) - Kayen: Due to limited avialability of effects on live it is too difficult + /*Allow one proc from each (Spell/Item/AA) + Kayen: Due to limited avialability of effects on live it is too difficult to confirm how they stack at this time, will adjust formula when more data is avialablle to test.*/ bool CanProc = true; @@ -4519,7 +4520,7 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui uint16 proc_spell_id = 0; float ProcMod = 0; float chance = 0; - + if (IsDefensive) chance = on->GetSkillProcChances(ReuseTime, hand); else @@ -4528,16 +4529,16 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui if (spellbonuses.LimitToSkill[skill]){ for(int e = 0; e < MAX_SKILL_PROCS; e++){ - - if (CanProc && - (!Success && spellbonuses.SkillProc[e] && IsValidSpell(spellbonuses.SkillProc[e])) + + if (CanProc && + (!Success && spellbonuses.SkillProc[e] && IsValidSpell(spellbonuses.SkillProc[e])) || (Success && spellbonuses.SkillProcSuccess[e] && IsValidSpell(spellbonuses.SkillProcSuccess[e]))) { base_spell_id = spellbonuses.SkillProc[e]; base_spell_id = 0; ProcMod = 0; - + for (int i = 0; i < EFFECT_COUNT; i++) { - + if (spells[base_spell_id].effectid[i] == SE_SkillProc) { proc_spell_id = spells[base_spell_id].base[i]; ProcMod = static_cast(spells[base_spell_id].base2[i]); @@ -4567,16 +4568,16 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui if (itembonuses.LimitToSkill[skill]){ CanProc = true; for(int e = 0; e < MAX_SKILL_PROCS; e++){ - - if (CanProc && - (!Success && itembonuses.SkillProc[e] && IsValidSpell(itembonuses.SkillProc[e])) + + if (CanProc && + (!Success && itembonuses.SkillProc[e] && IsValidSpell(itembonuses.SkillProc[e])) || (Success && itembonuses.SkillProcSuccess[e] && IsValidSpell(itembonuses.SkillProcSuccess[e]))) { base_spell_id = itembonuses.SkillProc[e]; base_spell_id = 0; ProcMod = 0; for (int i = 0; i < EFFECT_COUNT; i++) { - + if (spells[base_spell_id].effectid[i] == SE_SkillProc) { proc_spell_id = spells[base_spell_id].base[i]; ProcMod = static_cast(spells[base_spell_id].base2[i]); @@ -4607,12 +4608,12 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui CanProc = true; uint32 effect = 0; int32 base1 = 0; - int32 base2 = 0; + int32 base2 = 0; uint32 slot = 0; for(int e = 0; e < MAX_SKILL_PROCS; e++){ - - if (CanProc && + + if (CanProc && (!Success && aabonuses.SkillProc[e]) || (Success && aabonuses.SkillProcSuccess[e])){ int aaid = aabonuses.SkillProc[e]; @@ -4660,44 +4661,44 @@ float Mob::GetSkillProcChances(uint16 ReuseTime, uint16 hand) { uint32 weapon_speed; float ProcChance = 0; - + if (!ReuseTime && hand) { weapon_speed = GetWeaponSpeedbyHand(hand); ProcChance = static_cast(weapon_speed) * (RuleR(Combat, AvgProcsPerMinute) / 60000.0f); - + if (hand != MainPrimary) ProcChance /= 2; } - else + else ProcChance = static_cast(ReuseTime) * (RuleR(Combat, AvgProcsPerMinute) / 60000.0f); return ProcChance; } bool Mob::TryRootFadeByDamage(int buffslot, Mob* attacker) { - + /*Dev Quote 2010: http://forums.station.sony.com/eq/posts/list.m?topic_id=161443 The Viscid Roots AA does the following: Reduces the chance for root to break by X percent. There is no distinction of any kind between the caster inflicted damage, or anyone else's damage. There is also no distinction between Direct and DOT damage in the root code. - + /* General Mechanics - Check buffslot to make sure damage from a root does not cancel the root - - If multiple roots on target, always and only checks first root slot and if broken only removes that slots root. + - If multiple roots on target, always and only checks first root slot and if broken only removes that slots root. - Only roots on determental spells can be broken by damage. - Root break chance values obtained from live parses. */ - + if (!attacker || !spellbonuses.Root[0] || spellbonuses.Root[1] < 0) return false; - + if (IsDetrimentalSpell(spellbonuses.Root[1]) && spellbonuses.Root[1] != buffslot){ - + int BreakChance = RuleI(Spells, RootBreakFromSpells); - + BreakChance -= BreakChance*buffs[spellbonuses.Root[1]].RootBreakChance/100; int level_diff = attacker->GetLevel() - GetLevel(); @@ -4705,13 +4706,13 @@ bool Mob::TryRootFadeByDamage(int buffslot, Mob* attacker) { if (level_diff == 2) BreakChance = (BreakChance * 80) /100; //Decrease by 20%; - + else if (level_diff >= 3 && level_diff <= 20) BreakChance = (BreakChance * 60) /100; //Decrease by 40%; else if (level_diff > 21) BreakChance = (BreakChance * 20) /100; //Decrease by 80%; - + if (BreakChance < 1) BreakChance = 1; @@ -4736,7 +4737,7 @@ int32 Mob::RuneAbsorb(int32 damage, uint16 type) for(uint32 slot = 0; slot < buff_max; slot++) { if(slot == spellbonuses.MeleeRune[1] && spellbonuses.MeleeRune[0] && buffs[slot].melee_rune && IsValidSpell(buffs[slot].spellid)){ int melee_rune_left = buffs[slot].melee_rune; - + if(melee_rune_left > damage) { melee_rune_left -= damage; @@ -4748,7 +4749,7 @@ int32 Mob::RuneAbsorb(int32 damage, uint16 type) { if(melee_rune_left > 0) damage -= melee_rune_left; - + if(!TryFadeEffect(slot)) BuffFadeBySlot(slot); } @@ -4756,7 +4757,7 @@ int32 Mob::RuneAbsorb(int32 damage, uint16 type) } } - + else{ for(uint32 slot = 0; slot < buff_max; slot++) { if(slot == spellbonuses.AbsorbMagicAtt[1] && spellbonuses.AbsorbMagicAtt[0] && buffs[slot].magic_rune && IsValidSpell(buffs[slot].spellid)){ @@ -4772,7 +4773,7 @@ int32 Mob::RuneAbsorb(int32 damage, uint16 type) { if(magic_rune_left > 0) damage -= magic_rune_left; - + if(!TryFadeEffect(slot)) BuffFadeBySlot(slot); } @@ -4785,7 +4786,7 @@ int32 Mob::RuneAbsorb(int32 damage, uint16 type) void Mob::CommonOutgoingHitSuccess(Mob* defender, int32 &damage, SkillUseTypes skillInUse) { - if (!defender) + if (!defender) return; ApplyMeleeDamageBonus(skillInUse, damage); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 9f7d533b2..70b33dd1b 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4595,13 +4595,8 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) safe_delete(outapp); } - if(zone->watermap) - { - if(zone->watermap->InLiquid(m_Position.m_X, m_Position.m_Y, m_Position.m_Z)) - { - CheckIncreaseSkill(SkillSwimming, nullptr, -17); - } - } + if(zone->watermap && zone->watermap->InLiquid(m_Position)) + CheckIncreaseSkill(SkillSwimming, nullptr, -17); return; } diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 4c4290232..5b028f0df 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -199,7 +199,7 @@ void HateList::Add(Mob *ent, int32 in_hate, int32 in_dam, bool bFrenzy, bool iAd parse->EventNPC(EVENT_HATE_LIST, owner->CastToNPC(), ent, "1", 0); if (ent->IsClient()) { - if (owner->CastToNPC()->IsRaidTarget()) + if (owner->CastToNPC()->IsRaidTarget()) ent->CastToClient()->SetEngagedRaidTarget(true); ent->CastToClient()->IncrementAggroCount(); } @@ -222,7 +222,7 @@ bool HateList::RemoveEnt(Mob *ent) parse->EventNPC(EVENT_HATE_LIST, owner->CastToNPC(), ent, "0", 0); found = true; - + if(ent && ent->IsClient()) ent->CastToClient()->DecrementAggroCount(); @@ -263,11 +263,11 @@ int HateList::SummonedPetCount(Mob *hater) { auto iterator = list.begin(); while(iterator != list.end()) { - if((*iterator)->ent != nullptr && (*iterator)->ent->IsNPC() && ((*iterator)->ent->CastToNPC()->IsPet() || ((*iterator)->ent->CastToNPC()->GetSwarmOwner() > 0))) + if((*iterator)->ent != nullptr && (*iterator)->ent->IsNPC() && ((*iterator)->ent->CastToNPC()->IsPet() || ((*iterator)->ent->CastToNPC()->GetSwarmOwner() > 0))) { ++petcount; } - + ++iterator; } @@ -303,15 +303,16 @@ Mob *HateList::GetTop(Mob *center) continue; } + auto hateEntryPosition = xyz_location(cur->ent->GetX(), cur->ent->GetY(), cur->ent->GetZ()); if(center->IsNPC() && center->CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) { - if(!zone->watermap->InLiquid(cur->ent->GetX(), cur->ent->GetY(), cur->ent->GetZ())) { + if(!zone->watermap->InLiquid(hateEntryPosition)) { skipped_count++; ++iterator; continue; } } - if (cur->ent->Sanctuary()) { + if (cur->ent->Sanctuary()) { if(hate == -1) { top = cur->ent; @@ -428,8 +429,9 @@ Mob *HateList::GetTop(Mob *center) while(iterator != list.end()) { tHateEntry *cur = (*iterator); + auto hateEntryPosition = xyz_location(cur->ent->GetX(), cur->ent->GetY(), cur->ent->GetZ()); if(center->IsNPC() && center->CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) { - if(!zone->watermap->InLiquid(cur->ent->GetX(), cur->ent->GetY(), cur->ent->GetZ())) { + if(!zone->watermap->InLiquid(hateEntryPosition)) { skipped_count++; ++iterator; continue; @@ -488,7 +490,7 @@ Mob *HateList::GetRandom() int random = MakeRandomInt(0, count - 1); for (int i = 0; i < random; i++) ++iterator; - + return (*iterator)->ent; } diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index e2fa84560..b727d20b2 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1372,7 +1372,8 @@ void Mob::AI_Process() { //we cannot reach our target... //underwater stuff only works with water maps in the zone! if(IsNPC() && CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) { - if(!zone->watermap->InLiquid(target->GetX(), target->GetY(), target->GetZ())) { + auto targetPosition = xyz_location(target->GetX(), target->GetY(), target->GetZ()); + if(!zone->watermap->InLiquid(targetPosition)) { Mob *tar = hate_list.GetTop(this); if(tar == target) { WipeHateList(); diff --git a/zone/pathing.cpp b/zone/pathing.cpp index c860913fe..7bd44c757 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -1197,12 +1197,14 @@ bool PathManager::NoHazardsAccurate(Map::Vertex From, Map::Vertex To) if (zone->watermap) { - if (zone->watermap->InLiquid(From.x, From.y, From.z) || zone->watermap->InLiquid(To.x, To.y, To.z)) + auto from = xyz_location(From.x, From.y, From.z); + auto to = xyz_location(To.x, To.y, To.z); + if (zone->watermap->InLiquid(from) || zone->watermap->InLiquid(to)) { break; } - - if (zone->watermap->InLiquid(TestPoint.x, TestPoint.y, NewZ)) + auto testPointNewZ = xyz_location(TestPoint.x, TestPoint.y, NewZ); + if (zone->watermap->InLiquid(testPointNewZ)) { Map::Vertex TestPointWater(TestPoint.x, TestPoint.y, NewZ - 0.5f); Map::Vertex TestPointWaterDest = TestPointWater; diff --git a/zone/water_map.h b/zone/water_map.h index 82de8cc2d..dd07fca5f 100644 --- a/zone/water_map.h +++ b/zone/water_map.h @@ -29,7 +29,7 @@ public: virtual bool InWater(const xyz_location& location) const { return false; } virtual bool InVWater(const xyz_location& location) const { return false; } virtual bool InLava(const xyz_location& location) const { return false; } - virtual bool InLiquid(float y, float x, float z) const { return false; } + virtual bool InLiquid(const xyz_location& location) const { return false; } protected: virtual bool Load(FILE *fp) { return false; } From ef1845848045a2ecdd07e06fb97ab8447e451c5d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 19:36:47 -0800 Subject: [PATCH 019/253] ReturnRegionType converted to xyz_location --- zone/water_map_v2.cpp | 14 ++++++++------ zone/water_map_v2.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/zone/water_map_v2.cpp b/zone/water_map_v2.cpp index b08c9ca89..7c9f3bce3 100644 --- a/zone/water_map_v2.cpp +++ b/zone/water_map_v2.cpp @@ -6,11 +6,11 @@ WaterMapV2::WaterMapV2() { WaterMapV2::~WaterMapV2() { } -WaterRegionType WaterMapV2::ReturnRegionType(float y, float x, float z) const { +WaterRegionType WaterMapV2::ReturnRegionType(const xyz_location& location) const { size_t sz = regions.size(); for(size_t i = 0; i < sz; ++i) { auto const ®ion = regions[i]; - if (region.second.ContainsPoint(glm::vec3(x, y, z))) { + if (region.second.ContainsPoint(glm::vec3(location.m_X, location.m_Y, location.m_Z))) { return region.first; } } @@ -18,19 +18,21 @@ WaterRegionType WaterMapV2::ReturnRegionType(float y, float x, float z) const { } bool WaterMapV2::InWater(const xyz_location& location) const { - return ReturnRegionType(location.m_Y, location.m_X, location.m_Z) == RegionTypeWater; + return ReturnRegionType(location) == RegionTypeWater; } bool WaterMapV2::InVWater(float y, float x, float z) const { - return ReturnRegionType(y, x, z) == RegionTypeVWater; + auto location = xyz_location(x, y, z); + return ReturnRegionType(location) == RegionTypeVWater; } bool WaterMapV2::InLava(float y, float x, float z) const { - return ReturnRegionType(y, x, z) == RegionTypeLava; + auto location = xyz_location(x, y, z); + return ReturnRegionType(location) == RegionTypeLava; } bool WaterMapV2::InLiquid(float y, float x, float z) const { - auto location = xyz_location(y, x, z); + auto location = xyz_location(x, y, z); return InWater(location) || InLava(y, x, z); } diff --git a/zone/water_map_v2.h b/zone/water_map_v2.h index eef514af5..fea136957 100644 --- a/zone/water_map_v2.h +++ b/zone/water_map_v2.h @@ -12,7 +12,7 @@ public: WaterMapV2(); ~WaterMapV2(); - virtual WaterRegionType ReturnRegionType(float y, float x, float z) const; + virtual WaterRegionType ReturnRegionType(const xyz_location& location) const; virtual bool InWater(const xyz_location& location) const; virtual bool InVWater(float y, float x, float z) const; virtual bool InLava(float y, float x, float z) const; From 5140e6fabf82c3ad114a6239656fd292cba4f0ab Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 19:37:32 -0800 Subject: [PATCH 020/253] InVWater converted to xyz_location --- zone/water_map_v2.cpp | 3 +-- zone/water_map_v2.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/zone/water_map_v2.cpp b/zone/water_map_v2.cpp index 7c9f3bce3..2ba0a7d35 100644 --- a/zone/water_map_v2.cpp +++ b/zone/water_map_v2.cpp @@ -21,8 +21,7 @@ bool WaterMapV2::InWater(const xyz_location& location) const { return ReturnRegionType(location) == RegionTypeWater; } -bool WaterMapV2::InVWater(float y, float x, float z) const { - auto location = xyz_location(x, y, z); +bool WaterMapV2::InVWater(const xyz_location& location) const { return ReturnRegionType(location) == RegionTypeVWater; } diff --git a/zone/water_map_v2.h b/zone/water_map_v2.h index fea136957..5c4ba9e80 100644 --- a/zone/water_map_v2.h +++ b/zone/water_map_v2.h @@ -14,7 +14,7 @@ public: virtual WaterRegionType ReturnRegionType(const xyz_location& location) const; virtual bool InWater(const xyz_location& location) const; - virtual bool InVWater(float y, float x, float z) const; + virtual bool InVWater(const xyz_location& location) const; virtual bool InLava(float y, float x, float z) const; virtual bool InLiquid(float y, float x, float z) const; From 2f203fa6bb3cf8fd48c72d5abc86d60bc1271213 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 19:38:53 -0800 Subject: [PATCH 021/253] InLava converted to xyz_location --- zone/water_map_v2.cpp | 5 ++--- zone/water_map_v2.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/zone/water_map_v2.cpp b/zone/water_map_v2.cpp index 2ba0a7d35..6f5977d79 100644 --- a/zone/water_map_v2.cpp +++ b/zone/water_map_v2.cpp @@ -25,14 +25,13 @@ bool WaterMapV2::InVWater(const xyz_location& location) const { return ReturnRegionType(location) == RegionTypeVWater; } -bool WaterMapV2::InLava(float y, float x, float z) const { - auto location = xyz_location(x, y, z); +bool WaterMapV2::InLava(const xyz_location& location) const { return ReturnRegionType(location) == RegionTypeLava; } bool WaterMapV2::InLiquid(float y, float x, float z) const { auto location = xyz_location(x, y, z); - return InWater(location) || InLava(y, x, z); + return InWater(location) || InLava(location); } bool WaterMapV2::Load(FILE *fp) { diff --git a/zone/water_map_v2.h b/zone/water_map_v2.h index 5c4ba9e80..02e549cc7 100644 --- a/zone/water_map_v2.h +++ b/zone/water_map_v2.h @@ -15,7 +15,7 @@ public: virtual WaterRegionType ReturnRegionType(const xyz_location& location) const; virtual bool InWater(const xyz_location& location) const; virtual bool InVWater(const xyz_location& location) const; - virtual bool InLava(float y, float x, float z) const; + virtual bool InLava(const xyz_location& location) const; virtual bool InLiquid(float y, float x, float z) const; protected: From 4094d43c49acca8c651cf8ecdd71f4afb24438b4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 19:39:39 -0800 Subject: [PATCH 022/253] InLiquid converted to xyz_location --- zone/water_map_v2.cpp | 3 +-- zone/water_map_v2.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/zone/water_map_v2.cpp b/zone/water_map_v2.cpp index 6f5977d79..9a8eb9564 100644 --- a/zone/water_map_v2.cpp +++ b/zone/water_map_v2.cpp @@ -29,8 +29,7 @@ bool WaterMapV2::InLava(const xyz_location& location) const { return ReturnRegionType(location) == RegionTypeLava; } -bool WaterMapV2::InLiquid(float y, float x, float z) const { - auto location = xyz_location(x, y, z); +bool WaterMapV2::InLiquid(const xyz_location& location) const { return InWater(location) || InLava(location); } diff --git a/zone/water_map_v2.h b/zone/water_map_v2.h index 02e549cc7..a0adccc48 100644 --- a/zone/water_map_v2.h +++ b/zone/water_map_v2.h @@ -16,7 +16,7 @@ public: virtual bool InWater(const xyz_location& location) const; virtual bool InVWater(const xyz_location& location) const; virtual bool InLava(const xyz_location& location) const; - virtual bool InLiquid(float y, float x, float z) const; + virtual bool InLiquid(const xyz_location& location) const; protected: virtual bool Load(FILE *fp); From 5b783e84e9993023893a23b1250f54f0d4bb266f Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 21:25:09 -0800 Subject: [PATCH 023/253] added automatic conversion of Map::Vertex into xyz_location --- zone/map.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zone/map.h b/zone/map.h index 224e30c73..64a289a41 100644 --- a/zone/map.h +++ b/zone/map.h @@ -22,6 +22,7 @@ #ifndef ZONE_MAP_H #define ZONE_MAP_H +#include "position.h" #include #include @@ -36,10 +37,14 @@ public: Vertex() : x(0.0f), y(0.0f), z(0.0f) { } Vertex(float _x, float _y, float _z) : x(_x), y(_y), z(_z) { } ~Vertex() { } - bool operator==(const Vertex &v) const + bool operator==(const Vertex &v) const { return((v.x == x) && (v.y == y) && (v.z == z)); } + operator xyz_location() const + { + return xyz_location(x,y,z); + } float x; float y; @@ -49,7 +54,7 @@ public: Map(); ~Map(); - + float FindBestZ(Vertex &start, Vertex *result) const; bool LineIntersectsZone(Vertex start, Vertex end, float step, Vertex *result) const; bool LineIntersectsZoneNoZLeaps(Vertex start, Vertex end, float step_mag, Vertex *result) const; @@ -62,7 +67,7 @@ private: void TranslateVertex(Vertex &v, float tx, float ty, float tz); bool LoadV1(FILE *f); bool LoadV2(FILE *f); - + struct impl; impl *imp; }; From 11ecf77c85022082091353a1fff3e0800c568cbc Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 26 Nov 2014 21:41:14 -0800 Subject: [PATCH 024/253] added constness to operators --- zone/position.cpp | 8 ++++---- zone/position.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/zone/position.cpp b/zone/position.cpp index a5f0cf5f1..d7e0d48f4 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -63,15 +63,15 @@ xyz_heading::operator xy_location() const { return xy_location(m_X,m_Y); } -const xyz_heading xyz_heading::operator +(const xyz_location& rhs) { +const xyz_heading xyz_heading::operator +(const xyz_location& rhs) const{ return xyz_heading(m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z + rhs.m_Z, m_Heading); } -const xyz_heading xyz_heading::operator +(const xy_location& rhs) { +const xyz_heading xyz_heading::operator +(const xy_location& rhs) const{ return xyz_heading(m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z, m_Heading); } -const xyz_heading xyz_heading::operator -(const xyz_location& rhs) { +const xyz_heading xyz_heading::operator -(const xyz_location& rhs) const{ return xyz_heading(m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z, m_Heading); } @@ -92,7 +92,7 @@ xyz_location::operator xy_location() const { return xy_location(m_X, m_Y); } -const xyz_location xyz_location::operator -(const xyz_location& rhs) { +const xyz_location xyz_location::operator -(const xyz_location& rhs) const { return xyz_location(m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z); } diff --git a/zone/position.h b/zone/position.h index 900d2cdfe..eadd187ce 100644 --- a/zone/position.h +++ b/zone/position.h @@ -43,7 +43,7 @@ public: operator xy_location() const; - const xyz_location operator -(const xyz_location& rhs); + const xyz_location operator -(const xyz_location& rhs) const; void ABS_XYZ(); bool isOrigin() const { return m_X == 0 && m_Y == 0 && m_Z == 0;} @@ -70,10 +70,10 @@ public: operator xyz_location() const; operator xy_location() const; - const xyz_heading operator +(const xyz_location& rhs); - const xyz_heading operator +(const xy_location& rhs); + const xyz_heading operator +(const xyz_location& rhs) const; + const xyz_heading operator +(const xy_location& rhs) const; - const xyz_heading operator -(const xyz_location& rhs); + const xyz_heading operator -(const xyz_location& rhs) const; bool isOrigin() const { return m_X == 0.0f && m_Y == 0.0f && m_Z == 0.0f;} }; From 607e28dcbf61d3f140931be66f15816bb5690f92 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 29 Nov 2014 16:43:24 -0800 Subject: [PATCH 025/253] added GetPosition to mob --- zone/mob.h | 1 + 1 file changed, 1 insertion(+) diff --git a/zone/mob.h b/zone/mob.h index 57da56de5..ff1364e07 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -393,6 +393,7 @@ public: ((static_cast(cur_mana) / max_mana) * 100); } virtual int32 CalcMaxMana(); uint32 GetNPCTypeID() const { return npctype_id; } + inline const xyz_heading GetPosition() const { return m_Position; } inline const float GetX() const { return m_Position.m_X; } inline const float GetY() const { return m_Position.m_Y; } inline const float GetZ() const { return m_Position.m_Z; } From 4b48ed7cbc69dacc7d3fb661ccadbbc9c6ce021e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 29 Nov 2014 21:07:08 -0800 Subject: [PATCH 026/253] SetDeltas converted to SetDelta --- zone/client_packet.cpp | 3 ++- zone/mob.cpp | 4 ++-- zone/mob.h | 2 +- zone/perl_mob.cpp | 7 ++----- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 70b33dd1b..62f4f12dd 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4360,7 +4360,8 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) } // set the boat's position deltas - boat->SetDeltas(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading); + auto boatDelta = xyz_heading(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading); + boat->SetDelta(boatDelta); // send an update to everyone nearby except the client controlling the boat EQApplicationPacket* outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); PlayerPositionUpdateServer_Struct* ppus = (PlayerPositionUpdateServer_Struct*)outapp->pBuffer; diff --git a/zone/mob.cpp b/zone/mob.cpp index 4db71440c..d2cd3d6df 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2928,8 +2928,8 @@ void Mob::TriggerDefensiveProcs(const ItemInst* weapon, Mob *on, uint16 hand, in } } -void Mob::SetDeltas(float dx, float dy, float dz, float dh) { - m_Delta = xyz_heading(dx,dy,dz,dh); +void Mob::SetDelta(const xyz_heading& delta) { + m_Delta = delta; } void Mob::SetEntityVariable(const char *id, const char *m_var) diff --git a/zone/mob.h b/zone/mob.h index ff1364e07..8d42642c3 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -432,7 +432,7 @@ public: bool IsRunning() const { return m_is_running; } void SetRunning(bool val) { m_is_running = val; } virtual void GMMove(float x, float y, float z, float heading = 0.01, bool SendUpdate = true); - void SetDeltas(float delta_x, float delta_y, float delta_z, float delta_h); + void SetDelta(const xyz_heading& delta); void SetTargetDestSteps(uint8 target_steps) { tar_ndx = target_steps; } void SendPosUpdate(uint8 iSendToSelf = 0); void MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct* spu); diff --git a/zone/perl_mob.cpp b/zone/perl_mob.cpp index f41685a1c..23694bf4a 100644 --- a/zone/perl_mob.cpp +++ b/zone/perl_mob.cpp @@ -7632,10 +7632,7 @@ XS(XS_Mob_SetDeltas) Perl_croak(aTHX_ "Usage: Mob::SetDeltas(THIS, delta_x, delta_y, delta_z, delta_h)"); { Mob * THIS; - float delta_x = (float)SvNV(ST(1)); - float delta_y = (float)SvNV(ST(2)); - float delta_z = (float)SvNV(ST(3)); - float delta_h = (float)SvNV(ST(4)); + auto delta = xyz_heading((float)SvNV(ST(1)), (float)SvNV(ST(2)), (float)SvNV(ST(3)), (float)SvNV(ST(4))); if (sv_derived_from(ST(0), "Mob")) { IV tmp = SvIV((SV*)SvRV(ST(0))); @@ -7646,7 +7643,7 @@ XS(XS_Mob_SetDeltas) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - THIS->SetDeltas(delta_x, delta_y, delta_z, delta_h); + THIS->SetDelta(delta); } XSRETURN_EMPTY; } From 82cc830297cd65283bbb80f81a18a42122cdbad5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 29 Nov 2014 21:24:57 -0800 Subject: [PATCH 027/253] converted Warp to xyz_location instead of x,y,z --- zone/bot.cpp | 6 +++--- zone/mob.cpp | 14 +++++--------- zone/mob.h | 2 +- zone/position.cpp | 8 -------- zone/position.h | 1 - 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 2a8921dd7..f2bde8980 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -10715,12 +10715,12 @@ void Bot::BotGroupSummon(Group* group, Client* client) { if(botMember->GetBotOwnerCharacterID() == client->CharacterID()) { botMember->SetTarget(botMember->GetBotOwner()); botMember->WipeHateList(); - botMember->Warp(botMember->GetBotOwner()->GetX(), botMember->GetBotOwner()->GetY(), botMember->GetBotOwner()->GetZ()); + botMember->Warp(botMember->GetBotOwner()->GetPosition()); if(botMember->HasPet() && botMember->GetPet()) { botMember->GetPet()->SetTarget(botMember); botMember->GetPet()->WipeHateList(); - botMember->GetPet()->Warp(botMember->GetBotOwner()->GetX(), botMember->GetBotOwner()->GetY(), botMember->GetBotOwner()->GetZ()); + botMember->GetPet()->Warp(botMember->GetBotOwner()->GetPosition()); } } } @@ -11729,7 +11729,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else { b->SetTarget(c->CastToMob()); - b->Warp(c->GetX(), c->GetY(), c->GetZ()); + b->Warp(c->GetPosition()); } } } diff --git a/zone/mob.cpp b/zone/mob.cpp index d2cd3d6df..48aee2260 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2590,20 +2590,16 @@ void Mob::SetNextIncHPEvent( int inchpevent ) nextinchpevent = inchpevent; } //warp for quest function,from sandy -void Mob::Warp( float x, float y, float z ) +void Mob::Warp(const xyz_location& location) { - if(IsNPC()) { - entity_list.ProcessMove(CastToNPC(), x, y, z); - } + if(IsNPC()) + entity_list.ProcessMove(CastToNPC(), location.m_X, location.m_Y, location.m_Z); - m_Position.m_X = x; - m_Position.m_Y = y; - m_Position.m_Z = z; + m_Position = location; Mob* target = GetTarget(); - if (target) { + if (target) FaceTarget( target ); - } SendPosition(); } diff --git a/zone/mob.h b/zone/mob.h index 8d42642c3..cf904a97d 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -420,7 +420,7 @@ public: virtual inline int32 GetPrimaryFaction() const { return 0; } //Movement - void Warp( float x, float y, float z ); + void Warp(const xyz_location& location); inline bool IsMoving() const { return moving; } virtual void SetMoving(bool move) { moving = move; m_Delta = xyz_heading::Origin(); } virtual void GoToBind(uint8 bindnum = 0) { } diff --git a/zone/position.cpp b/zone/position.cpp index d7e0d48f4..2d7d48cf8 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -40,14 +40,6 @@ xyz_heading::xyz_heading(const xy_location& locationDir, float z, float heading) m_Heading(heading) { } - -xyz_heading::xyz_heading(const xyz_location locationDir, float heading) : - m_X(locationDir.m_X), - m_Y(locationDir.m_Y), - m_Z(locationDir.m_Z), - m_Heading(heading) { -} - xyz_heading::xyz_heading(const xy_location locationDir, float z, float heading) : m_X(locationDir.m_X), m_Y(locationDir.m_Y), diff --git a/zone/position.h b/zone/position.h index eadd187ce..591c14b10 100644 --- a/zone/position.h +++ b/zone/position.h @@ -63,7 +63,6 @@ public: xyz_heading(float x = 0.0f, float y = 0.0f, float z = 0.0f, float heading = 0.0f); xyz_heading(const xyz_heading& locationDir); xyz_heading(const xyz_location& locationDir, float heading = 0.0f); - xyz_heading(const xyz_location locationDir, float heading = 0.0f); explicit xyz_heading(const xy_location& locationDir, float z, float heading); explicit xyz_heading(const xy_location locationDir, float z, float heading); From 6ffd7203ffa8df7b76288f994d40f690f7a56561 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 13:51:57 -0800 Subject: [PATCH 028/253] org_x, org_y, org_z, and org_heading converted to xyz_heading as m_SpawnPoint --- zone/command.cpp | 5 +++-- zone/npc.cpp | 17 +++++++---------- zone/npc.h | 28 ++++++++++++++-------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 7499edd6b..1dfab5bb0 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -1800,10 +1800,11 @@ void command_gassign(Client *c, const Seperator *sep) { if (sep->IsNumber(1) && c->GetTarget() && c->GetTarget()->IsNPC()) { + auto npcBind = c->GetTarget()->CastToNPC()->m_SpawnPoint; database.AssignGrid( c, - (c->GetTarget()->CastToNPC()->org_x), - (c->GetTarget()->CastToNPC()->org_y), + npcBind.m_X, + npcBind.m_Y, atoi(sep->arg[1]) ); } diff --git a/zone/npc.cpp b/zone/npc.cpp index eae42b670..147d275f9 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -113,7 +113,8 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float qglobal_purge_timer(30000), sendhpupdate_timer(1000), enraged_timer(1000), - taunt_timer(TauntReuseTime * 1000) + taunt_timer(TauntReuseTime * 1000), + m_SpawnPoint(x,y,z,heading) { //What is the point of this, since the names get mangled.. Mob* mob = entity_list.GetMob(name); @@ -203,9 +204,6 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float MerchantType = d->merchanttype; merchant_open = GetClass() == MERCHANT; adventure_template_id = d->adventure_template; - org_x = x; - org_y = y; - org_z = z; flymode = iflymode; guard_x = -1; //just some value we might be able to recongize as "unset" guard_y = -1; @@ -221,7 +219,6 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float roambox_movingto_y = -2; roambox_min_delay = 1000; roambox_delay = 1000; - org_heading = heading; p_depop = false; loottable_id = d->loottable_id; @@ -1853,7 +1850,7 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns) { swarmOwner = entity_list.GetMobID(GetSwarmOwner()); } - + if (swarmOwner != nullptr) { if(swarmOwner->IsClient()) @@ -1873,7 +1870,7 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns) SetTempPet(true); //Simple mob flag for checking if temp pet swarmOwner->SetTempPetsActive(true); //Necessary fail safe flag set if mob ever had a swarm pet to ensure they are removed. swarmOwner->SetTempPetCount(swarmOwner->GetTempPetCount() + 1); - + //Not recommended if using above (However, this will work better on older clients). if (RuleB(Pets, UnTargetableSwarmPet)) { @@ -1881,7 +1878,7 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns) if(!IsCharmed() && swarmOwner->IsClient()) sprintf(ns->spawn.lastName, "%s's Pet", swarmOwner->GetName()); } - } + } else if(GetOwnerID()) { ns->spawn.is_pet = 1; @@ -2430,7 +2427,7 @@ void NPC::DepopSwarmPets() Mob* owner = entity_list.GetMobID(GetSwarmInfo()->owner_id); if (owner) owner->SetTempPetCount(owner->GetTempPetCount() - 1); - + Depop(); return; } @@ -2448,4 +2445,4 @@ void NPC::DepopSwarmPets() } } } -} \ No newline at end of file +} diff --git a/zone/npc.h b/zone/npc.h index 71e6596ad..1770219ba 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -67,10 +67,10 @@ struct AISpells_Struct { }; struct AISpellsEffects_Struct { - uint16 spelleffectid; - int32 base; - int32 limit; - int32 max; + uint16 spelleffectid; + int32 base; + int32 limit; + int32 max; }; struct AISpellsVar_Struct { @@ -86,7 +86,7 @@ struct AISpellsVar_Struct { uint32 idle_no_sp_recast_min; uint32 idle_no_sp_recast_max; uint8 idle_beneficial_chance; -}; +}; class AA_SwarmPetInfo; @@ -163,7 +163,7 @@ public: FACTION_VALUE CheckNPCFactionAlly(int32 other_faction); virtual FACTION_VALUE GetReverseFactionCon(Mob* iOther); - void GoToBind(uint8 bindnum = 0) { GMMove(org_x, org_y, org_z, org_heading); } + void GoToBind(uint8 bindnum = 0) { GMMove(m_SpawnPoint.m_X, m_SpawnPoint.m_Y, m_SpawnPoint.m_Z, m_SpawnPoint.m_Heading); } void Gate(); void GetPetState(SpellBuff_Struct *buffs, uint32 *items, char *name); @@ -211,10 +211,10 @@ public: uint32 GetSp2() const { return spawn_group; } uint32 GetSpawnPointID() const; - float GetSpawnPointX() const { return org_x; } - float GetSpawnPointY() const { return org_y; } - float GetSpawnPointZ() const { return org_z; } - float GetSpawnPointH() const { return org_heading; } + float GetSpawnPointX() const { return m_SpawnPoint.m_X; } + float GetSpawnPointY() const { return m_SpawnPoint.m_Y; } + float GetSpawnPointZ() const { return m_SpawnPoint.m_Z; } + float GetSpawnPointH() const { return m_SpawnPoint.m_Heading; } float GetGuardPointX() const { return guard_x; } float GetGuardPointY() const { return guard_y; } float GetGuardPointZ() const { return guard_z; } @@ -255,7 +255,7 @@ public: void SetNPCFactionID(int32 in) { npc_faction_id = in; database.GetFactionIdsForNPC(npc_faction_id, &faction_list, &primary_faction); } - float org_x, org_y, org_z, org_heading; + xyz_heading m_SpawnPoint; uint32 GetMaxDMG() const {return max_dmg;} uint32 GetMinDMG() const {return min_dmg;} @@ -385,7 +385,7 @@ public: inline void SetHealScale(float amt) { healscale = amt; } inline float GetHealScale() { return healscale; } - + inline void SetSpellFocusDMG(int32 NewSpellFocusDMG) {SpellFocusDMG = NewSpellFocusDMG;} inline int32 GetSpellFocusDMG() const { return SpellFocusDMG;} @@ -443,7 +443,7 @@ protected: virtual bool AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes); virtual bool AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore = 0); AISpellsVar_Struct AISpellVar; - + uint32 npc_spells_effects_id; std::vector AIspellsEffects; bool HasAISpellEffects; @@ -510,7 +510,7 @@ protected: //mercenary stuff std::list mercTypeList; std::list mercDataList; - + bool raid_target; uint8 probability; From 4b71d28747e71738dd319aa60a68a70f5ea5d78a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 14:17:14 -0800 Subject: [PATCH 029/253] guard_x, guard_y, guard_z, guard_heading converted to xyz_heading as m_GuardPoint --- zone/mob_ai.cpp | 10 ++++----- zone/npc.cpp | 11 ++++------ zone/npc.h | 12 +++++------ zone/waypoints.cpp | 54 ++++++++++++++++++++-------------------------- 4 files changed, 38 insertions(+), 49 deletions(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index b727d20b2..9c720957e 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1787,13 +1787,13 @@ void NPC::AI_DoMovement() { { bool CP2Moved; if(!RuleB(Pathing, Guard) || !zone->pathing) - CP2Moved = CalculateNewPosition2(guard_x, guard_y, guard_z, walksp); + CP2Moved = CalculateNewPosition2(m_GuardPoint.m_X, m_GuardPoint.m_Y, m_GuardPoint.m_Z, walksp); else { - if(!((m_Position.m_X == guard_x) && (m_Position.m_Y == guard_y) && (m_Position.m_Z == guard_z))) + if(!((m_Position.m_X == m_GuardPoint.m_X) && (m_Position.m_Y == m_GuardPoint.m_Y) && (m_Position.m_Z == m_GuardPoint.m_Z))) { bool WaypointChanged, NodeReached; - Map::Vertex Goal = UpdatePath(guard_x, guard_y, guard_z, walksp, WaypointChanged, NodeReached); + Map::Vertex Goal = UpdatePath(m_GuardPoint.m_X, m_GuardPoint.m_Y, m_GuardPoint.m_Z, walksp, WaypointChanged, NodeReached); if(WaypointChanged) tar_ndx = 20; @@ -1809,13 +1809,13 @@ void NPC::AI_DoMovement() { if (!CP2Moved) { if(moved) { - mlog(AI__WAYPOINTS, "Reached guard point (%.3f,%.3f,%.3f)", guard_x, guard_y, guard_z); + mlog(AI__WAYPOINTS, "Reached guard point (%.3f,%.3f,%.3f)", m_GuardPoint.m_X, m_GuardPoint.m_Y, m_GuardPoint.m_Z); ClearFeignMemory(); moved=false; SetMoving(false); if (GetTarget() == nullptr || DistNoRoot(*GetTarget()) >= 5*5 ) { - SetHeading(guard_heading); + SetHeading(m_GuardPoint.m_Heading); } else { FaceTarget(GetTarget()); } diff --git a/zone/npc.cpp b/zone/npc.cpp index 147d275f9..4469292f6 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -114,7 +114,8 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float sendhpupdate_timer(1000), enraged_timer(1000), taunt_timer(TauntReuseTime * 1000), - m_SpawnPoint(x,y,z,heading) + m_SpawnPoint(x,y,z,heading), + m_GuardPoint(-1,-1,-1,0) { //What is the point of this, since the names get mangled.. Mob* mob = entity_list.GetMob(name); @@ -205,10 +206,6 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float merchant_open = GetClass() == MERCHANT; adventure_template_id = d->adventure_template; flymode = iflymode; - guard_x = -1; //just some value we might be able to recongize as "unset" - guard_y = -1; - guard_z = -1; - guard_heading = 0; guard_anim = eaStanding; roambox_distance = 0; roambox_max_x = -2; @@ -673,8 +670,8 @@ bool NPC::Process() DoGravityEffect(); } - if(reface_timer->Check() && !IsEngaged() && (guard_x == GetX() && guard_y == GetY() && guard_z == GetZ())) { - SetHeading(guard_heading); + if(reface_timer->Check() && !IsEngaged() && (m_GuardPoint.m_X == GetX() && m_GuardPoint.m_Y == GetY() && m_GuardPoint.m_Z == GetZ())) { + SetHeading(m_GuardPoint.m_Heading); SendPosition(); reface_timer->Disable(); } diff --git a/zone/npc.h b/zone/npc.h index 1770219ba..ce943174c 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -215,10 +215,10 @@ public: float GetSpawnPointY() const { return m_SpawnPoint.m_Y; } float GetSpawnPointZ() const { return m_SpawnPoint.m_Z; } float GetSpawnPointH() const { return m_SpawnPoint.m_Heading; } - float GetGuardPointX() const { return guard_x; } - float GetGuardPointY() const { return guard_y; } - float GetGuardPointZ() const { return guard_z; } - float GetGuardPointH() const { return guard_heading; } + float GetGuardPointX() const { return m_GuardPoint.m_X; } + float GetGuardPointY() const { return m_GuardPoint.m_Y; } + float GetGuardPointZ() const { return m_GuardPoint.m_Z; } + float GetGuardPointH() const { return m_GuardPoint.m_Heading; } EmuAppearance GetGuardPointAnim() const { return guard_anim; } void SaveGuardPointAnim(EmuAppearance anim) { guard_anim = anim; } @@ -295,7 +295,7 @@ public: void NextGuardPosition(); void SaveGuardSpot(bool iClearGuardSpot = false); - inline bool IsGuarding() const { return(guard_heading != 0); } + inline bool IsGuarding() const { return(m_GuardPoint.m_Heading != 0); } void SaveGuardSpotCharm(); void RestoreGuardSpotCharm(); void AI_SetRoambox(float iDist, float iRoamDist, uint32 iDelay = 2500, uint32 iMinDelay = 2500); @@ -473,7 +473,7 @@ protected: void _ClearWaypints(); int max_wp; int save_wp; - float guard_x, guard_y, guard_z, guard_heading; + xyz_heading m_GuardPoint; float guard_x_saved, guard_y_saved, guard_z_saved, guard_heading_saved; EmuAppearance guard_anim; float roambox_max_x; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 6f4b3e90a..606149925 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -187,18 +187,15 @@ void NPC::MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot) } if (saveguardspot) { - guard_x = mtx; - guard_y = mty; - guard_z = mtz; - guard_heading = mth; + m_GuardPoint = xyz_heading(mtx, mty, mtz, mth); - if(guard_heading == 0) - guard_heading = 0.0001; //hack to make IsGuarding simpler + if(m_GuardPoint.m_Heading == 0) + m_GuardPoint.m_Heading = 0.0001; //hack to make IsGuarding simpler - if(guard_heading == -1) - guard_heading = this->CalculateHeadingToTarget(mtx, mty); + if(m_GuardPoint.m_Heading == -1) + m_GuardPoint.m_Heading = this->CalculateHeadingToTarget(mtx, mty); - mlog(AI__WAYPOINTS, "Setting guard position to (%.3f, %.3f, %.3f)", guard_x, guard_y, guard_z); + mlog(AI__WAYPOINTS, "Setting guard position to %s", to_string(static_cast(m_GuardPoint)).c_str()); } m_CurrentWayPoint = xyz_heading(mtx, mty, mtz, mth); @@ -425,28 +422,23 @@ void NPC::SetWaypointPause() void NPC::SaveGuardSpot(bool iClearGuardSpot) { if (iClearGuardSpot) { mlog(AI__WAYPOINTS, "Clearing guard order."); - guard_x = 0; - guard_y = 0; - guard_z = 0; - guard_heading = 0; + m_GuardPoint = xyz_heading(0, 0, 0, 0); } else { - guard_x = m_Position.m_X; - guard_y = m_Position.m_Y; - guard_z = m_Position.m_Z; - guard_heading = m_Position.m_Heading; - if(guard_heading == 0) - guard_heading = 0.0001; //hack to make IsGuarding simpler - mlog(AI__WAYPOINTS, "Setting guard position to (%.3f, %.3f, %.3f)", guard_x, guard_y, guard_z); + m_GuardPoint = m_Position; + + if(m_GuardPoint.m_Heading == 0) + m_GuardPoint.m_Heading = 0.0001; //hack to make IsGuarding simpler + mlog(AI__WAYPOINTS, "Setting guard position to %s", to_string(static_cast(m_GuardPoint)).c_str()); } } void NPC::NextGuardPosition() { - if (!CalculateNewPosition2(guard_x, guard_y, guard_z, GetMovespeed())) { - SetHeading(guard_heading); + if (!CalculateNewPosition2(m_GuardPoint.m_X, m_GuardPoint.m_Y, m_GuardPoint.m_Z, GetMovespeed())) { + SetHeading(m_GuardPoint.m_Heading); mlog(AI__WAYPOINTS, "Unable to move to next guard position. Probably rooted."); } - else if((m_Position.m_X == guard_x) && (m_Position.m_Y == guard_y) && (m_Position.m_Z == guard_z)) + else if((m_Position.m_X == m_GuardPoint.m_X) && (m_Position.m_Y == m_GuardPoint.m_Y) && (m_Position.m_Z == m_GuardPoint.m_Z)) { if(moved) { @@ -1336,16 +1328,16 @@ int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) { void NPC::SaveGuardSpotCharm() { - guard_x_saved = guard_x; - guard_y_saved = guard_y; - guard_z_saved = guard_z; - guard_heading_saved = guard_heading; + guard_x_saved = m_GuardPoint.m_X; + guard_y_saved = m_GuardPoint.m_Y; + guard_z_saved = m_GuardPoint.m_Z; + guard_heading_saved = m_GuardPoint.m_Heading; } void NPC::RestoreGuardSpotCharm() { - guard_x = guard_x_saved; - guard_y = guard_y_saved; - guard_z = guard_z_saved; - guard_heading = guard_heading_saved; + m_GuardPoint.m_X = guard_x_saved; + m_GuardPoint.m_Y = guard_y_saved; + m_GuardPoint.m_Z = guard_z_saved; + m_GuardPoint.m_Heading = guard_heading_saved; } From c060723762e7c2bf2d0ae654dee1745e298a922a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 14:34:27 -0800 Subject: [PATCH 030/253] guard_x_saved, guard_y_saved, guard_z_saved, guard_heading_saved converted to m_GuardPointSaved --- zone/npc.cpp | 7 ++----- zone/npc.h | 2 +- zone/waypoints.cpp | 10 ++-------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/zone/npc.cpp b/zone/npc.cpp index 4469292f6..b43a36611 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -115,7 +115,8 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float enraged_timer(1000), taunt_timer(TauntReuseTime * 1000), m_SpawnPoint(x,y,z,heading), - m_GuardPoint(-1,-1,-1,0) + m_GuardPoint(-1,-1,-1,0), + m_GuardPointSaved(0,0,0,0) { //What is the point of this, since the names get mangled.. Mob* mob = entity_list.GetMob(name); @@ -346,10 +347,6 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float reface_timer = new Timer(15000); reface_timer->Disable(); qGlobals = nullptr; - guard_x_saved = 0; - guard_y_saved = 0; - guard_z_saved = 0; - guard_heading_saved = 0; SetEmoteID(d->emoteid); InitializeBuffSlots(); CalcBonuses(); diff --git a/zone/npc.h b/zone/npc.h index ce943174c..9b0b68b28 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -474,7 +474,7 @@ protected: int max_wp; int save_wp; xyz_heading m_GuardPoint; - float guard_x_saved, guard_y_saved, guard_z_saved, guard_heading_saved; + xyz_heading m_GuardPointSaved; EmuAppearance guard_anim; float roambox_max_x; float roambox_max_y; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 606149925..e3193c2c8 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1328,16 +1328,10 @@ int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) { void NPC::SaveGuardSpotCharm() { - guard_x_saved = m_GuardPoint.m_X; - guard_y_saved = m_GuardPoint.m_Y; - guard_z_saved = m_GuardPoint.m_Z; - guard_heading_saved = m_GuardPoint.m_Heading; + m_GuardPointSaved = m_GuardPoint; } void NPC::RestoreGuardSpotCharm() { - m_GuardPoint.m_X = guard_x_saved; - m_GuardPoint.m_Y = guard_y_saved; - m_GuardPoint.m_Z = guard_z_saved; - m_GuardPoint.m_Heading = guard_heading_saved; + m_GuardPoint = m_GuardPointSaved; } From f9036ddc6ac0c369619c30bb152b166d34d4dc94 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 15:05:50 -0800 Subject: [PATCH 031/253] GetGuardPointX(), GetGuardPointY(), GetGuardPointZ(), and GetGuardPointH() replaced with GetGuardPoint() --- zone/lua_npc.cpp | 6 +++--- zone/npc.h | 5 +---- zone/perl_npc.cpp | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/zone/lua_npc.cpp b/zone/lua_npc.cpp index 869efb019..e247e34e3 100644 --- a/zone/lua_npc.cpp +++ b/zone/lua_npc.cpp @@ -334,17 +334,17 @@ float Lua_NPC::GetSpawnPointH() { float Lua_NPC::GetGuardPointX() { Lua_Safe_Call_Real(); - return self->GetGuardPointX(); + return self->GetGuardPoint().m_X; } float Lua_NPC::GetGuardPointY() { Lua_Safe_Call_Real(); - return self->GetGuardPointY(); + return self->GetGuardPoint().m_Y; } float Lua_NPC::GetGuardPointZ() { Lua_Safe_Call_Real(); - return self->GetGuardPointZ(); + return self->GetGuardPoint().m_Z; } void Lua_NPC::SetPrimSkill(int skill_id) { diff --git a/zone/npc.h b/zone/npc.h index 9b0b68b28..4bb15de9a 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -215,10 +215,7 @@ public: float GetSpawnPointY() const { return m_SpawnPoint.m_Y; } float GetSpawnPointZ() const { return m_SpawnPoint.m_Z; } float GetSpawnPointH() const { return m_SpawnPoint.m_Heading; } - float GetGuardPointX() const { return m_GuardPoint.m_X; } - float GetGuardPointY() const { return m_GuardPoint.m_Y; } - float GetGuardPointZ() const { return m_GuardPoint.m_Z; } - float GetGuardPointH() const { return m_GuardPoint.m_Heading; } + xyz_heading const GetGuardPoint() const { return m_GuardPoint; } EmuAppearance GetGuardPointAnim() const { return guard_anim; } void SaveGuardPointAnim(EmuAppearance anim) { guard_anim = anim; } diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index c1f8d8828..2696eae7d 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -1653,7 +1653,7 @@ XS(XS_NPC_GetGuardPointX) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetGuardPointX(); + RETVAL = THIS->GetGuardPoint().m_X; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -1680,7 +1680,7 @@ XS(XS_NPC_GetGuardPointY) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetGuardPointY(); + RETVAL = THIS->GetGuardPoint().m_Y; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -1707,7 +1707,7 @@ XS(XS_NPC_GetGuardPointZ) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetGuardPointZ(); + RETVAL = THIS->GetGuardPoint().m_Z; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); From 69dbdb24854d09fae401646f2fa61e8d8febcd30 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 15:29:13 -0800 Subject: [PATCH 032/253] GetSpawnPointX(). GetSpawnPointY(), GetSpawnPointZ(), and GetSpawnPointH() replaced with GetSpawnPoint() --- zone/lua_npc.cpp | 8 ++++---- zone/mob_ai.cpp | 9 +++++---- zone/npc.h | 5 +---- zone/perl_npc.cpp | 8 ++++---- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/zone/lua_npc.cpp b/zone/lua_npc.cpp index e247e34e3..8e04a9ae6 100644 --- a/zone/lua_npc.cpp +++ b/zone/lua_npc.cpp @@ -314,22 +314,22 @@ int Lua_NPC::GetSpawnPointID() { float Lua_NPC::GetSpawnPointX() { Lua_Safe_Call_Real(); - return self->GetSpawnPointX(); + return self->GetSpawnPoint().m_X; } float Lua_NPC::GetSpawnPointY() { Lua_Safe_Call_Real(); - return self->GetSpawnPointY(); + return self->GetSpawnPoint().m_Y; } float Lua_NPC::GetSpawnPointZ() { Lua_Safe_Call_Real(); - return self->GetSpawnPointZ(); + return self->GetSpawnPoint().m_Z; } float Lua_NPC::GetSpawnPointH() { Lua_Safe_Call_Real(); - return self->GetSpawnPointH(); + return self->GetSpawnPoint().m_Heading; } float Lua_NPC::GetGuardPointX() { diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 9c720957e..c510aa035 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1125,19 +1125,20 @@ void Mob::AI_Process() { if(DivineAura()) return; + auto npcSpawnPoint = CastToNPC()->GetSpawnPoint(); if(GetSpecialAbility(TETHER)) { float tether_range = static_cast(GetSpecialAbilityParam(TETHER, 0)); tether_range = tether_range > 0.0f ? tether_range * tether_range : pAggroRange * pAggroRange; - if(DistNoRootNoZ(CastToNPC()->GetSpawnPointX(), CastToNPC()->GetSpawnPointY()) > tether_range) { - GMMove(CastToNPC()->GetSpawnPointX(), CastToNPC()->GetSpawnPointY(), CastToNPC()->GetSpawnPointZ(), CastToNPC()->GetSpawnPointH()); + if(DistNoRootNoZ(npcSpawnPoint.m_X, npcSpawnPoint.m_Y) > tether_range) { + GMMove(npcSpawnPoint.m_X, npcSpawnPoint.m_Y, npcSpawnPoint.m_Z, npcSpawnPoint.m_Heading); } } else if(GetSpecialAbility(LEASH)) { float leash_range = static_cast(GetSpecialAbilityParam(LEASH, 0)); leash_range = leash_range > 0.0f ? leash_range * leash_range : pAggroRange * pAggroRange; - if(DistNoRootNoZ(CastToNPC()->GetSpawnPointX(), CastToNPC()->GetSpawnPointY()) > leash_range) { - GMMove(CastToNPC()->GetSpawnPointX(), CastToNPC()->GetSpawnPointY(), CastToNPC()->GetSpawnPointZ(), CastToNPC()->GetSpawnPointH()); + if(DistNoRootNoZ(npcSpawnPoint.m_X, npcSpawnPoint.m_Y) > leash_range) { + GMMove(npcSpawnPoint.m_X, npcSpawnPoint.m_Y, npcSpawnPoint.m_Z, npcSpawnPoint.m_Heading); SetHP(GetMaxHP()); BuffFadeAll(); WipeHateList(); diff --git a/zone/npc.h b/zone/npc.h index 4bb15de9a..55b613289 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -211,10 +211,7 @@ public: uint32 GetSp2() const { return spawn_group; } uint32 GetSpawnPointID() const; - float GetSpawnPointX() const { return m_SpawnPoint.m_X; } - float GetSpawnPointY() const { return m_SpawnPoint.m_Y; } - float GetSpawnPointZ() const { return m_SpawnPoint.m_Z; } - float GetSpawnPointH() const { return m_SpawnPoint.m_Heading; } + xyz_heading const GetSpawnPoint() const { return m_SpawnPoint; } xyz_heading const GetGuardPoint() const { return m_GuardPoint; } EmuAppearance GetGuardPointAnim() const { return guard_anim; } void SaveGuardPointAnim(EmuAppearance anim) { guard_anim = anim; } diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index 2696eae7d..f12f97d26 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -1545,7 +1545,7 @@ XS(XS_NPC_GetSpawnPointX) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetSpawnPointX(); + RETVAL = THIS->GetSpawnPoint().m_X; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -1572,7 +1572,7 @@ XS(XS_NPC_GetSpawnPointY) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetSpawnPointY(); + RETVAL = THIS->GetSpawnPoint().m_Y; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -1599,7 +1599,7 @@ XS(XS_NPC_GetSpawnPointZ) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetSpawnPointZ(); + RETVAL = THIS->GetSpawnPoint().m_Z; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -1626,7 +1626,7 @@ XS(XS_NPC_GetSpawnPointH) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetSpawnPointH(); + RETVAL = THIS->GetSpawnPoint().m_Heading; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); From 2e6711916e4dc2e178850406b07fa1134c1f5d28 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 15:40:24 -0800 Subject: [PATCH 033/253] GetClosestWaypoint converted to xyz_location --- zone/npc.h | 2 +- zone/waypoints.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zone/npc.h b/zone/npc.h index 55b613289..4491d5e6c 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -282,7 +282,7 @@ public: void ResumeWandering(); void PauseWandering(int pausetime); void MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot); - void GetClosestWaypoint(std::list &wp_list, int count, float m_x, float m_y, float m_z); + void GetClosestWaypoint(std::list &wp_list, int count, const xyz_location& location ); uint32 GetEquipment(uint8 material_slot) const; // returns item id int32 GetEquipmentMaterial(uint8 material_slot) const; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index e3193c2c8..51f68e952 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -260,7 +260,7 @@ void NPC::CalculateNewWaypoint() case 1: //10 closest { std::list closest; - GetClosestWaypoint(closest, 10, GetX(), GetY(), GetZ()); + GetClosestWaypoint(closest, 10, GetPosition()); std::list::iterator iter = closest.begin(); if(closest.size() != 0) { @@ -316,7 +316,7 @@ void NPC::CalculateNewWaypoint() case 5: //pick random closest 5 and pick one that's in sight { std::list closest; - GetClosestWaypoint(closest, 5, GetX(), GetY(), GetZ()); + GetClosestWaypoint(closest, 5, GetPosition()); std::list::iterator iter = closest.begin(); while(iter != closest.end()) @@ -357,7 +357,7 @@ bool wp_distance_pred(const wp_distance& left, const wp_distance& right) return left.dist < right.dist; } -void NPC::GetClosestWaypoint(std::list &wp_list, int count, float m_x, float m_y, float m_z) +void NPC::GetClosestWaypoint(std::list &wp_list, int count, const xyz_location& location) { wp_list.clear(); if(Waypoints.size() <= count) @@ -372,11 +372,11 @@ void NPC::GetClosestWaypoint(std::list &wp_list, int count, float m_x, f std::list distances; for(int i = 0; i < Waypoints.size(); ++i) { - float cur_x = (Waypoints[i].x - m_x); + float cur_x = (Waypoints[i].x - location.m_X); cur_x *= cur_x; - float cur_y = (Waypoints[i].y - m_y); + float cur_y = (Waypoints[i].y - location.m_Y); cur_y *= cur_y; - float cur_z = (Waypoints[i].z - m_z); + float cur_z = (Waypoints[i].z - location.m_Z); cur_z *= cur_z; float cur_dist = cur_x + cur_y + cur_z; wp_distance w_dist; From e6d23228e53f185395309982e567e51b20a12120 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 15:58:44 -0800 Subject: [PATCH 034/253] GetSpawnPointX(), GetSpawnPointY(), GetSpawnPointZ(), and GetSpawnPointH(), converted to GetSpawnPoint() --- zone/lua_npc.cpp | 3 ++- zone/npc.h | 4 ++-- zone/perl_npc.cpp | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/zone/lua_npc.cpp b/zone/lua_npc.cpp index 8e04a9ae6..95ae4c5c9 100644 --- a/zone/lua_npc.cpp +++ b/zone/lua_npc.cpp @@ -269,7 +269,8 @@ void Lua_NPC::PauseWandering(int pause_time) { void Lua_NPC::MoveTo(float x, float y, float z, float h, bool save) { Lua_Safe_Call_Void(); - self->MoveTo(x, y, z, h, save); + auto position = xyz_heading(x, y, z, h); + self->MoveTo(position, save); } void Lua_NPC::NextGuardPosition() { diff --git a/zone/npc.h b/zone/npc.h index 4491d5e6c..dde3ebf2a 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -281,8 +281,8 @@ public: void StopWandering(); void ResumeWandering(); void PauseWandering(int pausetime); - void MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot); - void GetClosestWaypoint(std::list &wp_list, int count, const xyz_location& location ); + void MoveTo(const xyz_heading& position, bool saveguardspot); + void GetClosestWaypoint(std::list &wp_list, int count, const xyz_location& location); uint32 GetEquipment(uint8 material_slot) const; // returns item id int32 GetEquipmentMaterial(uint8 material_slot) const; diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index f12f97d26..330e21283 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -1345,7 +1345,8 @@ XS(XS_NPC_MoveTo) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - THIS->MoveTo(mtx, mty, mtz, mth, saveguard); + auto position = xyz_heading(mtx, mty, mtz, mth); + THIS->MoveTo(position, saveguard); } XSRETURN_EMPTY; } From 0570722b3b6cd5d117cca59c46f39a29027c0bad Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 16:30:09 -0800 Subject: [PATCH 035/253] MoveTo converted to xyz_heading --- zone/command.cpp | 2 +- zone/npc.cpp | 4 ++-- zone/npc.h | 2 +- zone/questmgr.cpp | 15 ++++++++------- zone/waypoints.cpp | 12 ++++++------ 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 1dfab5bb0..9783361e5 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -2430,7 +2430,7 @@ void command_spawn(Client *c, const Seperator *sep) LogFile->write(EQEMuLog::Debug,"#spawn Spawning:"); #endif - NPC* npc = NPC::SpawnNPC(sep->argplus[1], c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(), c); + NPC* npc = NPC::SpawnNPC(sep->argplus[1], c->GetPosition(), c); if (!npc) { c->Message(0, "Format: #spawn name race level material hp gender class priweapon secweapon merchantid bodytype - spawns a npc those parameters."); c->Message(0, "Name Format: NPCFirstname_NPCLastname - All numbers in a name are stripped and \"_\" characters become a space."); diff --git a/zone/npc.cpp b/zone/npc.cpp index b43a36611..03fc7c45a 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -773,7 +773,7 @@ bool NPC::DatabaseCastAccepted(int spell_id) { return false; } -NPC* NPC::SpawnNPC(const char* spawncommand, float in_x, float in_y, float in_z, float in_heading, Client* client) { +NPC* NPC::SpawnNPC(const char* spawncommand, const xyz_heading& position, Client* client) { if(spawncommand == 0 || spawncommand[0] == 0) { return 0; } @@ -932,7 +932,7 @@ NPC* NPC::SpawnNPC(const char* spawncommand, float in_x, float in_y, float in_z, npc_type->prim_melee_type = 28; npc_type->sec_melee_type = 28; - NPC* npc = new NPC(npc_type, 0, in_x, in_y, in_z, in_heading/8, FlyMode3); + NPC* npc = new NPC(npc_type, 0, position.m_X, position.m_Y, position.m_Z, position.m_Heading, FlyMode3); npc->GiveNPCTypeData(npc_type); entity_list.AddNPC(npc); diff --git a/zone/npc.h b/zone/npc.h index dde3ebf2a..0c1c42aa8 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -94,7 +94,7 @@ class AA_SwarmPetInfo; class NPC : public Mob { public: - static NPC* SpawnNPC(const char* spawncommand, float in_x, float in_y, float in_z, float in_heading = 0, Client* client = 0); + static NPC* SpawnNPC(const char* spawncommand, const xyz_heading& position, Client* client = 0); static int8 GetAILevel(bool iForceReRead = false); NPC(const NPCType* data, Spawn2* respawn, float x, float y, float z, float heading, int iflymode, bool IsCorpse = false); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index e014c01cd..0c56a46bc 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -963,7 +963,7 @@ uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) { spells[curspell].skill != 52 && ( !RuleB(Spells, UseCHAScribeHack) || spells[curspell].effectid[EFFECT_COUNT - 1] != 10 ) ) - { + { if(IsDiscipline(curspell)){ //we may want to come up with a function like Client::GetNextAvailableSpellBookSlot() to help speed this up a little for(uint32 r = 0; r < MAX_PP_DISCIPLINES; r++) { @@ -977,12 +977,12 @@ uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) { SpellGlobalCheckResult = initiator->SpellGlobalCheck(curspell, Char_ID); if (SpellGlobalCheckResult) { initiator->GetPP().disciplines.values[r] = curspell; - database.SaveCharacterDisc(Char_ID, r, curspell); + database.SaveCharacterDisc(Char_ID, r, curspell); initiator->SendDisciplineUpdate(); initiator->Message(0, "You have learned a new discipline!"); count++; //success counter } - break; //continue the 1st loop + break; //continue the 1st loop } else { initiator->GetPP().disciplines.values[r] = curspell; @@ -1558,7 +1558,8 @@ void QuestManager::moveto(float x, float y, float z, float h, bool saveguardspot if (!owner || !owner->IsNPC()) return; - owner->CastToNPC()->MoveTo(x, y, z, h, saveguardspot); + auto position = xyz_heading(x,y,z,h); + owner->CastToNPC()->MoveTo(position, saveguardspot); } void QuestManager::resume() { @@ -2926,7 +2927,7 @@ void QuestManager::CrossZoneSignalPlayerByName(const char *CharName, uint32 data CZSC->data = data; worldserver.SendPacket(pack); safe_delete(pack); -} +} void QuestManager::CrossZoneMessagePlayerByName(uint32 Type, const char *CharName, const char *Message){ uint32 message_len = strlen(CharName) + 1; @@ -2936,7 +2937,7 @@ void QuestManager::CrossZoneMessagePlayerByName(uint32 Type, const char *CharNam CZSC->Type = Type; strn0cpy(CZSC->CharName, CharName, 64); strn0cpy(CZSC->Message, Message, 512); - worldserver.SendPacket(pack); + worldserver.SendPacket(pack); safe_delete(pack); } @@ -2946,7 +2947,7 @@ void QuestManager::CrossZoneSetEntityVariableByNPCTypeID(uint32 npctype_id, cons ServerPacket* pack = new ServerPacket(ServerOP_CZSetEntityVariableByNPCTypeID, sizeof(CZSetEntVarByNPCTypeID_Struct) + message_len + message_len2); CZSetEntVarByNPCTypeID_Struct* CZSNBYNID = (CZSetEntVarByNPCTypeID_Struct*)pack->pBuffer; CZSNBYNID->npctype_id = npctype_id; - strn0cpy(CZSNBYNID->id, id, 256); + strn0cpy(CZSNBYNID->id, id, 256); strn0cpy(CZSNBYNID->m_var, m_var, 256); worldserver.SendPacket(pack); safe_delete(pack); diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 51f68e952..b36f63106 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -161,7 +161,7 @@ void NPC::PauseWandering(int pausetime) return; } -void NPC::MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot) +void NPC::MoveTo(const xyz_heading& position, bool saveguardspot) { // makes mob walk to specified location if (IsNPC() && GetGrid() != 0) { // he is on a grid @@ -176,29 +176,29 @@ void NPC::MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot) save_wp=cur_wp; // save the current waypoint cur_wp=-1; // flag this move as quest controlled } - mlog(AI__WAYPOINTS, "MoveTo (%.3f, %.3f, %.3f), pausing regular grid wandering. Grid %d, save_wp %d", mtx, mty, mtz, -GetGrid(), save_wp); + mlog(AI__WAYPOINTS, "MoveTo %s, pausing regular grid wandering. Grid %d, save_wp %d",to_string(static_cast(position)).c_str(), -GetGrid(), save_wp); } else { // not on a grid roamer=true; save_wp=0; cur_wp=-2; // flag as quest controlled w/no grid - mlog(AI__WAYPOINTS, "MoveTo (%.3f, %.3f, %.3f) without a grid.", mtx, mty, mtz); + mlog(AI__WAYPOINTS, "MoveTo %s without a grid.", to_string(static_cast(position)).c_str()); } if (saveguardspot) { - m_GuardPoint = xyz_heading(mtx, mty, mtz, mth); + m_GuardPoint = position; if(m_GuardPoint.m_Heading == 0) m_GuardPoint.m_Heading = 0.0001; //hack to make IsGuarding simpler if(m_GuardPoint.m_Heading == -1) - m_GuardPoint.m_Heading = this->CalculateHeadingToTarget(mtx, mty); + m_GuardPoint.m_Heading = this->CalculateHeadingToTarget(position.m_X, position.m_Y); mlog(AI__WAYPOINTS, "Setting guard position to %s", to_string(static_cast(m_GuardPoint)).c_str()); } - m_CurrentWayPoint = xyz_heading(mtx, mty, mtz, mth); + m_CurrentWayPoint = position; cur_wp_pause = 0; pLastFightingDelayMoving = 0; if(AIwalking_timer->Enabled()) From 54bc1b06e4b143ecc629d182cd5d63255aa948eb Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 17:32:11 -0800 Subject: [PATCH 036/253] NPC constructor converted to use xyz_heading --- zone/aa.cpp | 47 ++++++++++++++++++++++---------------------- zone/bot.cpp | 4 ++-- zone/client.cpp | 11 +++++++---- zone/command.cpp | 2 +- zone/forage.cpp | 4 +++- zone/horse.cpp | 2 +- zone/lua_general.cpp | 10 +++++----- zone/merc.cpp | 34 ++++++++++++++++---------------- zone/npc.cpp | 14 ++++++------- zone/npc.h | 4 ++-- zone/pathing.cpp | 10 ++++++---- zone/pets.cpp | 2 +- zone/questmgr.cpp | 22 ++++++++------------- zone/spawn2.cpp | 2 +- zone/trap.cpp | 10 +++++++--- zone/zone.cpp | 10 +++++----- 16 files changed, 96 insertions(+), 92 deletions(-) diff --git a/zone/aa.cpp b/zone/aa.cpp index 3a3101746..87b997cca 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -319,10 +319,10 @@ void Client::ActivateAA(aaID activate){ } // Check if AA is expendable if (aas_send[activate - activate_val]->special_category == 7) { - + // Add the AA cost to the extended profile to track overall total m_epp.expended_aa += aas_send[activate]->cost; - + SetAA(activate, 0); SaveAA(); /* Save Character AA */ @@ -598,12 +598,12 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u if(summon_count > MAX_SWARM_PETS) summon_count = MAX_SWARM_PETS; - static const float swarm_pet_x[MAX_SWARM_PETS] = { 5, -5, 5, -5, - 10, -10, 10, -10, - 8, -8, 8, -8 }; - static const float swarm_pet_y[MAX_SWARM_PETS] = { 5, 5, -5, -5, - 10, 10, -10, -10, - 8, 8, -8, -8 }; + static const xy_location swarmPetLocations[MAX_SWARM_PETS] = { + {5, 5}, {-5, 5}, {5, -5}, {-5, -5}, + {10, 10}, {-10, 10}, {10, -10}, {-10, -10}, + {8, 8}, {-8, 8}, {8, -8}, {-8, -8} + }; + while(summon_count > 0) { int pet_duration = pet.duration; if(duration_override > 0) @@ -620,8 +620,8 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u NPC* npca = new NPC( (npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer 0, - GetX()+swarm_pet_x[summon_count], GetY()+swarm_pet_y[summon_count], - GetZ(), GetHeading(), FlyMode3); + GetPosition() + swarmPetLocations[summon_count], + FlyMode3); if (followme) npca->SetFollowID(GetID()); @@ -692,12 +692,11 @@ void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_overrid if(summon_count > MAX_SWARM_PETS) summon_count = MAX_SWARM_PETS; - static const float swarm_pet_x[MAX_SWARM_PETS] = { 5, -5, 5, -5, - 10, -10, 10, -10, - 8, -8, 8, -8 }; - static const float swarm_pet_y[MAX_SWARM_PETS] = { 5, 5, -5, -5, - 10, 10, -10, -10, - 8, 8, -8, -8 }; + static const xy_location swarmPetLocations[MAX_SWARM_PETS] = { + {5, 5}, {-5, 5}, {5, -5}, {-5, -5}, + {10, 10}, {-10, 10}, {10, -10}, {-10, -10}, + {8, 8}, {-8, 8}, {8, -8}, {-8, -8} + }; while(summon_count > 0) { int pet_duration = pet.duration; @@ -715,8 +714,8 @@ void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_overrid NPC* npca = new NPC( (npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer 0, - GetX()+swarm_pet_x[summon_count], GetY()+swarm_pet_y[summon_count], - GetZ(), GetHeading(), FlyMode3); + GetPosition()+swarmPetLocations[summon_count], + FlyMode3); if (followme) npca->SetFollowID(GetID()); @@ -899,7 +898,7 @@ void Mob::WakeTheDead(uint16 spell_id, Mob *target, uint32 duration) make_npc->d_meele_texture1 = 0; make_npc->d_meele_texture2 = 0; - NPC* npca = new NPC(make_npc, 0, GetX(), GetY(), GetZ(), GetHeading(), FlyMode3); + NPC* npca = new NPC(make_npc, 0, GetPosition(), FlyMode3); if(!npca->GetSwarmInfo()){ AA_SwarmPetInfo* nSI = new AA_SwarmPetInfo; @@ -1056,7 +1055,7 @@ void Client::BuyAA(AA_Action* action) /* Do Player Profile rank calculations and set player profile */ SaveAA(); /* Save to Database to avoid having to write the whole AA array to the profile, only write changes*/ - // database.SaveCharacterAA(this->CharacterID(), aa2->id, (cur_level + 1)); + // database.SaveCharacterAA(this->CharacterID(), aa2->id, (cur_level + 1)); if ((RuleB(AA, Stacking) && (GetClientVersionBit() >= 4) && (aa2->hotkey_sid == 4294967295u)) && ((aa2->max_level == (cur_level + 1)) && aa2->sof_next_id)){ @@ -1077,7 +1076,7 @@ void Client::BuyAA(AA_Action* action) if (cur_level < 1){ Message(15, "You have gained the ability \"%s\" at a cost of %d ability %s.", aa2->name, real_cost, (real_cost>1) ? "points" : "point"); - /* QS: Player_Log_AA_Purchases */ + /* QS: Player_Log_AA_Purchases */ if (RuleB(QueryServ, PlayerLogAAPurchases)){ std::string event_desc = StringFormat("Initial AA Purchase :: aa_name:%s aa_id:%i at cost:%i in zoneid:%i instid:%i", aa2->name, aa2->id, real_cost, this->GetZoneID(), this->GetInstanceID()); QServ->PlayerLogEvent(Player_Log_AA_Purchases, this->CharacterID(), event_desc); @@ -1522,13 +1521,13 @@ bool ZoneDatabase::LoadAAEffects2() { return true; } void Client::ResetAA(){ - RefundAA(); + RefundAA(); uint32 i; for(i=0;iAA = 0; aa[i]->value = 0; m_pp.aa_array[MAX_PP_AA_ARRAY].AA = 0; - m_pp.aa_array[MAX_PP_AA_ARRAY].value = 0; + m_pp.aa_array[MAX_PP_AA_ARRAY].value = 0; } std::map::iterator itr; @@ -1544,7 +1543,7 @@ void Client::ResetAA(){ m_pp.raid_leadership_exp = 0; database.DeleteCharacterAAs(this->CharacterID()); - SaveAA(); + SaveAA(); SendAATable(); database.DeleteCharacterLeadershipAAs(this->CharacterID()); Kick(); diff --git a/zone/bot.cpp b/zone/bot.cpp index f2bde8980..05dead52a 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -9,7 +9,7 @@ extern volatile bool ZoneLoaded; // This constructor is used during the bot create command -Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, 0, 0, 0, 0, 0, 0, false), rest_timer(1) { +Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, nullptr, xyz_heading::Origin(), 0, false), rest_timer(1) { if(botOwner) { this->SetBotOwner(botOwner); this->_botOwnerCharacterID = botOwner->CharacterID(); @@ -99,7 +99,7 @@ Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, 0, 0, 0, 0, } // This constructor is used when the bot is loaded out of the database -Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double totalPlayTime, uint32 lastZoneId, NPCType npcTypeData) : NPC(&npcTypeData, 0, 0, 0, 0, 0, 0, false), rest_timer(1) { +Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double totalPlayTime, uint32 lastZoneId, NPCType npcTypeData) : NPC(&npcTypeData, nullptr, xyz_heading::Origin(), 0, false), rest_timer(1) { this->_botOwnerCharacterID = botOwnerCharacterID; if(this->_botOwnerCharacterID > 0) { diff --git a/zone/client.cpp b/zone/client.cpp index 2c6c73b8a..5f5089d2b 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -6422,8 +6422,11 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid if(summon_count > MAX_SWARM_PETS) summon_count = MAX_SWARM_PETS; - static const float swarm_pet_x[MAX_SWARM_PETS] = { 5, -5, 5, -5, 10, -10, 10, -10, 8, -8, 8, -8 }; - static const float swarm_pet_y[MAX_SWARM_PETS] = { 5, 5, -5, -5, 10, 10, -10, -10, 8, 8, -8, -8 }; + static const xy_location swarmPetLocations[MAX_SWARM_PETS] = { + {5, 5}, {-5, 5}, {5, -5}, {-5, -5}, + {10, 10}, {-10, 10}, {10, -10}, {-10, -10}, + {8, 8}, {-8, 8}, {8, -8}, {-8, -8} + }; while(summon_count > 0) { NPCType *npc_dup = nullptr; @@ -6435,8 +6438,8 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid NPC* npca = new NPC( (npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer 0, - GetX()+swarm_pet_x[summon_count], GetY()+swarm_pet_y[summon_count], - GetZ(), GetHeading(), FlyMode3); + GetPosition()+swarmPetLocations[summon_count], + FlyMode3); if(!npca->GetSwarmInfo()){ AA_SwarmPetInfo* nSI = new AA_SwarmPetInfo; diff --git a/zone/command.cpp b/zone/command.cpp index 9783361e5..d74fedabe 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -2489,7 +2489,7 @@ void command_npctypespawn(Client *c, const Seperator *sep) const NPCType* tmp = 0; if ((tmp = database.GetNPCType(atoi(sep->arg[1])))) { //tmp->fixedZ = 1; - NPC* npc = new NPC(tmp, 0, c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(), FlyMode3); + NPC* npc = new NPC(tmp, 0, c->GetPosition(), FlyMode3); if (npc && sep->IsNumber(2)) npc->SetNPCFactionID(atoi(sep->arg[2])); diff --git a/zone/forage.cpp b/zone/forage.cpp index 459fee6a7..2760a779c 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -315,7 +315,9 @@ void Client::GoFish() if(npc_chance < MakeRandomInt(0, 99)) { const NPCType* tmp = database.GetNPCType(npc_id); if(tmp != nullptr) { - NPC* npc = new NPC(tmp, nullptr, GetX()+3, GetY(), GetZ(), GetHeading(), FlyMode3); + auto positionNPC = GetPosition(); + positionNPC.m_X = positionNPC.m_X + 3; + NPC* npc = new NPC(tmp, nullptr, positionNPC, FlyMode3); npc->AddLootTable(); npc->AddToHateList(this, 1, 0, false); //no help yelling diff --git a/zone/horse.cpp b/zone/horse.cpp index df7c7e7c1..cdcd8a28e 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -29,7 +29,7 @@ std::map Horse::horse_types; LinkedList horses_auto_delete; Horse::Horse(Client *_owner, uint16 spell_id, float x, float y, float z, float heading) - : NPC(GetHorseType(spell_id), nullptr, x, y, z, heading, FlyMode3) + : NPC(GetHorseType(spell_id), nullptr, xyz_heading(x, y, z, heading), FlyMode3) { //give the horse its proper name. strn0cpy(name, _owner->GetCleanName(), 55); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 09b0dcf53..f18ff95fb 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -124,7 +124,7 @@ void register_event(std::string package_name, std::string name, int evt, luabind e.encounter_name = name; e.lua_reference = func; e.event_id = static_cast(evt); - + auto liter = lua_encounter_events_registered.find(package_name); if(liter == lua_encounter_events_registered.end()) { std::list elist; @@ -201,7 +201,7 @@ void unregister_player_event(int evt) { void register_item_event(std::string name, int evt, int item_id, luabind::adl::object func) { std::string package_name = "item_"; package_name += std::to_string(static_cast(item_id)); - + if(luabind::type(func) == LUA_TFUNCTION) { register_event(package_name, name, evt, func); } @@ -1036,7 +1036,7 @@ void lua_add_spawn_point(luabind::adl::object table) { int condition_min_value = 0; bool enabled = true; int animation = 0; - + auto cur = table["spawn2_id"]; if(luabind::type(cur) != LUA_TNIL) { try { @@ -1284,7 +1284,7 @@ void lua_create_npc(luabind::adl::object table, float x, float y, float z, float if(luabind::type(table) != LUA_TTABLE) { return; } - + NPCType* npc_type = new NPCType; memset(npc_type, 0, sizeof(NPCType)); @@ -1391,7 +1391,7 @@ void lua_create_npc(luabind::adl::object table, float x, float y, float z, float LuaCreateNPCParse(raid_target, bool, false); LuaCreateNPCParse(probability, uint8, 0); - NPC* npc = new NPC(npc_type, nullptr, x, y, z, heading, FlyMode3); + NPC* npc = new NPC(npc_type, nullptr, xyz_heading(x, y, z, heading), FlyMode3); npc->GiveNPCTypeData(npc_type); entity_list.AddNPC(npc); } diff --git a/zone/merc.cpp b/zone/merc.cpp index 2ecd0849e..aa8bb98c1 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -17,7 +17,7 @@ extern volatile bool ZoneLoaded; Merc::Merc(const NPCType* d, float x, float y, float z, float heading) -: NPC(d, 0, x, y, z, heading, 0, false), endupkeep_timer(1000), rest_timer(1), confidence_timer(6000), check_target_timer(2000) +: NPC(d, nullptr, xyz_heading(x, y, z, heading), 0, false), endupkeep_timer(1000), rest_timer(1), confidence_timer(6000), check_target_timer(2000) { base_hp = d->max_hp; base_mana = d->Mana; @@ -4925,11 +4925,11 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id, if(merc_template) { //TODO: Maybe add a way of updating client merc stats in a seperate function? like, for example, on leveling up. - const NPCType* npc_type_to_copy = database.GetMercType(merc_template->MercNPCID, merc_template->RaceID, c->GetLevel()); + const NPCType* npc_type_to_copy = database.GetMercType(merc_template->MercNPCID, merc_template->RaceID, c->GetLevel()); if(npc_type_to_copy != nullptr) { //This is actually a very terrible method of assigning stats, and should be changed at some point. See the comment in merc's deconstructor. - NPCType* npc_type = new NPCType; + NPCType* npc_type = new NPCType; memset(npc_type, 0, sizeof(NPCType)); memcpy(npc_type, npc_type_to_copy, sizeof(NPCType)); if(c && !updateFromDB) @@ -5099,7 +5099,7 @@ bool Merc::Spawn(Client *owner) { entity_list.AddMerc(this, true, true); SendPosition(); - + if (MERC_DEBUG > 0) owner->Message(7, "Mercenary Debug: Spawn."); @@ -5125,7 +5125,7 @@ void Client::SendMercResponsePackets(uint32 ResponseType) break; case 3: //Mercenary failed to spawn! SendMercMerchantResponsePacket(3); - break; + break; case 4: //Mercenaries are not allowed in raids! SendMercMerchantResponsePacket(4); break; @@ -5289,7 +5289,7 @@ void Client::UpdateMercTimer() { SendMercResponsePackets(16); } - + if (MERC_DEBUG > 0) Message(7, "Mercenary Debug: UpdateMercTimer Complete."); @@ -5312,7 +5312,7 @@ bool Client::CheckCanHireMerc(Mob* merchant, uint32 template_id) { MercTemplate* mercTemplate = zone->GetMercTemplate(template_id); //check for suspended merc - if(GetMercInfo().mercid != 0 && GetMercInfo().IsSuspended) { + if(GetMercInfo().mercid != 0 && GetMercInfo().IsSuspended) { SendMercResponsePackets(6); return false; } @@ -5343,7 +5343,7 @@ bool Client::CheckCanHireMerc(Mob* merchant, uint32 template_id) { return false; } } - + if (MERC_DEBUG > 0) Message(7, "Mercenary Debug: CheckCanHireMerc True."); @@ -5417,7 +5417,7 @@ bool Client::CheckCanSpawnMerc(uint32 template_id) { SendMercResponsePackets(9); return false; } - + if (MERC_DEBUG > 0) Message(7, "Mercenary Debug: CheckCanSpawnMerc True."); @@ -5440,7 +5440,7 @@ bool Client::CheckCanUnsuspendMerc() { Message(0, "You must wait %i seconds before unsuspending your mercenary.", GetPTimers().GetRemainingTime(pTimerMercSuspend)); return false; } - + if (MERC_DEBUG > 0) Message(7, "Mercenary Debug: CheckCanUnsuspendMerc True."); @@ -5588,7 +5588,7 @@ void Client::SendMercTimer(Merc* merc) { } -void Client::SpawnMerc(Merc* merc, bool setMaxStats) { +void Client::SpawnMerc(Merc* merc, bool setMaxStats) { if (!merc || !CheckCanSpawnMerc(merc->GetMercTemplateID())) { @@ -5607,7 +5607,7 @@ void Client::SpawnMerc(Merc* merc, bool setMaxStats) { GetMercInfo().SuspendedTime = 0; //SendMercTimer(merc); - + if (MERC_DEBUG > 0) Message(7, "Mercenary Debug: SpawnMerc Success."); @@ -5632,12 +5632,12 @@ bool Merc::Suspend() { mercOwner->GetMercTimer()->Disable(); mercOwner->SendMercSuspendResponsePacket(mercOwner->GetMercInfo().SuspendedTime); mercOwner->SendMercTimer(this); - + Depop(); // Start the timer to send the packet that refreshes the Unsuspend Button mercOwner->GetPTimers().Start(pTimerMercSuspend, RuleI(Mercs, SuspendIntervalS)); - + if (MERC_DEBUG > 0) mercOwner->Message(7, "Mercenary Debug: Suspend Complete."); @@ -5739,7 +5739,7 @@ bool Client::DismissMerc(uint32 MercID) { if (MERC_DEBUG > 0) Message(7, "Mercenary Debug: Dismiss Successful."); } - + if (GetMerc()) { GetMerc()->Depop(); @@ -5907,7 +5907,7 @@ bool Merc::MercJoinClientGroup() { if(MERC_DEBUG > 0) mercOwner->Message(7, "Mercenary Debug: Mercenary disbanded new group."); } - + } else if (AddMercToGroup(this, mercOwner->GetGroup())) { @@ -5997,7 +5997,7 @@ Merc* Client::GetMerc() { Message(7, "Mercenary Debug: GetMerc Owner Mismatch."); return (nullptr); } - + if (MERC_DEBUG > 0) //Message(7, "Mercenary Debug: GetMerc Success."); diff --git a/zone/npc.cpp b/zone/npc.cpp index 03fc7c45a..8f947a0c7 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -54,7 +54,7 @@ extern EntityList entity_list; #include "quest_parser_collection.h" -NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float heading, int iflymode, bool IsCorpse) +NPC::NPC(const NPCType* d, Spawn2* in_respawn, const xyz_heading& position, int iflymode, bool IsCorpse) : Mob(d->name, d->lastname, d->max_hp, @@ -68,10 +68,10 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float d->npc_id, d->size, d->runspeed, - heading, - x, - y, - z, + position.m_Heading, + position.m_X, + position.m_Y, + position.m_Z, d->light, d->texture, d->helmtexture, @@ -114,7 +114,7 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float sendhpupdate_timer(1000), enraged_timer(1000), taunt_timer(TauntReuseTime * 1000), - m_SpawnPoint(x,y,z,heading), + m_SpawnPoint(position), m_GuardPoint(-1,-1,-1,0), m_GuardPointSaved(0,0,0,0) { @@ -932,7 +932,7 @@ NPC* NPC::SpawnNPC(const char* spawncommand, const xyz_heading& position, Client npc_type->prim_melee_type = 28; npc_type->sec_melee_type = 28; - NPC* npc = new NPC(npc_type, 0, position.m_X, position.m_Y, position.m_Z, position.m_Heading, FlyMode3); + NPC* npc = new NPC(npc_type, nullptr, position, FlyMode3); npc->GiveNPCTypeData(npc_type); entity_list.AddNPC(npc); diff --git a/zone/npc.h b/zone/npc.h index 0c1c42aa8..8db5514de 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -94,10 +94,10 @@ class AA_SwarmPetInfo; class NPC : public Mob { public: - static NPC* SpawnNPC(const char* spawncommand, const xyz_heading& position, Client* client = 0); + static NPC* SpawnNPC(const char* spawncommand, const xyz_heading& position, Client* client = nullptr); static int8 GetAILevel(bool iForceReRead = false); - NPC(const NPCType* data, Spawn2* respawn, float x, float y, float z, float heading, int iflymode, bool IsCorpse = false); + NPC(const NPCType* data, Spawn2* respawn, const xyz_heading& position, int iflymode, bool IsCorpse = false); virtual ~NPC(); diff --git a/zone/pathing.cpp b/zone/pathing.cpp index 7bd44c757..016e7afe1 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -587,8 +587,8 @@ void PathManager::SpawnPathNodes() npc_type->CHA = 150; npc_type->findable = 1; - - NPC* npc = new NPC(npc_type, 0, PathNodes[i].v.x, PathNodes[i].v.y, PathNodes[i].v.z, 0, FlyMode1); + auto position = xyz_heading(PathNodes[i].v.x, PathNodes[i].v.y, PathNodes[i].v.z, 0.0f); + NPC* npc = new NPC(npc_type, nullptr, position, FlyMode1); npc->GiveNPCTypeData(npc_type); entity_list.AddNPC(npc, true, true); @@ -1578,7 +1578,8 @@ int32 PathManager::AddNode(float x, float y, float z, float best_z, int32 reques npc_type->CHA = 150; npc_type->findable = 1; - NPC* npc = new NPC(npc_type, 0, new_node.v.x, new_node.v.y, new_node.v.z, 0, FlyMode1); + auto position = xyz_heading(new_node.v.x, new_node.v.y, new_node.v.z, 0.0f); + NPC* npc = new NPC(npc_type, nullptr, position, FlyMode1); npc->GiveNPCTypeData(npc_type); entity_list.AddNPC(npc, true, true); @@ -1638,7 +1639,8 @@ int32 PathManager::AddNode(float x, float y, float z, float best_z, int32 reques npc_type->CHA = 150; npc_type->findable = 1; - NPC* npc = new NPC(npc_type, 0, new_node.v.x, new_node.v.y, new_node.v.z, 0, FlyMode1); + auto position = xyz_heading(new_node.v.x, new_node.v.y, new_node.v.z, 0.0f); + NPC* npc = new NPC(npc_type, nullptr, position, FlyMode1); npc->GiveNPCTypeData(npc_type); entity_list.AddNPC(npc, true, true); diff --git a/zone/pets.cpp b/zone/pets.cpp index 1f61b227b..8556bb620 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -435,7 +435,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, into walls or objects (+10), this sometimes creates the "ghost" effect. I changed to +2 (as close as I could get while it still looked good). I also noticed this can happen if an NPC is spawned on the same spot of another or in a related bad spot.*/ Pet::Pet(NPCType *type_data, Mob *owner, PetType type, uint16 spell_id, int16 power) -: NPC(type_data, 0, owner->GetX()+2, owner->GetY()+2, owner->GetZ(), owner->GetHeading(), FlyMode3) +: NPC(type_data, 0, owner->GetPosition() + xy_location(2, 2), FlyMode3) { GiveNPCTypeData(type_data); typeofpet = type; diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 0c56a46bc..bcef4ef98 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -245,7 +245,7 @@ Mob* QuestManager::spawn2(int npc_type, int grid, int unused, float x, float y, const NPCType* tmp = 0; if (tmp = database.GetNPCType(npc_type)) { - NPC* npc = new NPC(tmp, 0, x, y, z, heading, FlyMode3); + NPC* npc = new NPC(tmp, nullptr, xyz_heading(x, y, z, heading), FlyMode3); npc->AddLootTable(); entity_list.AddNPC(npc,true,true); if(grid > 0) @@ -267,7 +267,7 @@ Mob* QuestManager::unique_spawn(int npc_type, int grid, int unused, float x, flo const NPCType* tmp = 0; if (tmp = database.GetNPCType(npc_type)) { - NPC* npc = new NPC(tmp, 0, x, y, z, heading, FlyMode3); + NPC* npc = new NPC(tmp, nullptr, xyz_heading(x, y, z, heading), FlyMode3); npc->AddLootTable(); entity_list.AddNPC(npc,true,true); if(grid > 0) @@ -340,8 +340,8 @@ Mob* QuestManager::spawn_from_spawn2(uint32 spawn2_id) database.UpdateSpawn2Timeleft(spawn2_id, zone->GetInstanceID(), 0); found_spawn->SetCurrentNPCID(npcid); - NPC* npc = new NPC(tmp, found_spawn, found_spawn->GetX(), found_spawn->GetY(), found_spawn->GetZ(), - found_spawn->GetHeading(), FlyMode3); + auto position = xyz_heading(found_spawn->GetX(), found_spawn->GetY(), found_spawn->GetZ(), found_spawn->GetHeading()); + NPC* npc = new NPC(tmp, found_spawn, position, FlyMode3); found_spawn->SetNPCPointer(npc); npc->AddLootTable(); @@ -1600,26 +1600,20 @@ void QuestManager::setnextinchpevent(int at) { owner->SetNextIncHPEvent(at); } -void QuestManager::respawn(int npc_type, int grid) { +void QuestManager::respawn(int npcTypeID, int grid) { QuestManagerCurrentQuestVars(); if (!owner || !owner->IsNPC()) return; - float x,y,z,h; - - x = owner->GetX(); - y = owner->GetY(); - z = owner->GetZ(); - h = owner->GetHeading(); running_quest e = quests_running_.top(); e.depop_npc = true; quests_running_.pop(); quests_running_.push(e); - const NPCType* tmp = 0; - if ((tmp = database.GetNPCType(npc_type))) + const NPCType* npcType = nullptr; + if ((npcType = database.GetNPCType(npcTypeID))) { - owner = new NPC(tmp, 0, x, y, z, h, FlyMode3); + owner = new NPC(npcType, nullptr, owner->GetPosition(), FlyMode3); owner->CastToNPC()->AddLootTable(); entity_list.AddNPC(owner->CastToNPC(),true,true); if(grid > 0) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 8d8562157..1e973ebc7 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -217,7 +217,7 @@ bool Spawn2::Process() { database.UpdateSpawn2Timeleft(spawn2_id, zone->GetInstanceID(), 0); currentnpcid = npcid; - NPC* npc = new NPC(tmp, this, x, y, z, heading, FlyMode3); + NPC* npc = new NPC(tmp, this, xyz_heading(x, y, z, heading), FlyMode3); npc->mod_prespawn(this); diff --git a/zone/trap.cpp b/zone/trap.cpp index 44c177118..b4a4a1f1f 100644 --- a/zone/trap.cpp +++ b/zone/trap.cpp @@ -144,7 +144,9 @@ void Trap::Trigger(Mob* trigger) { if ((tmp = database.GetNPCType(effectvalue))) { - NPC* new_npc = new NPC(tmp, 0, x-5+MakeRandomInt(0, 10), y-5+MakeRandomInt(0, 10), z-5+MakeRandomInt(0, 10), MakeRandomInt(0, 249), FlyMode3); + auto randomOffset = xyz_heading(-5 + MakeRandomInt(0, 10),-5 + MakeRandomInt(0, 10),-5 + MakeRandomInt(0, 10), MakeRandomInt(0, 249)); + auto position = randomOffset + xyz_location(x, y, z); + NPC* new_npc = new NPC(tmp, nullptr, position, FlyMode3); new_npc->AddLootTable(); entity_list.AddNPC(new_npc); new_npc->AddToHateList(trigger,1); @@ -165,7 +167,9 @@ void Trap::Trigger(Mob* trigger) { if ((tmp = database.GetNPCType(effectvalue))) { - NPC* new_npc = new NPC(tmp, 0, x-2+MakeRandomInt(0, 5), y-2+MakeRandomInt(0, 5), z-2+MakeRandomInt(0, 5), MakeRandomInt(0, 249), FlyMode3); + auto randomOffset = xyz_heading(-2 + MakeRandomInt(0, 5), -2 + MakeRandomInt(0, 5), -2 + MakeRandomInt(0, 5), MakeRandomInt(0, 249)); + auto position = randomOffset + xyz_location(x, y, z); + NPC* new_npc = new NPC(tmp, nullptr, position, FlyMode3); new_npc->AddLootTable(); entity_list.AddNPC(new_npc); new_npc->AddToHateList(trigger,1); @@ -318,7 +322,7 @@ void Trap::CreateHiddenTrigger() make_npc->trackable = 0; make_npc->level = level; strcpy(make_npc->special_abilities, "19,1^20,1^24,1^25,1"); - NPC* npca = new NPC(make_npc, 0, x, y, z, 0, FlyMode3); + NPC* npca = new NPC(make_npc, nullptr, xyz_heading(x, y, z, 0.0f), FlyMode3); npca->GiveNPCTypeData(make_npc); entity_list.AddNPC(npca); diff --git a/zone/zone.cpp b/zone/zone.cpp index ecf10bcb5..eaf73f1da 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -103,7 +103,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { } zone->zonemap = Map::LoadMapFile(zone->map_name); zone->watermap = WaterMap::LoadWaterMapfile(zone->map_name); - zone->pathing = PathManager::LoadPathFile(zone->map_name); + zone->pathing = PathManager::LoadPathFile(zone->map_name); char tmp[10]; if (database.GetVariable("loglevel",tmp, 9)) { @@ -470,7 +470,7 @@ void Zone::LoadNewMerchantData(uint32 merchantid) { void Zone::GetMerchantDataForZoneLoad() { LogFile->write(EQEMuLog::Status, "Loading Merchant Lists..."); - std::string query = StringFormat( + std::string query = StringFormat( "SELECT " "DISTINCT ml.merchantid, " "ml.slot, " @@ -488,14 +488,14 @@ void Zone::GetMerchantDataForZoneLoad() { "WHERE nt.merchant_id = ml.merchantid AND nt.id = se.npcid " "AND se.spawngroupid = s2.spawngroupid AND s2.zone = '%s' AND s2.version = %i " "ORDER BY ml.slot ", GetShortName(), GetInstanceVersion()); - auto results = database.QueryDatabase(query); + auto results = database.QueryDatabase(query); std::map >::iterator cur; uint32 npcid = 0; if (results.RowCount() == 0) { LogFile->write(EQEMuLog::Debug, "No Merchant Data found for %s.", GetShortName()); return; } - for (auto row = results.begin(); row != results.end(); ++row) { + for (auto row = results.begin(); row != results.end(); ++row) { MerchantList ml; ml.id = atoul(row[0]); if (npcid != ml.id) { @@ -2199,7 +2199,7 @@ void Zone::DoAdventureActions() const NPCType* tmp = database.GetNPCType(ds->data_id); if(tmp) { - NPC* npc = new NPC(tmp, 0, ds->assa_x, ds->assa_y, ds->assa_z, ds->assa_h, FlyMode3); + NPC* npc = new NPC(tmp, nullptr, xyz_heading(ds->assa_x, ds->assa_y, ds->assa_z, ds->assa_h), FlyMode3); npc->AddLootTable(); entity_list.AddNPC(npc); npc->Shout("Rarrrgh!"); From 2546c6c226272211e10999282a11f770fb1c30e7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 18:10:30 -0800 Subject: [PATCH 037/253] Trap converted to use xyz_location as m_Position instead of x, y, z --- zone/client_packet.cpp | 22 ++++++------- zone/entity.cpp | 48 ++++++++++++--------------- zone/position.cpp | 10 ++++++ zone/position.h | 1 + zone/trap.cpp | 74 ++++++++++++++++++------------------------ zone/trap.h | 4 +-- 6 files changed, 74 insertions(+), 85 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 62f4f12dd..958834784 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -11699,29 +11699,29 @@ void Client::Handle_OP_SenseTraps(const EQApplicationPacket *app) int uskill = GetSkill(SkillSenseTraps); if ((MakeRandomInt(0, 99) + uskill) >= (MakeRandomInt(0, 99) + trap->skill*0.75)) { - float xdif = trap->x - GetX(); - float ydif = trap->y - GetY(); - if (xdif == 0 && ydif == 0) + auto diff = trap->m_Position - GetPosition(); + + if (diff.m_X == 0 && diff.m_Y == 0) Message(MT_Skills, "You sense a trap right under your feet!"); - else if (xdif > 10 && ydif > 10) + else if (diff.m_X > 10 && diff.m_Y > 10) Message(MT_Skills, "You sense a trap to the NorthWest."); - else if (xdif < -10 && ydif > 10) + else if (diff.m_X < -10 && diff.m_Y > 10) Message(MT_Skills, "You sense a trap to the NorthEast."); - else if (ydif > 10) + else if (diff.m_Y > 10) Message(MT_Skills, "You sense a trap to the North."); - else if (xdif > 10 && ydif < -10) + else if (diff.m_X > 10 && diff.m_Y < -10) Message(MT_Skills, "You sense a trap to the SouthWest."); - else if (xdif < -10 && ydif < -10) + else if (diff.m_X < -10 && diff.m_Y < -10) Message(MT_Skills, "You sense a trap to the SouthEast."); - else if (ydif < -10) + else if (diff.m_Y < -10) Message(MT_Skills, "You sense a trap to the South."); - else if (xdif > 10) + else if (diff.m_X > 10) Message(MT_Skills, "You sense a trap to the West."); else Message(MT_Skills, "You sense a trap to the East."); trap->detected = true; - float angle = CalculateHeadingToTarget(trap->x, trap->y); + float angle = CalculateHeadingToTarget(trap->m_Position.m_X, trap->m_Position.m_Y); if (angle < 0) angle = (256 + angle); diff --git a/zone/entity.cpp b/zone/entity.cpp index 122e24582..792deaad4 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -68,7 +68,7 @@ Entity::Entity() Entity::~Entity() { - + } Client *Entity::CastToClient() @@ -493,14 +493,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; @@ -3106,33 +3106,25 @@ void EntityList::OpenDoorsNear(NPC *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); } } @@ -3636,7 +3628,7 @@ int16 EntityList::CountTempPets(Mob *owner) } ++it; } - + owner->SetTempPetCount(count); return count; diff --git a/zone/position.cpp b/zone/position.cpp index 2d7d48cf8..887949f41 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -67,6 +67,16 @@ const xyz_heading xyz_heading::operator -(const xyz_location& rhs) const{ return xyz_heading(m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z, m_Heading); } +void xyz_heading::ABS_XYZ(void) { + if (m_X < 0) + m_X = -m_X; + + if (m_Y < 0) + m_Y = -m_Y; + + if (m_Z < 0) + m_Z = -m_Z; +} xyz_location::xyz_location(float x, float y, float z) : m_X(x), diff --git a/zone/position.h b/zone/position.h index 591c14b10..653cd4ba6 100644 --- a/zone/position.h +++ b/zone/position.h @@ -74,6 +74,7 @@ public: const xyz_heading operator -(const xyz_location& rhs) const; + void ABS_XYZ(); bool isOrigin() const { return m_X == 0.0f && m_Y == 0.0f && m_Z == 0.0f;} }; diff --git a/zone/trap.cpp b/zone/trap.cpp index b4a4a1f1f..7d53bcc70 100644 --- a/zone/trap.cpp +++ b/zone/trap.cpp @@ -50,12 +50,10 @@ CREATE TABLE traps ( Trap::Trap() : Entity(), respawn_timer(600000), - chkarea_timer(500) + chkarea_timer(500), + m_Position(xyz_location::Origin()) { trap_id = 0; - x = 0; - y = 0; - z = 0; maxzdiff = 0; radius = 0; effect = 0; @@ -145,8 +143,8 @@ void Trap::Trigger(Mob* trigger) if ((tmp = database.GetNPCType(effectvalue))) { auto randomOffset = xyz_heading(-5 + MakeRandomInt(0, 10),-5 + MakeRandomInt(0, 10),-5 + MakeRandomInt(0, 10), MakeRandomInt(0, 249)); - auto position = randomOffset + xyz_location(x, y, z); - NPC* new_npc = new NPC(tmp, nullptr, position, FlyMode3); + auto spawnPosition = randomOffset + m_Position; + NPC* new_npc = new NPC(tmp, nullptr, spawnPosition, FlyMode3); new_npc->AddLootTable(); entity_list.AddNPC(new_npc); new_npc->AddToHateList(trigger,1); @@ -168,8 +166,8 @@ void Trap::Trigger(Mob* trigger) if ((tmp = database.GetNPCType(effectvalue))) { auto randomOffset = xyz_heading(-2 + MakeRandomInt(0, 5), -2 + MakeRandomInt(0, 5), -2 + MakeRandomInt(0, 5), MakeRandomInt(0, 249)); - auto position = randomOffset + xyz_location(x, y, z); - NPC* new_npc = new NPC(tmp, nullptr, position, FlyMode3); + auto spawnPosition = randomOffset + m_Position; + NPC* new_npc = new NPC(tmp, nullptr, spawnPosition, FlyMode3); new_npc->AddLootTable(); entity_list.AddNPC(new_npc); new_npc->AddToHateList(trigger,1); @@ -212,55 +210,47 @@ Trap* EntityList::FindNearbyTrap(Mob* searcher, float max_dist) { float max_dist2 = max_dist*max_dist; Trap *cur; - auto it = trap_list.begin(); - while (it != trap_list.end()) { - cur = it->second; - if(!cur->disarmed) { - float curdist = 0; - float tmp = searcher->GetX() - cur->x; - curdist += tmp*tmp; - tmp = searcher->GetY() - cur->y; - curdist += tmp*tmp; - tmp = searcher->GetZ() - cur->z; - curdist += tmp*tmp; - if (curdist < max_dist2 && curdist < dist) - { - dist = curdist; - current_trap = cur; - } - } - ++it; + for (auto it = trap_list.begin(); it != trap_list.end(); ++it) { + cur = it->second; + if(cur->disarmed) + continue; + + auto diff = searcher->GetPosition() - cur->m_Position; + float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y + diff.m_Z * diff.m_Z; + + if (curdist < max_dist2 && curdist < dist) + { + dist = curdist; + current_trap = cur; + } } + return current_trap; } Mob* EntityList::GetTrapTrigger(Trap* trap) { Mob* savemob = 0; - float xdiff, ydiff, zdiff; - float maxdist = trap->radius * trap->radius; - auto it = client_list.begin(); - while (it != client_list.end()) { + for (auto it = client_list.begin(); it != client_list.end(); ++it) { Client* cur = it->second; - zdiff = cur->GetZ() - trap->z; - if(zdiff < 0) - zdiff = 0 - zdiff; - xdiff = cur->GetX() - trap->x; - ydiff = cur->GetY() - trap->y; - if ((xdiff*xdiff + ydiff*ydiff) <= maxdist - && zdiff < trap->maxzdiff) + auto diff = cur->GetPosition() - trap->m_Position; + diff.ABS_XYZ(); + + if ((diff.m_X*diff.m_X + diff.m_Y*diff.m_Y) <= maxdist + && diff.m_Z < trap->maxzdiff) { if (MakeRandomInt(0,100) < trap->chance) - return(cur); + return cur; else savemob = cur; } - ++it; + } + return savemob; } @@ -279,9 +269,7 @@ bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) { for (auto row = results.begin(); row != results.end(); ++row) { Trap* trap = new Trap(); trap->trap_id = atoi(row[0]); - trap->x = atof(row[1]); - trap->y = atof(row[2]); - trap->z = atof(row[3]); + trap->m_Position = xyz_location(atof(row[1]), atof(row[2]), atof(row[3])); trap->effect = atoi(row[4]); trap->effectvalue = atoi(row[5]); trap->effectvalue2 = atoi(row[6]); @@ -322,7 +310,7 @@ void Trap::CreateHiddenTrigger() make_npc->trackable = 0; make_npc->level = level; strcpy(make_npc->special_abilities, "19,1^20,1^24,1^25,1"); - NPC* npca = new NPC(make_npc, nullptr, xyz_heading(x, y, z, 0.0f), FlyMode3); + NPC* npca = new NPC(make_npc, nullptr, xyz_heading(m_Position, 0.0f), FlyMode3); npca->GiveNPCTypeData(make_npc); entity_list.AddNPC(npca); diff --git a/zone/trap.h b/zone/trap.h index ad2e2171a..ac1925e41 100644 --- a/zone/trap.h +++ b/zone/trap.h @@ -53,9 +53,7 @@ public: Timer respawn_timer; //Respawn Time when Trap's been disarmed Timer chkarea_timer; uint32 trap_id; //Database ID of trap - float x; //X position - float y; //Y position - float z; //Z position + xyz_location m_Position; float maxzdiff; //maximum z diff to be triggerable float radius; //radius around trap to be triggerable uint8 chance; //%chance that the trap is triggered each 'tick' From 51d6ea622ea977b91dd74728b139c4dd317ceadd Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 18:13:28 -0800 Subject: [PATCH 038/253] Switched to c++11 based abs instead of hacky custom version --- zone/position.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/zone/position.cpp b/zone/position.cpp index 887949f41..90b85726d 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -1,5 +1,7 @@ -#include "position.h" #include +#include + +#include "position.h" #include "../common/string_util.h" xy_location::xy_location(float x, float y) : @@ -68,14 +70,9 @@ const xyz_heading xyz_heading::operator -(const xyz_location& rhs) const{ } void xyz_heading::ABS_XYZ(void) { - if (m_X < 0) - m_X = -m_X; - - if (m_Y < 0) - m_Y = -m_Y; - - if (m_Z < 0) - m_Z = -m_Z; + m_X = abs(m_X); + m_Y = abs(m_Y); + m_Z = abs(m_Z); } xyz_location::xyz_location(float x, float y, float z) : @@ -99,14 +96,9 @@ const xyz_location xyz_location::operator -(const xyz_location& rhs) const { } void xyz_location::ABS_XYZ(void) { - if (m_X < 0) - m_X = -m_X; - - if (m_Y < 0) - m_Y = -m_Y; - - if (m_Z < 0) - m_Z = -m_Z; + m_X = abs(m_X); + m_Y = abs(m_Y); + m_Z = abs(m_Z); } std::string to_string(const xyz_heading &position) { From 708b4f3bfb7053fd7b09618f2eb50e4feee23574 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 18:33:45 -0800 Subject: [PATCH 039/253] Horse constructor converted to xyz_heading --- zone/horse.cpp | 6 +++--- zone/horse.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/horse.cpp b/zone/horse.cpp index cdcd8a28e..f4efa931b 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -28,8 +28,8 @@ std::map Horse::horse_types; LinkedList horses_auto_delete; -Horse::Horse(Client *_owner, uint16 spell_id, float x, float y, float z, float heading) - : NPC(GetHorseType(spell_id), nullptr, xyz_heading(x, y, z, heading), FlyMode3) +Horse::Horse(Client *_owner, uint16 spell_id, const xyz_heading& position) + : NPC(GetHorseType(spell_id), nullptr, position, FlyMode3) { //give the horse its proper name. strn0cpy(name, _owner->GetCleanName(), 55); @@ -126,7 +126,7 @@ void Client::SummonHorse(uint16 spell_id) { // No Horse, lets get them one. - Horse* horse = new Horse(this, spell_id, GetX(), GetY(), GetZ(), GetHeading()); + Horse* horse = new Horse(this, spell_id, GetPosition()); //we want to manage the spawn packet ourself. //another reason is we dont want quests executing on it. diff --git a/zone/horse.h b/zone/horse.h index dd58007eb..e34b4aaa0 100644 --- a/zone/horse.h +++ b/zone/horse.h @@ -25,7 +25,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) class Horse : public NPC { public: - Horse(Client *owner, uint16 spell_id, float x, float y, float z, float heading); + Horse(Client *owner, uint16 spell_id, const xyz_heading& position); virtual void FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho); From 6b1b0838024ea0d784310b04dadf8573f6de467c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 18:57:50 -0800 Subject: [PATCH 040/253] mob constructor converted to xyz_heading --- zone/beacon.cpp | 8 +------- zone/client.cpp | 5 +---- zone/corpse.cpp | 13 +++---------- zone/mob.cpp | 14 +++----------- zone/mob.h | 5 +---- zone/npc.cpp | 5 +---- 6 files changed, 10 insertions(+), 40 deletions(-) diff --git a/zone/beacon.cpp b/zone/beacon.cpp index 4713e7c63..2b10ed1ab 100644 --- a/zone/beacon.cpp +++ b/zone/beacon.cpp @@ -43,7 +43,7 @@ extern Zone* zone; Beacon::Beacon(Mob *at_mob, int lifetime) :Mob ( - nullptr, nullptr, 0, 0, 0, INVISIBLE_MAN, 0, BT_NoTarget, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + nullptr, nullptr, 0, 0, 0, INVISIBLE_MAN, 0, BT_NoTarget, 0, 0, 0, 0, 0, at_mob->GetPosition(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), remove_timer(lifetime), @@ -57,12 +57,6 @@ Beacon::Beacon(Mob *at_mob, int lifetime) spell_iterations = 0; caster_id = 0; - // copy location - m_Position.m_X = at_mob->GetX(); - m_Position.m_Y = at_mob->GetY(); - m_Position.m_Z = at_mob->GetZ(); - m_Position.m_Heading = at_mob->GetHeading(); - if(lifetime) { remove_timer.Start(); diff --git a/zone/client.cpp b/zone/client.cpp index 5f5089d2b..fd229f29d 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -89,10 +89,7 @@ Client::Client(EQStreamInterface* ieqs) 0, // npctypeid 0, // size 0.7, // runspeed - 0, // heading - 0, // x - 0, // y - 0, // z + xyz_heading::Origin(), 0, // light 0xFF, // texture 0xFF, // helmtexture diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 5c56be256..766c70345 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -146,8 +146,7 @@ Corpse::Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NP // vesuvias - appearence fix : Mob("Unnamed_Corpse","",0,0,in_npc->GetGender(),in_npc->GetRace(),in_npc->GetClass(),BT_Humanoid,//bodytype added in_npc->GetDeity(),in_npc->GetLevel(),in_npc->GetNPCTypeID(),in_npc->GetSize(),0, - in_npc->GetHeading(),in_npc->GetX(),in_npc->GetY(),in_npc->GetZ(),0, - in_npc->GetTexture(),in_npc->GetHelmTexture(), + in_npc->GetPosition(), 0, in_npc->GetTexture(),in_npc->GetHelmTexture(), 0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0xff,0,0,0,0,0,0,0,0,0), corpse_decay_timer(in_decaytime), @@ -212,10 +211,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( 0, // uint32 in_npctype_id, client->GetSize(), // float in_size, 0, // float in_runspeed, - client->GetHeading(), // float in_heading, - client->GetX(), // float in_x_pos, - client->GetY(), // float in_y_pos, - client->GetZ(), // float in_z_pos, + client->GetPosition(), 0, // uint8 in_light, client->GetTexture(), // uint8 in_texture, client->GetHelmTexture(), // uint8 in_helmtexture, @@ -441,10 +437,7 @@ in_level, 0, in_size, 0, -in_heading, -in_x, -in_y, -in_z, +xyz_heading(in_x, in_y,in_z,in_heading), 0, in_texture, in_helmtexture, diff --git a/zone/mob.cpp b/zone/mob.cpp index 48aee2260..8ccbfe5fe 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -45,11 +45,7 @@ Mob::Mob(const char* in_name, uint32 in_npctype_id, float in_size, float in_runspeed, - float in_heading, - float in_x_pos, - float in_y_pos, - float in_z_pos, - + const xyz_heading& position, uint8 in_light, uint8 in_texture, uint8 in_helmtexture, @@ -101,8 +97,8 @@ Mob::Mob(const char* in_name, m_FearWalkTarget(-999999.0f,-999999.0f,-999999.0f), m_TargetLocation(xyz_location::Origin()), m_TargetV(xyz_location::Origin()), - flee_timer(FLEE_CHECK_TIMER) - + flee_timer(FLEE_CHECK_TIMER), + m_Position(position) { targeted = 0; tar_ndx=0; @@ -149,10 +145,6 @@ Mob::Mob(const char* in_name, if (runspeed < 0 || runspeed > 20) runspeed = 1.25f; - m_Position.m_Heading = in_heading; - m_Position.m_X = in_x_pos; - m_Position.m_Y = in_y_pos; - m_Position.m_Z = in_z_pos; light = in_light; texture = in_texture; helmtexture = in_helmtexture; diff --git a/zone/mob.h b/zone/mob.h index cf904a97d..dd208b615 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -71,10 +71,7 @@ public: uint32 in_npctype_id, float in_size, float in_runspeed, - float in_heading, - float in_x_pos, - float in_y_pos, - float in_z_pos, + const xyz_heading& position, uint8 in_light, uint8 in_texture, uint8 in_helmtexture, diff --git a/zone/npc.cpp b/zone/npc.cpp index 8f947a0c7..f1ea80639 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -68,10 +68,7 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, const xyz_heading& position, int d->npc_id, d->size, d->runspeed, - position.m_Heading, - position.m_X, - position.m_Y, - position.m_Z, + position, d->light, d->texture, d->helmtexture, From 381dc7574f2d33cefe31b6476f51ecbd193c1f38 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 19:14:24 -0800 Subject: [PATCH 041/253] replaced _preSummonX, _preSummonY, and _preSummonZ in bot with xyz_location m_PreSummonlocation --- zone/bot.cpp | 8 +++----- zone/bot.h | 16 +++++++--------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 05dead52a..b1b926520 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -16279,11 +16279,9 @@ bool Bot::HasOrMayGetAggro() { void Bot::SetHasBeenSummoned(bool wasSummoned) { _hasBeenSummoned = wasSummoned; - if(!wasSummoned) { - _preSummonX = 0; - _preSummonY = 0; - _preSummonZ = 0; - } + if(!wasSummoned) + m_PreSummonLocation = xyz_location::Origin(); + } void Bot::SetDefaultBotStance() { diff --git a/zone/bot.h b/zone/bot.h index 6e7b452af..ffb757c7b 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -448,9 +448,9 @@ public: uint32 GetAA(uint32 aa_id); void ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon); bool GetHasBeenSummoned() { return _hasBeenSummoned; } - float GetPreSummonX() { return _preSummonX; } - float GetPreSummonY() { return _preSummonY; } - float GetPreSummonZ() { return _preSummonZ; } + float GetPreSummonX() { return m_PreSummonLocation.m_X; } + float GetPreSummonY() { return m_PreSummonLocation.m_Y; } + float GetPreSummonZ() { return m_PreSummonLocation.m_Z; } bool GetGroupMessagesOn() { return _groupMessagesOn; } bool GetInHealRotation() { return _isInHealRotation; } bool GetHealRotationActive() { return (GetInHealRotation() && _isHealRotationActive); } @@ -535,9 +535,9 @@ public: void SetSpellRecastTimer(int timer_index, int32 recast_delay); void SetDisciplineRecastTimer(int timer_index, int32 recast_delay); void SetHasBeenSummoned(bool s); - void SetPreSummonX(float x) { _preSummonX = x; } - void SetPreSummonY(float y) { _preSummonY = y; } - void SetPreSummonZ(float z) { _preSummonZ = z; } + void SetPreSummonX(float x) { m_PreSummonLocation.m_X = x; } + void SetPreSummonY(float y) { m_PreSummonLocation.m_Y = y; } + void SetPreSummonZ(float z) { m_PreSummonLocation.m_Z = z; } void SetGroupMessagesOn(bool groupMessagesOn) { _groupMessagesOn = groupMessagesOn; } void SetInHealRotation( bool inRotation ) { _isInHealRotation = inRotation; } void SetHealRotationActive( bool isActive ) { _isHealRotationActive = isActive; } @@ -604,9 +604,7 @@ private: int32 end_regen; uint32 timers[MaxTimer]; bool _hasBeenSummoned; - float _preSummonX; - float _preSummonY; - float _preSummonZ; + xyz_location m_PreSummonLocation; uint8 _spellCastingChances[MaxStances][MaxSpellTypes]; bool _groupMessagesOn; bool _isInHealRotation; From 98a8ddbb2104a95781edef2b2f04e2f08fb020c3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 19:23:35 -0800 Subject: [PATCH 042/253] Replace GetPreSummonX(), GetPreSummonY(), GetPreSummonZ() with GetPreSummonLocation as xyz_location --- zone/bot.cpp | 6 +++--- zone/bot.h | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index b1b926520..add609d9a 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3371,7 +3371,7 @@ void Bot::AI_Process() { if(GetHasBeenSummoned()) { if(IsBotCaster() || IsBotArcher()) { if (AImovement_timer->Check()) { - if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (DistNoRootNoZ(GetPreSummonX(), GetPreSummonY()) < 10)) { + if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (DistNoRootNoZ(m_PreSummonLocation.m_X, m_PreSummonLocation.m_Y) < 10)) { if(GetTarget()) FaceTarget(GetTarget()); SetHasBeenSummoned(false); @@ -3380,8 +3380,8 @@ void Bot::AI_Process() { if(GetTarget() && GetTarget()->GetHateTop() && GetTarget()->GetHateTop() != this) { mlog(AI__WAYPOINTS, "Returning to location prior to being summoned."); - CalculateNewPosition2(GetPreSummonX(), GetPreSummonY(), GetPreSummonZ(), GetRunspeed()); - SetHeading(CalculateHeadingToTarget(GetPreSummonX(), GetPreSummonY())); + CalculateNewPosition2(m_PreSummonLocation.m_X, m_PreSummonLocation.m_Y, m_PreSummonLocation.m_Z, GetRunspeed()); + SetHeading(CalculateHeadingToTarget(m_PreSummonLocation.m_X, m_PreSummonLocation.m_Y)); return; } } diff --git a/zone/bot.h b/zone/bot.h index ffb757c7b..a370f9ece 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -448,9 +448,7 @@ public: uint32 GetAA(uint32 aa_id); void ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon); bool GetHasBeenSummoned() { return _hasBeenSummoned; } - float GetPreSummonX() { return m_PreSummonLocation.m_X; } - float GetPreSummonY() { return m_PreSummonLocation.m_Y; } - float GetPreSummonZ() { return m_PreSummonLocation.m_Z; } + const xyz_location GetPreSummonLocation() const { return m_PreSummonLocation; } bool GetGroupMessagesOn() { return _groupMessagesOn; } bool GetInHealRotation() { return _isInHealRotation; } bool GetHealRotationActive() { return (GetInHealRotation() && _isHealRotationActive); } From 70d26a532cfff8300d98c83b7294f69a2189e3c2 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 19:34:44 -0800 Subject: [PATCH 043/253] SetPreSummonX(), SetPreSummonY(), and SetPreSummonZ() converted to SetPreSummonLocation() --- zone/bot.h | 4 +--- zone/mob.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/zone/bot.h b/zone/bot.h index a370f9ece..47fafa052 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -533,9 +533,7 @@ public: void SetSpellRecastTimer(int timer_index, int32 recast_delay); void SetDisciplineRecastTimer(int timer_index, int32 recast_delay); void SetHasBeenSummoned(bool s); - void SetPreSummonX(float x) { m_PreSummonLocation.m_X = x; } - void SetPreSummonY(float y) { m_PreSummonLocation.m_Y = y; } - void SetPreSummonZ(float z) { m_PreSummonLocation.m_Z = z; } + void SetPreSummonLocation(const xyz_location& location) { m_PreSummonLocation = location; } void SetGroupMessagesOn(bool groupMessagesOn) { _groupMessagesOn = groupMessagesOn; } void SetInHealRotation( bool inRotation ) { _isInHealRotation = inRotation; } void SetHealRotationActive( bool isActive ) { _isHealRotationActive = isActive; } diff --git a/zone/mob.cpp b/zone/mob.cpp index 8ccbfe5fe..18616323a 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2234,9 +2234,7 @@ bool Mob::HateSummon() { if(target && target->IsBot()) { // set pre summoning info to return to (to get out of melee range for caster) target->CastToBot()->SetHasBeenSummoned(true); - target->CastToBot()->SetPreSummonX(target->GetX()); - target->CastToBot()->SetPreSummonY(target->GetY()); - target->CastToBot()->SetPreSummonZ(target->GetZ()); + target->CastToBot()->SetPreSummonLocation(target->GetPosition()); } #endif //BOTS From 9f62f0e485f66f455def51ab4f95d516e28be3b7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 19:47:49 -0800 Subject: [PATCH 044/253] replaced pos_x, pos_y, pos_z, heading in Doors with xyz_heading m_Position --- zone/doors.cpp | 36 ++++++++++++++---------------------- zone/doors.h | 13 +++++-------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index 4af1d3eae..5b430df80 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -36,17 +36,14 @@ extern EntityList entity_list; extern WorldServer worldserver; -Doors::Doors(const Door* door) -: close_timer(5000) +Doors::Doors(const Door* door) : + close_timer(5000), + m_Position(door->pos_x, door->pos_y, door->pos_z, door->heading) { db_id = door->db_id; door_id = door->door_id; strn0cpy(zone_name,door->zone_name,32); strn0cpy(door_name,door->door_name,32); - pos_x = door->pos_x; - pos_y = door->pos_y; - pos_z = door->pos_z; - heading = door->heading; incline = door->incline; opentype = door->opentype; guild_id = door->guild_id; @@ -74,17 +71,14 @@ Doors::Doors(const Door* door) client_version_mask = door->client_version_mask; } -Doors::Doors(const char *dmodel, float dx, float dy, float dz, float dheading, uint8 dopentype, uint16 dsize) -: close_timer(5000) +Doors::Doors(const char *dmodel, float dx, float dy, float dz, float dheading, uint8 dopentype, uint16 dsize) : + close_timer(5000), + m_Position(dx, dy, dz, dheading) { db_id = database.GetDoorsCountPlusOne(zone->GetShortName(), zone->GetInstanceVersion()); door_id = database.GetDoorsDBCountPlusOne(zone->GetShortName(), zone->GetInstanceVersion()); strn0cpy(zone_name,zone->GetShortName(),32); strn0cpy(door_name,dmodel,32); - pos_x = dx; - pos_y = dy; - pos_z = dz; - heading = dheading; incline = 0; opentype = dopentype; guild_id = 0; @@ -141,7 +135,7 @@ bool Doors::Process() void Doors::HandleClick(Client* sender, uint8 trigger) { //door debugging info dump - _log(DOORS__INFO, "%s clicked door %s (dbid %d, eqid %d) at (%.4f,%.4f,%.4f @%.4f)", sender->GetName(), door_name, db_id, door_id, pos_x, pos_y, pos_z, heading); + _log(DOORS__INFO, "%s clicked door %s (dbid %d, eqid %d) at %s", sender->GetName(), door_name, db_id, door_id, to_string(m_Position).c_str()); _log(DOORS__INFO, " incline %d, opentype %d, lockpick %d, key %d, nokeyring %d, trigger %d type %d, param %d", incline, opentype, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param); _log(DOORS__INFO, " size %d, invert %d, dest: %s (%.4f,%.4f,%.4f @%.4f)", size, invert_state, dest_zone, dest_x, dest_y, dest_z, dest_heading); @@ -557,8 +551,8 @@ void Doors::ToggleState(Mob *sender) void Doors::DumpDoor(){ LogFile->write(EQEMuLog::Debug, - "db_id:%i door_id:%i zone_name:%s door_name:%s pos_x:%f pos_y:%f pos_z:%f heading:%f", - db_id, door_id, zone_name, door_name, pos_x, pos_y, pos_z, heading); + "db_id:%i door_id:%i zone_name:%s door_name:%s %s", + db_id, door_id, zone_name, door_name, to_string(m_Position).c_str()); LogFile->write(EQEMuLog::Debug, "opentype:%i guild_id:%i lockpick:%i keyitem:%i nokeyring:%i trigger_door:%i trigger_type:%i door_param:%i open:%s", opentype, guild_id, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param, (isopen) ? "open":"closed"); @@ -706,30 +700,28 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name void Doors::SetLocation(float x, float y, float z) { entity_list.DespawnAllDoors(); - pos_x = x; - pos_y = y; - pos_z = z; + m_Position = xyz_location(x, y, z); entity_list.RespawnAllDoors(); } void Doors::SetX(float in) { entity_list.DespawnAllDoors(); - pos_x = in; + m_Position.m_X = in; entity_list.RespawnAllDoors(); } void Doors::SetY(float in) { entity_list.DespawnAllDoors(); - pos_y = in; + m_Position.m_Y = in; entity_list.RespawnAllDoors(); } void Doors::SetZ(float in) { entity_list.DespawnAllDoors(); - pos_z = in; + m_Position.m_Z = in; entity_list.RespawnAllDoors(); } void Doors::SetHeading(float in) { entity_list.DespawnAllDoors(); - heading = in; + m_Position.m_Heading = in; entity_list.RespawnAllDoors(); } diff --git a/zone/doors.h b/zone/doors.h index 59fe394c8..f79ecd5ea 100644 --- a/zone/doors.h +++ b/zone/doors.h @@ -25,10 +25,10 @@ public: char* GetDoorName() { return door_name; } uint32 GetDoorParam() { return door_param; } int GetInvertState() { return invert_state; } - float GetX() { return pos_x; } - float GetY() { return pos_y; } - float GetZ() { return pos_z; } - float GetHeading() { return heading; } + float GetX() { return m_Position.m_X; } + float GetY() { return m_Position.m_Y; } + float GetZ() { return m_Position.m_Z; } + float GetHeading() { return m_Position.m_Heading; } int GetIncline() { return incline; } bool triggered; void SetOpenState(bool st) { isopen = st; } @@ -80,10 +80,7 @@ private: uint8 door_id; char zone_name[32]; char door_name[32]; - float pos_x; - float pos_y; - float pos_z; - float heading; + xyz_heading m_Position; int incline; uint8 opentype; uint32 guild_id; From 95f7bd94f3d5a7db77834523feb9c76389de7fc7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 19:58:56 -0800 Subject: [PATCH 045/253] replaced dest_x, dest_y, dest_z, and dest_headingg in Doors with xyz_heading m_Destination --- zone/doors.cpp | 30 ++++++++++++------------------ zone/doors.h | 13 +++++-------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index 5b430df80..be4b733a5 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -38,7 +38,8 @@ extern WorldServer worldserver; Doors::Doors(const Door* door) : close_timer(5000), - m_Position(door->pos_x, door->pos_y, door->pos_z, door->heading) + m_Position(door->pos_x, door->pos_y, door->pos_z, door->heading), + m_Destination(door->dest_x, door->dest_y, door->dest_z, door->dest_heading) { db_id = door->db_id; door_id = door->door_id; @@ -62,10 +63,6 @@ Doors::Doors(const Door* door) : strn0cpy(dest_zone,door->dest_zone,32); dest_instance_id = door->dest_instance_id; - dest_x = door->dest_x; - dest_y = door->dest_y; - dest_z = door->dest_z; - dest_heading = door->dest_heading; is_ldon_door = door->is_ldon_door; client_version_mask = door->client_version_mask; @@ -73,7 +70,8 @@ Doors::Doors(const Door* door) : Doors::Doors(const char *dmodel, float dx, float dy, float dz, float dheading, uint8 dopentype, uint16 dsize) : close_timer(5000), - m_Position(dx, dy, dz, dheading) + m_Position(dx, dy, dz, dheading), + m_Destination(xyz_heading::Origin()) { db_id = database.GetDoorsCountPlusOne(zone->GetShortName(), zone->GetInstanceVersion()); door_id = database.GetDoorsDBCountPlusOne(zone->GetShortName(), zone->GetInstanceVersion()); @@ -97,10 +95,6 @@ Doors::Doors(const char *dmodel, float dx, float dy, float dz, float dheading, u strn0cpy(dest_zone,"NONE",32); dest_instance_id = 0; - dest_x = 0; - dest_y = 0; - dest_z = 0; - dest_heading = 0; is_ldon_door = 0; client_version_mask = 4294967295u; @@ -137,7 +131,7 @@ void Doors::HandleClick(Client* sender, uint8 trigger) //door debugging info dump _log(DOORS__INFO, "%s clicked door %s (dbid %d, eqid %d) at %s", sender->GetName(), door_name, db_id, door_id, to_string(m_Position).c_str()); _log(DOORS__INFO, " incline %d, opentype %d, lockpick %d, key %d, nokeyring %d, trigger %d type %d, param %d", incline, opentype, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param); - _log(DOORS__INFO, " size %d, invert %d, dest: %s (%.4f,%.4f,%.4f @%.4f)", size, invert_state, dest_zone, dest_x, dest_y, dest_z, dest_heading); + _log(DOORS__INFO, " size %d, invert %d, dest: %s %s", size, invert_state, dest_zone, to_string(m_Destination).c_str()); EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct)); MoveDoor_Struct* md = (MoveDoor_Struct*)outapp->pBuffer; @@ -413,7 +407,7 @@ void Doors::HandleClick(Client* sender, uint8 trigger) { sender->KeyRingAdd(playerkey); } - sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), dest_x, dest_y, dest_z, dest_heading); + sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading); } else if (( !IsDoorOpen() || opentype == 58 ) && (keyneeded && ((keyneeded == playerkey) || sender->GetGM()))) { @@ -423,22 +417,22 @@ void Doors::HandleClick(Client* sender, uint8 trigger) } if(database.GetZoneID(dest_zone) == zone->GetZoneID()) { - sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), dest_x, dest_y, dest_z, dest_heading); + sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading); } else { - sender->MovePC(database.GetZoneID(dest_zone), dest_instance_id, dest_x, dest_y, dest_z, dest_heading); + sender->MovePC(database.GetZoneID(dest_zone), dest_instance_id, m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading); } } if (( !IsDoorOpen() || opentype == 58 ) && (!keyneeded)) { if(database.GetZoneID(dest_zone) == zone->GetZoneID()) { - sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), dest_x, dest_y, dest_z, dest_heading); + sender->MovePC(zone->GetZoneID(), zone->GetInstanceID(), m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading); } else { - sender->MovePC(database.GetZoneID(dest_zone), dest_instance_id, dest_x, dest_y, dest_z, dest_heading); + sender->MovePC(database.GetZoneID(dest_zone), dest_instance_id, m_Destination.m_X, m_Destination.m_Y, m_Destination.m_Z, m_Destination.m_Heading); } } } @@ -557,8 +551,8 @@ void Doors::DumpDoor(){ "opentype:%i guild_id:%i lockpick:%i keyitem:%i nokeyring:%i trigger_door:%i trigger_type:%i door_param:%i open:%s", opentype, guild_id, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param, (isopen) ? "open":"closed"); LogFile->write(EQEMuLog::Debug, - "dest_zone:%s dest_x:%f dest_y:%f dest_z:%f dest_heading:%f", - dest_zone, dest_x, dest_y, dest_z, dest_heading); + "dest_zone:%s destination:%s ", + dest_zone, to_string(m_Destination).c_str()); } int32 ZoneDatabase::GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 version) { diff --git a/zone/doors.h b/zone/doors.h index f79ecd5ea..3b519f90b 100644 --- a/zone/doors.h +++ b/zone/doors.h @@ -50,10 +50,10 @@ public: void SetEntityID(uint32 entity) { entity_id = entity; } void DumpDoor(); - float GetDestX() { return dest_x; } - float GetDestY() { return dest_y; } - float GetDestZ() { return dest_z; } - float GetDestHeading() { return dest_heading; } + float GetDestX() { return m_Destination.m_X; } + float GetDestY() { return m_Destination.m_Y; } + float GetDestZ() { return m_Destination.m_Z; } + float GetDestHeading() { return m_Destination.m_Heading; } uint8 IsLDoNDoor() { return is_ldon_door; } uint32 GetClientVersionMask() { return client_version_mask; } @@ -99,10 +99,7 @@ private: char dest_zone[16]; int dest_instance_id; - float dest_x; - float dest_y; - float dest_z; - float dest_heading; + xyz_heading m_Destination; uint8 is_ldon_door; uint32 client_version_mask; From 40d26b5bcf737d8f5575d43b5e9c5b48dd3b18de Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 20:05:51 -0800 Subject: [PATCH 046/253] replaced GetDestX(), GetDestY(), GetDestZ(), and GetDestHeading() with GetDestination in Doors --- zone/doors.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/zone/doors.h b/zone/doors.h index 3b519f90b..1a31b67c1 100644 --- a/zone/doors.h +++ b/zone/doors.h @@ -50,10 +50,7 @@ public: void SetEntityID(uint32 entity) { entity_id = entity; } void DumpDoor(); - float GetDestX() { return m_Destination.m_X; } - float GetDestY() { return m_Destination.m_Y; } - float GetDestZ() { return m_Destination.m_Z; } - float GetDestHeading() { return m_Destination.m_Heading; } + const xyz_heading GetDestination() const { return m_Destination; } uint8 IsLDoNDoor() { return is_ldon_door; } uint32 GetClientVersionMask() { return client_version_mask; } From a70eadecf47697432755d304488cc9042e779c73 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 20:23:18 -0800 Subject: [PATCH 047/253] Replaced GetX(), GetY(), GetZ(), and GetHeading() in Doors with GetPosition() --- zone/bot.cpp | 62 ++++++++++++++++++++------------------------- zone/doors.cpp | 2 +- zone/doors.h | 5 +--- zone/entity.cpp | 36 +++++++++++++------------- zone/lua_door.cpp | 8 +++--- zone/perl_doors.cpp | 8 +++--- 6 files changed, 54 insertions(+), 67 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index add609d9a..76363ab7c 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -15854,47 +15854,39 @@ std::list EntityList::GetBotsByBotOwnerCharacterID(uint32 botOwnerCharacte void EntityList::BotPickLock(Bot* rogue) { - auto it = door_list.begin(); for (auto it = door_list.begin(); it != door_list.end(); ++it) { Doors *cdoor = it->second; - if(cdoor && !cdoor->IsDoorOpen()) { - float zdiff = rogue->GetZ() - cdoor->GetZ(); - if(zdiff < 0) - zdiff = 0 - zdiff; - float curdist = 0; - float tmp = rogue->GetX() - cdoor->GetX(); - curdist += (tmp * tmp); - tmp = rogue->GetY() - cdoor->GetY(); - curdist += (tmp * tmp); - if((zdiff < 10) && (curdist <= 130)) { - // All rogue items with lock pick bonuses are hands or primary - const ItemInst* item1 = rogue->GetBotItem(MainHands); - const ItemInst* item2 = rogue->GetBotItem(MainPrimary); + if(!cdoor || cdoor->IsDoorOpen()) + continue; - float bonus1 = 0.0f; - float bonus2 = 0.0f; - float skill = rogue->GetSkill(SkillPickLock); + auto diff = rogue->GetPosition() - cdoor->GetPosition(); + diff.ABS_XYZ(); - if(item1) { // Hand slot item - if(item1->GetItem()->SkillModType == SkillPickLock) { - bonus1 = skill * (((float)item1->GetItem()->SkillModValue) / 100.0f); - } - } + float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y; - if(item2) { // Primary slot item - if(item2->GetItem()->SkillModType == SkillPickLock) { - bonus2 = skill * (((float)item2->GetItem()->SkillModValue) / 100.0f); - } - } + if((diff.m_Z * diff.m_Z >= 10) || (curdist > 130)) + continue; - if((skill+bonus1+bonus2) >= cdoor->GetLockpick()) { - cdoor->ForceOpen(rogue); - } - else { - rogue->Say("I am not skilled enough for this lock."); - } - } - } + // All rogue items with lock pick bonuses are hands or primary + const ItemInst* item1 = rogue->GetBotItem(MainHands); + const ItemInst* item2 = rogue->GetBotItem(MainPrimary); + + float bonus1 = 0.0f; + float bonus2 = 0.0f; + float skill = rogue->GetSkill(SkillPickLock); + + if(item1) // Hand slot item + if(item1->GetItem()->SkillModType == SkillPickLock) + bonus1 = skill * (((float)item1->GetItem()->SkillModValue) / 100.0f); + + if(item2) // Primary slot item + if(item2->GetItem()->SkillModType == SkillPickLock) + bonus2 = skill * (((float)item2->GetItem()->SkillModValue) / 100.0f); + + if((skill+bonus1+bonus2) >= cdoor->GetLockpick()) + cdoor->ForceOpen(rogue); + else + rogue->Say("I am not skilled enough for this lock."); } } diff --git a/zone/doors.cpp b/zone/doors.cpp index be4b733a5..d54d75edf 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -750,6 +750,6 @@ void Doors::CreateDatabaseEntry() { return; } - database.InsertDoor(GetDoorDBID(), GetDoorID(), GetDoorName(), GetX(), GetY(), GetZ(), GetHeading(), GetOpenType(), GetGuildID(), GetLockpick(), GetKeyItem(), GetDoorParam(), GetInvertState(), GetIncline(), GetSize()); + database.InsertDoor(GetDoorDBID(), GetDoorID(), GetDoorName(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_Position.m_Heading, GetOpenType(), GetGuildID(), GetLockpick(), GetKeyItem(), GetDoorParam(), GetInvertState(), GetIncline(), GetSize()); } diff --git a/zone/doors.h b/zone/doors.h index 1a31b67c1..3c57b967c 100644 --- a/zone/doors.h +++ b/zone/doors.h @@ -25,10 +25,7 @@ public: char* GetDoorName() { return door_name; } uint32 GetDoorParam() { return door_param; } int GetInvertState() { return invert_state; } - float GetX() { return m_Position.m_X; } - float GetY() { return m_Position.m_Y; } - float GetZ() { return m_Position.m_Z; } - float GetHeading() { return m_Position.m_Heading; } + const xyz_heading GetPosition() const{ return m_Position; } int GetIncline() { return incline; } bool triggered; void SetOpenState(bool st) { isopen = st; } diff --git a/zone/entity.cpp b/zone/entity.cpp index 792deaad4..da95f4025 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -855,10 +855,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(); @@ -3085,22 +3086,19 @@ 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); } } diff --git a/zone/lua_door.cpp b/zone/lua_door.cpp index 091cd0c0e..b6427e70e 100644 --- a/zone/lua_door.cpp +++ b/zone/lua_door.cpp @@ -20,22 +20,22 @@ const char *Lua_Door::GetDoorName() { float Lua_Door::GetX() { Lua_Safe_Call_Real(); - return self->GetX(); + return self->GetPosition().m_X; } float Lua_Door::GetY() { Lua_Safe_Call_Real(); - return self->GetY(); + return self->GetPosition().m_Y; } float Lua_Door::GetZ() { Lua_Safe_Call_Real(); - return self->GetZ(); + return self->GetPosition().m_Z; } float Lua_Door::GetHeading() { Lua_Safe_Call_Real(); - return self->GetHeading(); + return self->GetPosition().m_Heading; } void Lua_Door::SetX(float x) { diff --git a/zone/perl_doors.cpp b/zone/perl_doors.cpp index 77ad1902b..acdef2003 100644 --- a/zone/perl_doors.cpp +++ b/zone/perl_doors.cpp @@ -138,7 +138,7 @@ XS(XS_Doors_GetX) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetX(); + RETVAL = THIS->GetPosition().m_X; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -164,7 +164,7 @@ XS(XS_Doors_GetY) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetY(); + RETVAL = THIS->GetPosition().m_Y; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -190,7 +190,7 @@ XS(XS_Doors_GetZ) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetZ(); + RETVAL = THIS->GetPosition().m_Z; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); @@ -216,7 +216,7 @@ XS(XS_Doors_GetHeading) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetHeading(); + RETVAL = THIS->GetPosition().m_Heading; XSprePUSH; PUSHn((double)RETVAL); } XSRETURN(1); From 7239a1339ea6d7ca85c26766a1318060592da8cf Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 20:37:43 -0800 Subject: [PATCH 048/253] Replaced SetX(), SetY(), SetZ(), and SetHeading() with SetPosition() on Doors --- zone/doors.cpp | 19 ++----------------- zone/doors.h | 7 ++----- zone/lua_door.cpp | 16 ++++++++++++---- zone/perl_doors.cpp | 23 +++++++++++++++-------- 4 files changed, 31 insertions(+), 34 deletions(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index d54d75edf..ba8668f80 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -698,24 +698,9 @@ void Doors::SetLocation(float x, float y, float z) entity_list.RespawnAllDoors(); } -void Doors::SetX(float in) { +void Doors::SetPosition(const xyz_heading& position) { entity_list.DespawnAllDoors(); - m_Position.m_X = in; - entity_list.RespawnAllDoors(); -} -void Doors::SetY(float in) { - entity_list.DespawnAllDoors(); - m_Position.m_Y = in; - entity_list.RespawnAllDoors(); -} -void Doors::SetZ(float in) { - entity_list.DespawnAllDoors(); - m_Position.m_Z = in; - entity_list.RespawnAllDoors(); -} -void Doors::SetHeading(float in) { - entity_list.DespawnAllDoors(); - m_Position.m_Heading = in; + m_Position = position; entity_list.RespawnAllDoors(); } diff --git a/zone/doors.h b/zone/doors.h index 3c57b967c..f52d04108 100644 --- a/zone/doors.h +++ b/zone/doors.h @@ -57,14 +57,11 @@ public: void ForceClose(Mob *sender, bool alt_mode=false); void ToggleState(Mob *sender); - void SetX(float in); - void SetY(float in); - void SetZ(float in); - void SetHeading(float in); + void SetPosition(const xyz_heading& position); + void SetLocation(float x, float y, float z); void SetIncline(int in); void SetDoorName(const char* name); void SetOpenType(uint8 in); - void SetLocation(float x, float y, float z); void SetSize(uint16 size); void CreateDatabaseEntry(); diff --git a/zone/lua_door.cpp b/zone/lua_door.cpp index b6427e70e..bcd0ca284 100644 --- a/zone/lua_door.cpp +++ b/zone/lua_door.cpp @@ -40,22 +40,30 @@ float Lua_Door::GetHeading() { void Lua_Door::SetX(float x) { Lua_Safe_Call_Void(); - self->SetX(x); + auto position = self->GetPosition(); + position.m_X = x; + self->SetPosition(position); } void Lua_Door::SetY(float y) { Lua_Safe_Call_Void(); - self->SetY(y); + auto position = self->GetPosition(); + position.m_Y = y; + self->SetPosition(position); } void Lua_Door::SetZ(float z) { Lua_Safe_Call_Void(); - self->SetZ(z); + auto position = self->GetPosition(); + position.m_Z = z; + self->SetPosition(position); } void Lua_Door::SetHeading(float h) { Lua_Safe_Call_Void(); - self->SetHeading(h); + auto position = self->GetPosition(); + position.m_Heading = h; + self->SetPosition(position); } void Lua_Door::SetLocation(float x, float y, float z) { diff --git a/zone/perl_doors.cpp b/zone/perl_doors.cpp index acdef2003..615cce6e9 100644 --- a/zone/perl_doors.cpp +++ b/zone/perl_doors.cpp @@ -556,7 +556,7 @@ XS(XS_Doors_SetX) Perl_croak(aTHX_ "Usage: Doors::SetX(THIS, XPos)"); { Doors * THIS; - float pos = (float)SvNV(ST(1)); + float x = (float)SvNV(ST(1)); if (sv_derived_from(ST(0), "Doors")) { IV tmp = SvIV((SV*)SvRV(ST(0))); @@ -566,8 +566,9 @@ XS(XS_Doors_SetX) Perl_croak(aTHX_ "THIS is not of type Doors"); if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - - THIS->SetX(pos); + auto position = THIS->GetPosition(); + position.m_X = x; + THIS->SetPosition(position); } XSRETURN_EMPTY; } @@ -580,7 +581,7 @@ XS(XS_Doors_SetY) Perl_croak(aTHX_ "Usage: Doors::SetY(THIS, YPos)"); { Doors * THIS; - float pos = (float)SvNV(ST(1)); + float y = (float)SvNV(ST(1)); if (sv_derived_from(ST(0), "Doors")) { IV tmp = SvIV((SV*)SvRV(ST(0))); @@ -591,7 +592,9 @@ XS(XS_Doors_SetY) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - THIS->SetY(pos); + auto position = THIS->GetPosition(); + position.m_Y = y; + THIS->SetPosition(position); } XSRETURN_EMPTY; } @@ -604,7 +607,7 @@ XS(XS_Doors_SetZ) Perl_croak(aTHX_ "Usage: Doors::SetZ(THIS, ZPos)"); { Doors * THIS; - float pos = (float)SvNV(ST(1)); + float z = (float)SvNV(ST(1)); if (sv_derived_from(ST(0), "Doors")) { IV tmp = SvIV((SV*)SvRV(ST(0))); @@ -615,7 +618,9 @@ XS(XS_Doors_SetZ) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - THIS->SetZ(pos); + auto position = THIS->GetPosition(); + position.m_Z = z; + THIS->SetPosition(position); } XSRETURN_EMPTY; } @@ -639,7 +644,9 @@ XS(XS_Doors_SetHeading) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - THIS->SetHeading(heading); + auto position = THIS->GetPosition(); + position.m_Heading = heading; + THIS->SetPosition(position); } XSRETURN_EMPTY; } From 7ac9a5c5a63e47dea2b5e63eaceb57b3ceeae594 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 20:49:48 -0800 Subject: [PATCH 049/253] Doors constructor converted to xyz_heading --- zone/doors.cpp | 4 ++-- zone/doors.h | 2 +- zone/entity.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index ba8668f80..24bee901b 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -68,9 +68,9 @@ Doors::Doors(const Door* door) : client_version_mask = door->client_version_mask; } -Doors::Doors(const char *dmodel, float dx, float dy, float dz, float dheading, uint8 dopentype, uint16 dsize) : +Doors::Doors(const char *dmodel, const xyz_heading& position, uint8 dopentype, uint16 dsize) : close_timer(5000), - m_Position(dx, dy, dz, dheading), + m_Position(position), m_Destination(xyz_heading::Origin()) { db_id = database.GetDoorsCountPlusOne(zone->GetShortName(), zone->GetInstanceVersion()); diff --git a/zone/doors.h b/zone/doors.h index f52d04108..cd5fa61a1 100644 --- a/zone/doors.h +++ b/zone/doors.h @@ -13,7 +13,7 @@ class Doors : public Entity { public: Doors(const Door* door); - Doors(const char *dmodel, float dx, float dy, float dz, float dheading, uint8 dopentype = 58, uint16 dsize = 100); + Doors(const char *dmodel, const xyz_heading& position, uint8 dopentype = 58, uint16 dsize = 100); ~Doors(); bool IsDoor() const { return true; } void HandleClick(Client* sender, uint8 trigger); diff --git a/zone/entity.cpp b/zone/entity.cpp index da95f4025..1c17be825 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3852,7 +3852,7 @@ uint16 EntityList::CreateDoor(const char *model, float x, float y, float z, float heading, uint8 opentype, uint16 size) { if (model) { - Doors *door = new Doors(model, x, y, z, heading, opentype, size); + Doors *door = new Doors(model, xyz_heading(x, y, z, heading), opentype, size); RemoveAllDoors(); zone->LoadZoneDoors(zone->GetShortName(), zone->GetInstanceVersion()); entity_list.AddDoor(door); From 4f03ebb3afdba42d26b241e2dda21fe11f1fd94e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 21:04:39 -0800 Subject: [PATCH 050/253] EntityList::CreateDoor converted to xyz_heading --- zone/entity.cpp | 23 ++++++++++++----------- zone/entity.h | 5 +++-- zone/questmgr.cpp | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 1c17be825..8dd09bfab 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3848,19 +3848,20 @@ uint16 EntityList::CreateGroundObjectFromModel(const char *model, float x, return 0; // fell through everything, this is bad/incomplete from perl } -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, xyz_heading(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 } diff --git a/zone/entity.h b/zone/entity.h index 486f1d49f..8e888a9b1 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -26,6 +26,7 @@ #include "../common/bodytypes.h" #include "../common/eq_constants.h" +#include "position.h" #include "zonedb.h" #include "zonedump.h" #include "qglobals.h" @@ -52,7 +53,7 @@ class Bot; class BotRaids; #endif -extern EntityList entity_list; +extern EntityList entity_list; class Entity { @@ -388,7 +389,7 @@ public: uint16 CreateGroundObject(uint32 itemid, float x, float y, float z, float heading, uint32 decay_time = 300000); uint16 CreateGroundObjectFromModel(const char *model, float x, float y, float z, float heading, uint8 type = 0x00, uint32 decay_time = 0); - uint16 CreateDoor(const char *model, float x, float y, float z, float heading, uint8 type = 0, uint16 size = 100); + uint16 CreateDoor(const char *model, const xyz_heading& position, uint8 type = 0, uint16 size = 100); void ZoneWho(Client *c, Who_All_Struct* Who); void UnMarkNPC(uint16 ID); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index bcef4ef98..165a37071 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2878,7 +2878,7 @@ void QuestManager::SendMail(const char *to, const char *from, const char *subjec uint16 QuestManager::CreateDoor(const char* model, float x, float y, float z, float heading, uint8 opentype, uint16 size) { uint16 entid = 0; //safety check - entid = entity_list.CreateDoor(model, x, y, z, heading, opentype, size); + entid = entity_list.CreateDoor(model, xyz_heading(x, y, z, heading), opentype, size); return entid; } From d54215ea18f092cff5fb11075bc57d11de5afc13 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 21:20:46 -0800 Subject: [PATCH 051/253] EntityList::CreateGroundObjectFromModel converted to to xyz_heading --- zone/entity.cpp | 19 ++++++++++--------- zone/entity.h | 2 +- zone/questmgr.cpp | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 8dd09bfab..7b427314b 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3835,17 +3835,18 @@ uint16 EntityList::CreateGroundObject(uint32 itemid, float x, float y, float z, return 0; // fell through everything, this is bad/incomplete from perl } -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, const xyz_heading& position, uint8 opentype, uint16 size) diff --git a/zone/entity.h b/zone/entity.h index 8e888a9b1..a992a3a5d 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -388,7 +388,7 @@ public: void ReloadAllClientsTaskState(int TaskID=0); uint16 CreateGroundObject(uint32 itemid, float x, float y, float z, float heading, uint32 decay_time = 300000); - uint16 CreateGroundObjectFromModel(const char *model, float x, float y, float z, float heading, uint8 type = 0x00, uint32 decay_time = 0); + uint16 CreateGroundObjectFromModel(const char *model, const xyz_heading& position, uint8 type = 0x00, uint32 decay_time = 0); uint16 CreateDoor(const char *model, const xyz_heading& position, uint8 type = 0, uint16 size = 100); void ZoneWho(Client *c, Who_All_Struct* Who); void UnMarkNPC(uint16 ID); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 165a37071..8c4de1aed 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2352,7 +2352,7 @@ uint16 QuestManager::CreateGroundObject(uint32 itemid, float x, float y, float z uint16 QuestManager::CreateGroundObjectFromModel(const char *model, float x, float y, float z, float heading, uint8 type, uint32 decay_time) { uint16 entid = 0; //safety check - entid = entity_list.CreateGroundObjectFromModel(model, x, y, z, heading, type, decay_time); + entid = entity_list.CreateGroundObjectFromModel(model, xyz_heading(x, y, z, heading), type, decay_time); return entid; } From c3471ed88e33a35323497f611e95db9cac8c485c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 21:30:16 -0800 Subject: [PATCH 052/253] EntityList::CreateGroundObject converted to xyz_heading --- zone/entity.cpp | 29 +++++++++++++++-------------- zone/entity.h | 2 +- zone/questmgr.cpp | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 7b427314b..da89e9397 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3816,23 +3816,24 @@ 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, const xyz_heading& position, uint8 type, uint32 decay_time) diff --git a/zone/entity.h b/zone/entity.h index a992a3a5d..176aa1678 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -387,7 +387,7 @@ public: void SaveAllClientsTaskState(); void ReloadAllClientsTaskState(int TaskID=0); - uint16 CreateGroundObject(uint32 itemid, float x, float y, float z, float heading, uint32 decay_time = 300000); + uint16 CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time = 300000); uint16 CreateGroundObjectFromModel(const char *model, const xyz_heading& position, uint8 type = 0x00, uint32 decay_time = 0); uint16 CreateDoor(const char *model, const xyz_heading& position, uint8 type = 0, uint16 size = 100); void ZoneWho(Client *c, Who_All_Struct* Who); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 8c4de1aed..ccf4ef8ea 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2345,7 +2345,7 @@ int QuestManager::getlevel(uint8 type) uint16 QuestManager::CreateGroundObject(uint32 itemid, float x, float y, float z, float heading, uint32 decay_time) { uint16 entid = 0; //safety check - entid = entity_list.CreateGroundObject(itemid, x, y, z, heading, decay_time); + entid = entity_list.CreateGroundObject(itemid, xyz_heading(x, y, z, heading), decay_time); return entid; } From 4c5117cabe3d39d5e4b507290b0774a1a5dafc36 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 21:42:59 -0800 Subject: [PATCH 053/253] QuestManager::CreateGroundObject converted to xyz_heading --- zone/embparser_api.cpp | 24 ++++++++++++------------ zone/lua_general.cpp | 4 ++-- zone/questmgr.cpp | 4 ++-- zone/questmgr.h | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 0e8b10a8e..b1f3c126d 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -31,7 +31,7 @@ #include "queryserv.h" extern Zone* zone; -extern QueryServ* QServ; +extern QueryServ* QServ; /* @@ -1174,7 +1174,7 @@ XS(XS__createguild) Perl_croak(aTHX_ "Usage: createguild(guild_name, leader)"); char * guild_name = (char *)SvPV_nolen(ST(0)); - char * leader = (char *)SvPV_nolen(ST(1)); + char * leader = (char *)SvPV_nolen(ST(1)); quest_manager.CreateGuild(guild_name, leader); @@ -2668,10 +2668,10 @@ XS(XS__CreateGroundObject) uint16 id = 0; if(items == 5) - id = quest_manager.CreateGroundObject(itemid, x, y, z, heading); + id = quest_manager.CreateGroundObject(itemid, xyz_heading(x, y, z, heading)); else{ uint32 decay_time = (uint32)SvIV(ST(5)); - id = quest_manager.CreateGroundObject(itemid, x, y, z, heading, decay_time); + id = quest_manager.CreateGroundObject(itemid, xyz_heading(x, y, z, heading), decay_time); } XSRETURN_IV(id); @@ -3289,7 +3289,7 @@ XS(XS__GetZoneID) char *zone = (char *)SvPV_nolen(ST(0)); int32 id = quest_manager.GetZoneID(zone); - + XSRETURN_IV(id); } @@ -3302,7 +3302,7 @@ XS(XS__GetZoneLongName) dXSTARG; char *zone = (char *)SvPV_nolen(ST(0)); Const_char* RETVAL = quest_manager.GetZoneLongName(zone); - + sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; XSRETURN(1); } @@ -3432,7 +3432,7 @@ XS(XS__clear_npctype_cache) int32 npctype_id = (int32)SvIV(ST(0)); quest_manager.ClearNPCTypeCache(npctype_id); } - + XSRETURN_EMPTY; } @@ -3455,11 +3455,11 @@ XS(XS__qs_player_event); XS(XS__qs_player_event) { dXSARGS; - if (items != 2){ + if (items != 2){ Perl_croak(aTHX_ "Usage: qs_player_event(char_id, event_desc)"); } else{ - int char_id = (int)SvIV(ST(0)); + int char_id = (int)SvIV(ST(0)); std::string event_desc = (std::string)SvPV_nolen(ST(1)); QServ->PlayerLogEvent(Player_Log_Quest, char_id, event_desc); } @@ -3494,7 +3494,7 @@ XS(XS__crosszonesignalnpcbynpctypeid) if (items == 2) { uint32 npctype_id = (uint32)SvIV(ST(0)); - uint32 data = (uint32)SvIV(ST(1)); + uint32 data = (uint32)SvIV(ST(1)); quest_manager.CrossZoneSignalNPCByNPCTypeID(npctype_id, data); } @@ -3725,8 +3725,8 @@ EXTERN_C XS(boot_quest) newXS(strcpy(buf, "enablerecipe"), XS__enablerecipe, file); newXS(strcpy(buf, "disablerecipe"), XS__disablerecipe, file); newXS(strcpy(buf, "clear_npctype_cache"), XS__clear_npctype_cache, file); - newXS(strcpy(buf, "qs_send_query"), XS__qs_send_query, file); - newXS(strcpy(buf, "qs_player_event"), XS__qs_player_event, file); + newXS(strcpy(buf, "qs_send_query"), XS__qs_send_query, file); + newXS(strcpy(buf, "qs_player_event"), XS__qs_player_event, file); newXS(strcpy(buf, "crosszonesetentityvariablebynpctypeid"), XS__crosszonesetentityvariablebynpctypeid, file); newXS(strcpy(buf, "crosszonesignalnpcbynpctypeid"), XS__crosszonesignalnpcbynpctypeid, file); XSRETURN_YES; diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index f18ff95fb..6513d967f 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -685,11 +685,11 @@ int lua_get_level(int type) { } void lua_create_ground_object(uint32 item_id, float x, float y, float z, float h) { - quest_manager.CreateGroundObject(item_id, x, y, z, h); + quest_manager.CreateGroundObject(item_id, xyz_heading(x, y, z, h)); } void lua_create_ground_object(uint32 item_id, float x, float y, float z, float h, uint32 decay_time) { - quest_manager.CreateGroundObject(item_id, x, y, z, h, decay_time); + quest_manager.CreateGroundObject(item_id, xyz_heading(x, y, z, h), decay_time); } void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h) { diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index ccf4ef8ea..5afd56efb 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2342,10 +2342,10 @@ int QuestManager::getlevel(uint8 type) return 0; } -uint16 QuestManager::CreateGroundObject(uint32 itemid, float x, float y, float z, float heading, uint32 decay_time) +uint16 QuestManager::CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time) { uint16 entid = 0; //safety check - entid = entity_list.CreateGroundObject(itemid, xyz_heading(x, y, z, heading), decay_time); + entid = entity_list.CreateGroundObject(itemid, position, decay_time); return entid; } diff --git a/zone/questmgr.h b/zone/questmgr.h index 6b47bab04..41314b212 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -207,7 +207,7 @@ public: void enabletitle(int titleset); bool checktitle(int titlecheck); void removetitle(int titlecheck); - uint16 CreateGroundObject(uint32 itemid, float x, float y, float z, float heading, uint32 decay_time = 300000); + uint16 CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time = 300000); uint16 CreateGroundObjectFromModel(const char* model, float x, float y, float z, float heading, uint8 type = 0x00, uint32 decay_time = 0); void ModifyNPCStat(const char *identifier, const char *newValue); void UpdateSpawnTimer(uint32 id, uint32 newTime); @@ -240,7 +240,7 @@ public: uint16 CreateDoor( const char* model, float x, float y, float z, float heading, uint8 opentype, uint16 size); int32 GetZoneID(const char *zone); const char *GetZoneLongName(const char *zone); - void CrossZoneSignalPlayerByCharID(int charid, uint32 data); + void CrossZoneSignalPlayerByCharID(int charid, uint32 data); void CrossZoneSignalNPCByNPCTypeID(uint32 npctype_id, uint32 data); void CrossZoneSignalPlayerByName(const char *CharName, uint32 data); void CrossZoneSetEntityVariableByNPCTypeID(uint32 npctype_id, const char *id, const char *m_var); From c8063c31ed38d4884b7a7918c312c6d35850d06e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 22:05:34 -0800 Subject: [PATCH 054/253] QuestMgr::CreateObjectFromModel converted to xyz_heading --- zone/embparser_api.cpp | 2 +- zone/lua_general.cpp | 6 +++--- zone/questmgr.cpp | 4 ++-- zone/questmgr.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index b1f3c126d..ef486b68f 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -2699,7 +2699,7 @@ XS(XS__CreateGroundObjectFromModel) if (items > 6) decay_time = (uint32)SvIV(ST(6)); - id = quest_manager.CreateGroundObjectFromModel(modelname, x, y, z, heading, type, decay_time); + id = quest_manager.CreateGroundObjectFromModel(modelname, xyz_heading(x, y, z, heading), type, decay_time); XSRETURN_IV(id); } diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 6513d967f..efc6c48fe 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -693,15 +693,15 @@ void lua_create_ground_object(uint32 item_id, float x, float y, float z, float h } void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h) { - quest_manager.CreateGroundObjectFromModel(model, x, y, z, h); + quest_manager.CreateGroundObjectFromModel(model, xyz_heading(x, y, z, h)); } void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h, int type) { - quest_manager.CreateGroundObjectFromModel(model, x, y, z, h, type); + quest_manager.CreateGroundObjectFromModel(model, xyz_heading(x, y, z, h), type); } void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h, int type, uint32 decay_time) { - quest_manager.CreateGroundObjectFromModel(model, x, y, z, h, type, decay_time); + quest_manager.CreateGroundObjectFromModel(model, xyz_heading(x, y, z, h), type, decay_time); } void lua_create_door(const char *model, float x, float y, float z, float h, int open_type, int size) { diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 5afd56efb..79123f906 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2349,10 +2349,10 @@ uint16 QuestManager::CreateGroundObject(uint32 itemid, const xyz_heading& positi return entid; } -uint16 QuestManager::CreateGroundObjectFromModel(const char *model, float x, float y, float z, float heading, uint8 type, uint32 decay_time) +uint16 QuestManager::CreateGroundObjectFromModel(const char *model, const xyz_heading& position, uint8 type, uint32 decay_time) { uint16 entid = 0; //safety check - entid = entity_list.CreateGroundObjectFromModel(model, xyz_heading(x, y, z, heading), type, decay_time); + entid = entity_list.CreateGroundObjectFromModel(model, position, type, decay_time); return entid; } diff --git a/zone/questmgr.h b/zone/questmgr.h index 41314b212..1fd028e7b 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -208,7 +208,7 @@ public: bool checktitle(int titlecheck); void removetitle(int titlecheck); uint16 CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time = 300000); - uint16 CreateGroundObjectFromModel(const char* model, float x, float y, float z, float heading, uint8 type = 0x00, uint32 decay_time = 0); + uint16 CreateGroundObjectFromModel(const char* model, const xyz_heading& position, uint8 type = 0x00, uint32 decay_time = 0); void ModifyNPCStat(const char *identifier, const char *newValue); void UpdateSpawnTimer(uint32 id, uint32 newTime); void MerchantSetItem(uint32 NPCid, uint32 itemid, uint32 quantity = 0); From 8b7a09dbc1a1148fbb4a35e7649ceda6cc86169b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 22:14:57 -0800 Subject: [PATCH 055/253] QuestMgr::movePCInstance converted to xyz_heading --- zone/embparser_api.cpp | 4 ++-- zone/questmgr.cpp | 4 ++-- zone/questmgr.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index ef486b68f..4faae7c8c 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -2974,12 +2974,12 @@ XS(XS__MovePCInstance) if (items == 4) { - quest_manager.MovePCInstance(zoneid, instanceid, x, y, z, 0.0f); + quest_manager.MovePCInstance(zoneid, instanceid, xyz_heading(x, y, z, 0.0f)); } else { float heading = (float)SvNV(ST(5)); - quest_manager.MovePCInstance(zoneid, instanceid, x, y, z, heading); + quest_manager.MovePCInstance(zoneid, instanceid, xyz_heading(x, y, z, heading)); } XSRETURN_EMPTY; diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 79123f906..bd3c07cef 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2616,12 +2616,12 @@ void QuestManager::RemoveAllFromInstance(uint16 instance_id) } } -void QuestManager::MovePCInstance(int zone_id, int instance_id, float x, float y, float z, float heading) +void QuestManager::MovePCInstance(int zone_id, int instance_id, const xyz_heading& position) { QuestManagerCurrentQuestVars(); if(initiator) { - initiator->MovePC(zone_id, instance_id, x, y, z, heading); + initiator->MovePC(zone_id, instance_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading); } } diff --git a/zone/questmgr.h b/zone/questmgr.h index 1fd028e7b..6e8c6f4b5 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -223,7 +223,7 @@ public: //void RemoveGroupFromInstance(uint16 instance_id); //potentially useful but not implmented at this time. //void RemoveRaidFromInstance(uint16 instance_id); //potentially useful but not implmented at this time. void RemoveAllFromInstance(uint16 instance_id); - void MovePCInstance(int zone_id, int instance_id, float x, float y, float z, float heading); + void MovePCInstance(int zone_id, int instance_id, const xyz_heading& position); void FlagInstanceByGroupLeader(uint32 zone, int16 version); void FlagInstanceByRaidLeader(uint32 zone, int16 version); const char* varlink(char* perltext, int item_id); From 54f3f7f343abb35b1bf49e977b65aaa7bd909a4c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 22:28:17 -0800 Subject: [PATCH 056/253] EntityList::GetRandomClient converted to xyz_location --- zone/entity.cpp | 10 ++++------ zone/entity.h | 2 +- zone/lua_entity_list.cpp | 4 ++-- zone/perl_entity.cpp | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index da89e9397..baae4913f 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1561,16 +1561,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 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) && (it->second->DistNoRoot(location.m_X, location.m_Y, location.m_Z) <= Distance)) ClientsInRange.push_back(it->second); - ++it; - } if (ClientsInRange.empty()) return nullptr; diff --git a/zone/entity.h b/zone/entity.h index 176aa1678..9a23bafd0 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -150,7 +150,7 @@ public: Client *GetClientByCharID(uint32 iCharID); Client *GetClientByWID(uint32 iWID); Client *GetClient(uint32 ip, uint16 port); - Client *GetRandomClient(float x, float y, float z, float Distance, Client *ExcludeClient = nullptr); + Client *GetRandomClient(const xyz_location& location, float Distance, Client *ExcludeClient = nullptr); Group *GetGroupByMob(Mob* mob); Group *GetGroupByClient(Client* client); Group *GetGroupByID(uint32 id); diff --git a/zone/lua_entity_list.cpp b/zone/lua_entity_list.cpp index eace84a69..9632b6624 100644 --- a/zone/lua_entity_list.cpp +++ b/zone/lua_entity_list.cpp @@ -298,12 +298,12 @@ void Lua_EntityList::MessageGroup(Lua_Mob who, bool skip_close, uint32 type, con Lua_Client Lua_EntityList::GetRandomClient(float x, float y, float z, float dist) { Lua_Safe_Call_Class(Lua_Client); - return self->GetRandomClient(x, y, z, dist); + return self->GetRandomClient(xyz_location(x, y, z), dist); } Lua_Client Lua_EntityList::GetRandomClient(float x, float y, float z, float dist, Lua_Client exclude) { Lua_Safe_Call_Class(Lua_Client); - return self->GetRandomClient(x, y, z, dist, exclude); + return self->GetRandomClient(xyz_location(x, y, z), dist, exclude); } Lua_Mob_List Lua_EntityList::GetMobList() { diff --git a/zone/perl_entity.cpp b/zone/perl_entity.cpp index 3d685e011..a5ad00827 100644 --- a/zone/perl_entity.cpp +++ b/zone/perl_entity.cpp @@ -1875,7 +1875,7 @@ XS(XS_EntityList_GetRandomClient) c = INT2PTR(Client *,tmp); } } - RETVAL = entity_list.GetRandomClient(x, y, z, d * d, c); + RETVAL = entity_list.GetRandomClient(xyz_location(x, y, z), d * d, c); ST(0) = sv_newmortal(); sv_setref_pv(ST(0), "Client", (void*)RETVAL); } From e31c95670a13ce08b19d2bb2314629354ec7c242 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 30 Nov 2014 23:50:24 -0800 Subject: [PATCH 057/253] EntityList::ProcessMove converted to xyz_location --- zone/client.h | 2 +- zone/client_packet.cpp | 2 +- zone/entity.cpp | 14 +++++++------- zone/entity.h | 2 +- zone/zoning.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/zone/client.h b/zone/client.h index dcf665bab..80053a263 100644 --- a/zone/client.h +++ b/zone/client.h @@ -396,7 +396,7 @@ public: inline float ProximityX() const { return(proximity_x); } inline float ProximityY() const { return(proximity_y); } inline float ProximityZ() const { return(proximity_z); } - inline void ClearAllProximities() { entity_list.ProcessMove(this, FLT_MAX, FLT_MAX, FLT_MAX); proximity_x = FLT_MAX; proximity_y = FLT_MAX; proximity_z = FLT_MAX; } + inline void ClearAllProximities() { entity_list.ProcessMove(this, xyz_location(FLT_MAX, FLT_MAX, FLT_MAX)); proximity_x = FLT_MAX; proximity_y = FLT_MAX; proximity_z = FLT_MAX; } /* Begin client modifiers diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 958834784..31d7a192f 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4540,7 +4540,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) m_RewindLocation = xyz_location(ppu->x_pos, ppu->y_pos, ppu->z_pos); if(proximity_timer.Check()) { - entity_list.ProcessMove(this, ppu->x_pos, ppu->y_pos, ppu->z_pos); + entity_list.ProcessMove(this, xyz_location(ppu->x_pos, ppu->y_pos, ppu->z_pos)); if(RuleB(TaskSystem, EnableTaskSystem) && RuleB(TaskSystem,EnableTaskProximity)) ProcessTaskProximities(ppu->x_pos, ppu->y_pos, ppu->z_pos); proximity_x = ppu->x_pos; diff --git a/zone/entity.cpp b/zone/entity.cpp index baae4913f..b084235eb 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3160,7 +3160,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(); @@ -3182,9 +3182,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; } @@ -3217,9 +3217,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; } diff --git a/zone/entity.h b/zone/entity.h index 9a23bafd0..47bf35be5 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -198,7 +198,7 @@ public: void MobProcess(); void TrapProcess(); void BeaconProcess(); - void ProcessMove(Client *c, float x, float y, float z); + void ProcessMove(Client *c, const xyz_location& location); void ProcessMove(NPC *n, float x, float y, float z); void AddArea(int id, int type, float min_x, float max_x, float min_y, float max_y, float min_z, float max_z); void RemoveArea(int id); diff --git a/zone/zoning.cpp b/zone/zoning.cpp index b05b6a6e1..4dc99dd2b 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -652,7 +652,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z else { if(zoneID == GetZoneID()) { //properly handle proximities - entity_list.ProcessMove(this, m_Position.m_X, m_Position.m_Y, m_Position.m_Z); + entity_list.ProcessMove(this, m_Position); proximity_x = m_Position.m_X; proximity_y = m_Position.m_Y; proximity_z = m_Position.m_Z; From fb1d5842eac17d76853652c309d5d7054cbc15ab Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 00:03:59 -0800 Subject: [PATCH 058/253] proximity_x, proximity_y, and proximity_z converted to xyz_location m_Proximity --- zone/client.cpp | 6 ++---- zone/client.h | 13 +++++-------- zone/client_packet.cpp | 5 ++--- zone/zoning.cpp | 4 +--- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index fd229f29d..7cff859b2 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -155,7 +155,8 @@ Client::Client(EQStreamInterface* ieqs) RespawnFromHoverTimer(0), merc_timer(RuleI(Mercs, UpkeepIntervalMS)), ItemTickTimer(10000), - ItemQuestTimer(500) + ItemQuestTimer(500), + m_Proximity(FLT_MAX, FLT_MAX, FLT_MAX) //arbitrary large number { for(int cf=0; cf < _FilterCount; cf++) ClientFilters[cf] = FilterShow; @@ -208,9 +209,6 @@ Client::Client(EQStreamInterface* ieqs) zonesummon_ignorerestrictions = 0; zoning = false; zone_mode = ZoneUnsolicited; - proximity_x = FLT_MAX; //arbitrary large number - proximity_y = FLT_MAX; - proximity_z = FLT_MAX; casting_spell_id = 0; npcflag = false; npclevel = 0; diff --git a/zone/client.h b/zone/client.h index 80053a263..0bba0d931 100644 --- a/zone/client.h +++ b/zone/client.h @@ -393,10 +393,10 @@ public: inline const char* GetLastName() const { return lastname; } - inline float ProximityX() const { return(proximity_x); } - inline float ProximityY() const { return(proximity_y); } - inline float ProximityZ() const { return(proximity_z); } - inline void ClearAllProximities() { entity_list.ProcessMove(this, xyz_location(FLT_MAX, FLT_MAX, FLT_MAX)); proximity_x = FLT_MAX; proximity_y = FLT_MAX; proximity_z = FLT_MAX; } + inline float ProximityX() const { return m_Proximity.m_X; } + inline float ProximityY() const { return m_Proximity.m_Y; } + inline float ProximityZ() const { return m_Proximity.m_Z; } + inline void ClearAllProximities() { entity_list.ProcessMove(this, xyz_location(FLT_MAX, FLT_MAX, FLT_MAX)); m_Proximity = xyz_location(FLT_MAX,FLT_MAX,FLT_MAX); } /* Begin client modifiers @@ -1409,10 +1409,7 @@ private: Timer RespawnFromHoverTimer; Timer merc_timer; - float proximity_x; - float proximity_y; - float proximity_z; - + xyz_location m_Proximity; void BulkSendInventoryItems(); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 31d7a192f..1346b20e6 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4543,9 +4543,8 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) entity_list.ProcessMove(this, xyz_location(ppu->x_pos, ppu->y_pos, ppu->z_pos)); if(RuleB(TaskSystem, EnableTaskSystem) && RuleB(TaskSystem,EnableTaskProximity)) ProcessTaskProximities(ppu->x_pos, ppu->y_pos, ppu->z_pos); - proximity_x = ppu->x_pos; - proximity_y = ppu->y_pos; - proximity_z = ppu->z_pos; + + m_Proximity = xyz_location(ppu->x_pos, ppu->y_pos, ppu->z_pos); } // Update internal state diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 4dc99dd2b..3032662ab 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -653,9 +653,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z if(zoneID == GetZoneID()) { //properly handle proximities entity_list.ProcessMove(this, m_Position); - proximity_x = m_Position.m_X; - proximity_y = m_Position.m_Y; - proximity_z = m_Position.m_Z; + m_Proximity = m_Position; //send out updates to people in zone. SendPosition(); From 0a685d316de33658531baee47181157c3dbaaa39 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 00:26:35 -0800 Subject: [PATCH 059/253] zonesummon_x, zonesummon_y, and zonesummon_z converted to xyz_location m_ZoneSummonLocation --- zone/client.cpp | 6 ++---- zone/client.h | 5 ++--- zone/zoning.cpp | 36 ++++++++++++------------------------ 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 7cff859b2..c894a0ad9 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -156,7 +156,8 @@ Client::Client(EQStreamInterface* ieqs) merc_timer(RuleI(Mercs, UpkeepIntervalMS)), ItemTickTimer(10000), ItemQuestTimer(500), - m_Proximity(FLT_MAX, FLT_MAX, FLT_MAX) //arbitrary large number + m_Proximity(FLT_MAX, FLT_MAX, FLT_MAX), //arbitrary large number + m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f) { for(int cf=0; cf < _FilterCount; cf++) ClientFilters[cf] = FilterShow; @@ -202,9 +203,6 @@ Client::Client(EQStreamInterface* ieqs) auto_attack = false; auto_fire = false; linkdead_timer.Disable(); - zonesummon_x = -2; - zonesummon_y = -2; - zonesummon_z = -2; zonesummon_id = 0; zonesummon_ignorerestrictions = 0; zoning = false; diff --git a/zone/client.h b/zone/client.h index 0bba0d931..53a8ad521 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1368,9 +1368,8 @@ private: void DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instance_id, float dest_x, float dest_y, float dest_z, float dest_h, int8 ignore_r); void ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions, ZoneMode zm); void ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions = 0, ZoneMode zm = ZoneSolicited); - float zonesummon_x; - float zonesummon_y; - float zonesummon_z; + + xyz_location m_ZoneSummonLocation; uint16 zonesummon_id; uint8 zonesummon_ignorerestrictions; ZoneMode zone_mode; diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 3032662ab..49a5601aa 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -195,9 +195,9 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { dest_z = safe_z; break; case GMSummon: - dest_x = zonesummon_x; - dest_y = zonesummon_y; - dest_z = zonesummon_z; + dest_x = m_ZoneSummonLocation.m_X; + dest_y = m_ZoneSummonLocation.m_Y; + dest_z = m_ZoneSummonLocation.m_Z; ignorerestrictions = 1; break; case GateToBindPoint: @@ -213,9 +213,9 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { break; case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going. //recycle zonesummon variables - dest_x = zonesummon_x; - dest_y = zonesummon_y; - dest_z = zonesummon_z; + dest_x = m_ZoneSummonLocation.m_X; + dest_y = m_ZoneSummonLocation.m_Y; + dest_z = m_ZoneSummonLocation.m_Z; break; case ZoneUnsolicited: //client came up with this on its own. //client requested a zoning... what are the cases when this could happen? @@ -391,9 +391,7 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc //reset to unsolicited. zone_mode = ZoneUnsolicited; - zonesummon_x = 0; - zonesummon_y = 0; - zonesummon_z = 0; + m_ZoneSummonLocation = xyz_location::Origin(); zonesummon_id = 0; zonesummon_ignorerestrictions = 0; } @@ -500,18 +498,14 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z SetHeading(heading); break; case GMSummon: - zonesummon_x = m_Position.m_X = x; - zonesummon_y = m_Position.m_Y = y; - zonesummon_z = m_Position.m_Z = z; + m_ZoneSummonLocation = m_Position = xyz_heading(x,y,z,heading); SetHeading(heading); zonesummon_id = zoneID; zonesummon_ignorerestrictions = 1; break; case ZoneSolicited: - zonesummon_x = x; - zonesummon_y = y; - zonesummon_z = z; + m_ZoneSummonLocation = xyz_location(x,y,z); SetHeading(heading); zonesummon_id = zoneID; @@ -533,16 +527,12 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z LogFile->write(EQEMuLog::Debug, "Player %s has died and will be zoned to bind point in zone: %s at LOC x=%f, y=%f, z=%f, heading=%f", GetName(), pZoneName, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, m_pp.binds[0].heading); break; case SummonPC: - zonesummon_x = m_Position.m_X = x; - zonesummon_y = m_Position.m_Y = y; - zonesummon_z = m_Position.m_Z = z; + m_ZoneSummonLocation = m_Position = xyz_location(x, y, z); SetHeading(heading); break; case Rewind: LogFile->write(EQEMuLog::Debug, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_RewindLocation.m_X, m_RewindLocation.m_Y, m_RewindLocation.m_Z, zone->GetShortName()); - zonesummon_x = m_Position.m_X = x; - zonesummon_y = m_Position.m_Y = y; - zonesummon_z = m_Position.m_Z = z; + m_ZoneSummonLocation = m_Position = xyz_location(x, y, z); SetHeading(heading); break; default: @@ -682,9 +672,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z { if(zm != EvacToSafeCoords && zm != ZoneToSafeCoords && zm != ZoneToBindPoint) { - zonesummon_x = 0; - zonesummon_y = 0; - zonesummon_z = 0; + m_ZoneSummonLocation = xyz_location::Origin(); zonesummon_id = 0; zonesummon_ignorerestrictions = 0; zone_mode = ZoneUnsolicited; From f973d256dc966f0d6853fc3ae0c1c3b0100b92f7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 01:12:19 -0800 Subject: [PATCH 060/253] aa_los_me and aa_los_me_heading converted xyz_heading m_AutoAttackPosition --- zone/client.cpp | 7 ++----- zone/client.h | 3 +-- zone/client_packet.cpp | 15 +++------------ zone/client_process.cpp | 20 +++++++------------- 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index c894a0ad9..c4aab1733 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -157,7 +157,8 @@ Client::Client(EQStreamInterface* ieqs) ItemTickTimer(10000), ItemQuestTimer(500), m_Proximity(FLT_MAX, FLT_MAX, FLT_MAX), //arbitrary large number - m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f) + m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f), + m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f) { for(int cf=0; cf < _FilterCount; cf++) ClientFilters[cf] = FilterShow; @@ -275,10 +276,6 @@ Client::Client(EQStreamInterface* ieqs) m_AssistExemption = 0; m_CheatDetectMoved = false; CanUseReport = true; - aa_los_me.x = 0; - aa_los_me.y = 0; - aa_los_me.z = 0; - aa_los_me_heading = 0; aa_los_them.x = 0; aa_los_them.y = 0; aa_los_them.z = 0; diff --git a/zone/client.h b/zone/client.h index 53a8ad521..ad2414d60 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1211,11 +1211,10 @@ protected: Mob* bind_sight_target; - Map::Vertex aa_los_me; + xyz_heading m_AutoAttackPosition; Map::Vertex aa_los_them; Mob *aa_los_them_mob; bool los_status; - float aa_los_me_heading; bool los_status_facing; QGlobalCache *qGlobals; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 1346b20e6..fbbce9e83 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3224,10 +3224,7 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) ranged_timer.Disable(); attack_dw_timer.Disable(); - aa_los_me.x = 0; - aa_los_me.y = 0; - aa_los_me.z = 0; - aa_los_me_heading = 0; + m_AutoAttackPosition = xyz_heading::Origin(); aa_los_them.x = 0; aa_los_them.y = 0; aa_los_them.z = 0; @@ -3244,10 +3241,7 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) if (GetTarget()) { aa_los_them_mob = GetTarget(); - aa_los_me.x = GetX(); - aa_los_me.y = GetY(); - aa_los_me.z = GetZ(); - aa_los_me_heading = GetHeading(); + m_AutoAttackPosition = GetPosition(); aa_los_them.x = aa_los_them_mob->GetX(); aa_los_them.y = aa_los_them_mob->GetY(); aa_los_them.z = aa_los_them_mob->GetZ(); @@ -3256,10 +3250,7 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) } else { - aa_los_me.x = GetX(); - aa_los_me.y = GetY(); - aa_los_me.z = GetZ(); - aa_los_me_heading = GetHeading(); + m_AutoAttackPosition = GetPosition(); aa_los_them.x = 0; aa_los_them.y = 0; aa_los_them.z = 0; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 14f26f4df..22498e4ab 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -354,38 +354,32 @@ bool Client::Process() { if(aa_los_them_mob) { if(auto_attack_target != aa_los_them_mob || - aa_los_me.x != GetX() || - aa_los_me.y != GetY() || - aa_los_me.z != GetZ() || + m_AutoAttackPosition.m_X != GetX() || + m_AutoAttackPosition.m_Y != GetY() || + m_AutoAttackPosition.m_Z != GetZ() || aa_los_them.x != aa_los_them_mob->GetX() || aa_los_them.y != aa_los_them_mob->GetY() || aa_los_them.z != aa_los_them_mob->GetZ()) { aa_los_them_mob = auto_attack_target; - aa_los_me.x = GetX(); - aa_los_me.y = GetY(); - aa_los_me.z = GetZ(); + m_AutoAttackPosition = GetPosition(); aa_los_them.x = aa_los_them_mob->GetX(); aa_los_them.y = aa_los_them_mob->GetY(); aa_los_them.z = aa_los_them_mob->GetZ(); los_status = CheckLosFN(auto_attack_target); - aa_los_me_heading = GetHeading(); 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(); + if (m_AutoAttackPosition.m_Heading != GetHeading()) { + m_AutoAttackPosition.m_Heading = GetHeading(); los_status_facing = IsFacingMob(aa_los_them_mob); } } else { aa_los_them_mob = auto_attack_target; - aa_los_me.x = GetX(); - aa_los_me.y = GetY(); - aa_los_me.z = GetZ(); - aa_los_me_heading = GetHeading(); + m_AutoAttackPosition = GetPosition(); aa_los_them.x = aa_los_them_mob->GetX(); aa_los_them.y = aa_los_them_mob->GetY(); aa_los_them.z = aa_los_them_mob->GetZ(); From 5af1998167fc232a6549587b92389deebb9f1e6e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 01:23:58 -0800 Subject: [PATCH 061/253] aa_los_them converted to xyz_location m_AutoAttackTargetLocation --- zone/client.cpp | 6 ++---- zone/client.h | 2 +- zone/client_packet.cpp | 12 +++--------- zone/client_process.cpp | 14 +++++--------- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index c4aab1733..e2ec14178 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -158,7 +158,8 @@ Client::Client(EQStreamInterface* ieqs) ItemQuestTimer(500), m_Proximity(FLT_MAX, FLT_MAX, FLT_MAX), //arbitrary large number m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f), - m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f) + m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f), + m_AutoAttackTargetLocation(0.0f, 0.0f, 0.0f) { for(int cf=0; cf < _FilterCount; cf++) ClientFilters[cf] = FilterShow; @@ -276,9 +277,6 @@ Client::Client(EQStreamInterface* ieqs) m_AssistExemption = 0; m_CheatDetectMoved = false; CanUseReport = true; - aa_los_them.x = 0; - aa_los_them.y = 0; - aa_los_them.z = 0; aa_los_them_mob = nullptr; los_status = false; los_status_facing = false; diff --git a/zone/client.h b/zone/client.h index ad2414d60..004adfede 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1212,7 +1212,7 @@ protected: Mob* bind_sight_target; xyz_heading m_AutoAttackPosition; - Map::Vertex aa_los_them; + xyz_location m_AutoAttackTargetLocation; Mob *aa_los_them_mob; bool los_status; bool los_status_facing; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index fbbce9e83..475188975 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3225,9 +3225,7 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) attack_dw_timer.Disable(); m_AutoAttackPosition = xyz_heading::Origin(); - aa_los_them.x = 0; - aa_los_them.y = 0; - aa_los_them.z = 0; + m_AutoAttackTargetLocation = xyz_location::Origin(); aa_los_them_mob = nullptr; } else if (app->pBuffer[0] == 1) @@ -3242,18 +3240,14 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) { aa_los_them_mob = GetTarget(); m_AutoAttackPosition = GetPosition(); - aa_los_them.x = aa_los_them_mob->GetX(); - aa_los_them.y = aa_los_them_mob->GetY(); - aa_los_them.z = aa_los_them_mob->GetZ(); + m_AutoAttackTargetLocation = aa_los_them_mob->GetPosition(); los_status = CheckLosFN(aa_los_them_mob); los_status_facing = IsFacingMob(aa_los_them_mob); } else { m_AutoAttackPosition = GetPosition(); - aa_los_them.x = 0; - aa_los_them.y = 0; - aa_los_them.z = 0; + m_AutoAttackTargetLocation = xyz_location::Origin(); aa_los_them_mob = nullptr; los_status = false; los_status_facing = false; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 22498e4ab..7d2bac2c9 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -357,15 +357,13 @@ bool Client::Process() { m_AutoAttackPosition.m_X != GetX() || m_AutoAttackPosition.m_Y != GetY() || m_AutoAttackPosition.m_Z != GetZ() || - aa_los_them.x != aa_los_them_mob->GetX() || - aa_los_them.y != aa_los_them_mob->GetY() || - aa_los_them.z != aa_los_them_mob->GetZ()) + m_AutoAttackTargetLocation.m_X != aa_los_them_mob->GetX() || + m_AutoAttackTargetLocation.m_Y != aa_los_them_mob->GetY() || + m_AutoAttackTargetLocation.m_Z != aa_los_them_mob->GetZ()) { aa_los_them_mob = auto_attack_target; m_AutoAttackPosition = GetPosition(); - aa_los_them.x = aa_los_them_mob->GetX(); - aa_los_them.y = aa_los_them_mob->GetY(); - aa_los_them.z = aa_los_them_mob->GetZ(); + m_AutoAttackTargetLocation = aa_los_them_mob->GetPosition(); los_status = CheckLosFN(auto_attack_target); los_status_facing = IsFacingMob(aa_los_them_mob); } @@ -380,9 +378,7 @@ bool Client::Process() { { aa_los_them_mob = auto_attack_target; m_AutoAttackPosition = GetPosition(); - aa_los_them.x = aa_los_them_mob->GetX(); - aa_los_them.y = aa_los_them_mob->GetY(); - aa_los_them.z = aa_los_them_mob->GetZ(); + m_AutoAttackTargetLocation = aa_los_them_mob->GetPosition(); los_status = CheckLosFN(auto_attack_target); los_status_facing = IsFacingMob(aa_los_them_mob); } From 31d32682b05997ce5a33947821f9e1e7ec4c0264 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 12:30:07 -0800 Subject: [PATCH 062/253] ZoneDatabase::InsertDoor converted to xyz_heading --- zone/doors.cpp | 2 +- zone/zonedb.cpp | 236 ++++++++++++++++++++++++------------------------ zone/zonedb.h | 15 +-- 3 files changed, 127 insertions(+), 126 deletions(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index 24bee901b..5910b320b 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -735,6 +735,6 @@ void Doors::CreateDatabaseEntry() { return; } - database.InsertDoor(GetDoorDBID(), GetDoorID(), GetDoorName(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_Position.m_Heading, GetOpenType(), GetGuildID(), GetLockpick(), GetKeyItem(), GetDoorParam(), GetInvertState(), GetIncline(), GetSize()); + database.InsertDoor(GetDoorDBID(), GetDoorID(), GetDoorName(), m_Position, GetOpenType(), GetGuildID(), GetLockpick(), GetKeyItem(), GetDoorParam(), GetInvertState(), GetIncline(), GetSize()); } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 11d76e4af..3b9c69943 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -567,7 +567,7 @@ TraderCharges_Struct* ZoneDatabase::LoadTraderItemWithCharges(uint32 char_id) return loadti; } -ItemInst* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int SerialNumber) { +ItemInst* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int SerialNumber) { std::string query = StringFormat("SELECT * FROM trader WHERE char_id = %i AND serialnumber = %i " "ORDER BY slot_id LIMIT 80", CharID, SerialNumber); auto results = QueryDatabase(query); @@ -624,7 +624,7 @@ void ZoneDatabase::SaveTraderItem(uint32 CharID, uint32 ItemID, uint32 SerialNum } -void ZoneDatabase::UpdateTraderItemCharges(int CharID, uint32 SerialNumber, int32 Charges) { +void ZoneDatabase::UpdateTraderItemCharges(int CharID, uint32 SerialNumber, int32 Charges) { _log(TRADING__CLIENT, "ZoneDatabase::UpdateTraderItemCharges(%i, %i, %i)", CharID, SerialNumber, Charges); std::string query = StringFormat("UPDATE trader SET charges = %i WHERE char_id = %i AND serialnumber = %i", @@ -718,7 +718,7 @@ void ZoneDatabase::DeleteBuyLines(uint32 CharID) { } -void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, const char* ItemName, uint32 Quantity, uint32 Price) { +void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, const char* ItemName, uint32 Quantity, uint32 Price) { std::string query = StringFormat("REPLACE INTO buyer VALUES(%i, %i, %i, \"%s\", %i, %i)", CharID, BuySlot, ItemID, ItemName, Quantity, Price); auto results = QueryDatabase(query); @@ -727,7 +727,7 @@ void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, cons } -void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) { +void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) { std::string query = StringFormat("DELETE FROM buyer WHERE charid = %i AND buyslot = %i", CharID, BuySlot); auto results = QueryDatabase(query); if (!results.Success()) @@ -735,7 +735,7 @@ void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) { } -void ZoneDatabase::UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity) { +void ZoneDatabase::UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity) { if(Quantity <= 0) { RemoveBuyLine(CharID, BuySlot); return; @@ -959,16 +959,16 @@ bool ZoneDatabase::LoadCharacterMemmedSpells(uint32 character_id, PlayerProfile_ "FROM " "`character_memmed_spells` " "WHERE `id` = %u ORDER BY `slot_id`", character_id); - auto results = database.QueryDatabase(query); + auto results = database.QueryDatabase(query); int i = 0; /* Initialize Spells */ for (i = 0; i < MAX_PP_MEMSPELL; i++){ pp->mem_spells[i] = 0xFFFFFFFF; } for (auto row = results.begin(); row != results.end(); ++row) { - i = atoi(row[0]); + i = atoi(row[0]); if (i < MAX_PP_MEMSPELL && atoi(row[1]) <= SPDAT_RECORDS){ - pp->mem_spells[i] = atoi(row[1]); + pp->mem_spells[i] = atoi(row[1]); } } return true; @@ -982,36 +982,36 @@ bool ZoneDatabase::LoadCharacterSpellBook(uint32 character_id, PlayerProfile_Str "FROM " "`character_spells` " "WHERE `id` = %u ORDER BY `slot_id`", character_id); - auto results = database.QueryDatabase(query); + auto results = database.QueryDatabase(query); int i = 0; /* Initialize Spells */ for (i = 0; i < MAX_PP_SPELLBOOK; i++){ - pp->spell_book[i] = 0xFFFFFFFF; + pp->spell_book[i] = 0xFFFFFFFF; } - for (auto row = results.begin(); row != results.end(); ++row) { + for (auto row = results.begin(); row != results.end(); ++row) { i = atoi(row[0]); if (i < MAX_PP_SPELLBOOK && atoi(row[1]) <= SPDAT_RECORDS){ - pp->spell_book[i] = atoi(row[1]); - } - } + pp->spell_book[i] = atoi(row[1]); + } + } return true; } -bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Struct* pp){ +bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Struct* pp){ std::string query = StringFormat( "SELECT " "lang_id, " "`value` " "FROM " "`character_languages` " - "WHERE `id` = %u ORDER BY `lang_id`", character_id); - auto results = database.QueryDatabase(query); int i = 0; + "WHERE `id` = %u ORDER BY `lang_id`", character_id); + auto results = database.QueryDatabase(query); int i = 0; /* Initialize Languages */ - for (i = 0; i < MAX_PP_LANGUAGE; i++){ + for (i = 0; i < MAX_PP_LANGUAGE; i++){ pp->languages[i] = 0; } - for (auto row = results.begin(); row != results.end(); ++row) { - i = atoi(row[0]); + for (auto row = results.begin(); row != results.end(); ++row) { + i = atoi(row[0]); if (i < MAX_PP_LANGUAGE){ pp->languages[i] = atoi(row[1]); } @@ -1022,9 +1022,9 @@ bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Str bool ZoneDatabase::LoadCharacterLeadershipAA(uint32 character_id, PlayerProfile_Struct* pp){ std::string query = StringFormat("SELECT slot, rank FROM character_leadership_abilities WHERE `id` = %u", character_id); auto results = database.QueryDatabase(query); uint32 slot = 0; - for (auto row = results.begin(); row != results.end(); ++row) { + for (auto row = results.begin(); row != results.end(); ++row) { slot = atoi(row[0]); - pp->leader_abilities.ranks[slot] = atoi(row[1]); + pp->leader_abilities.ranks[slot] = atoi(row[1]); } return true; } @@ -1036,17 +1036,17 @@ bool ZoneDatabase::LoadCharacterDisciplines(uint32 character_id, PlayerProfile_S "FROM " "`character_disciplines`" "WHERE `id` = %u ORDER BY `slot_id`", character_id); - auto results = database.QueryDatabase(query); + auto results = database.QueryDatabase(query); int i = 0; /* Initialize Disciplines */ memset(pp->disciplines.values, 0, (sizeof(pp->disciplines.values[0]) * MAX_PP_DISCIPLINES)); - for (auto row = results.begin(); row != results.end(); ++row) { - if (i < MAX_PP_DISCIPLINES){ + for (auto row = results.begin(); row != results.end(); ++row) { + if (i < MAX_PP_DISCIPLINES){ pp->disciplines.values[i] = atoi(row[0]); } - i++; - } - return true; + i++; + } + return true; } bool ZoneDatabase::LoadCharacterSkills(uint32 character_id, PlayerProfile_Struct* pp){ @@ -1057,13 +1057,13 @@ bool ZoneDatabase::LoadCharacterSkills(uint32 character_id, PlayerProfile_Struct "FROM " "`character_skills` " "WHERE `id` = %u ORDER BY `skill_id`", character_id); - auto results = database.QueryDatabase(query); int i = 0; + auto results = database.QueryDatabase(query); int i = 0; /* Initialize Skill */ - for (i = 0; i < MAX_PP_SKILL; i++){ + for (i = 0; i < MAX_PP_SKILL; i++){ pp->skills[i] = 0; } - for (auto row = results.begin(); row != results.end(); ++row) { - i = atoi(row[0]); + for (auto row = results.begin(); row != results.end(); ++row) { + i = atoi(row[0]); if (i < MAX_PP_SKILL){ pp->skills[i] = atoi(row[1]); } @@ -1091,7 +1091,7 @@ bool ZoneDatabase::LoadCharacterCurrency(uint32 character_id, PlayerProfile_Stru "ebon_crystals, " "career_ebon_crystals " "FROM " - "character_currency " + "character_currency " "WHERE `id` = %i ", character_id); auto results = database.QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { @@ -1134,7 +1134,7 @@ bool ZoneDatabase::LoadCharacterBandolier(uint32 character_id, PlayerProfile_Str auto results = database.QueryDatabase(query); int i = 0; int r = 0; int si = 0; for (i = 0; i <= EmuConstants::BANDOLIERS_COUNT; i++){ for (int si = 0; si < EmuConstants::BANDOLIER_SIZE; si++){ - pp->bandoliers[i].items[si].icon = 0; + pp->bandoliers[i].items[si].icon = 0; } } @@ -1142,9 +1142,9 @@ bool ZoneDatabase::LoadCharacterBandolier(uint32 character_id, PlayerProfile_Str r = 0; i = atoi(row[r]); /* Bandolier ID */ r++; si = atoi(row[r]); /* Bandolier Slot */ r++; - pp->bandoliers[i].items[si].item_id = atoi(row[r]); r++; + pp->bandoliers[i].items[si].item_id = atoi(row[r]); r++; pp->bandoliers[i].items[si].icon = atoi(row[r]); r++; - strcpy(pp->bandoliers[i].name, row[r]); r++; + strcpy(pp->bandoliers[i].name, row[r]); r++; si++; } return true; @@ -1152,7 +1152,7 @@ bool ZoneDatabase::LoadCharacterBandolier(uint32 character_id, PlayerProfile_Str bool ZoneDatabase::LoadCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp){ std::string query = StringFormat("SELECT `tier`, `tribute` FROM `character_tribute` WHERE `id` = %u", character_id); - auto results = database.QueryDatabase(query); + auto results = database.QueryDatabase(query); int i = 0; for (i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){ pp->tributes[i].tribute = 0xFFFFFFFF; @@ -1170,7 +1170,7 @@ bool ZoneDatabase::LoadCharacterTribute(uint32 character_id, PlayerProfile_Struc } bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struct* pp){ - std::string query = StringFormat("SELECT `potion_id`, `item_id`, `icon` FROM `character_potionbelt` WHERE `id` = %u LIMIT 4", character_id); + std::string query = StringFormat("SELECT `potion_id`, `item_id`, `icon` FROM `character_potionbelt` WHERE `id` = %u LIMIT 4", character_id); auto results = database.QueryDatabase(query); int i = 0; for (i = 0; i < EmuConstants::POTION_BELT_SIZE; i++){ pp->potionbelt.items[i].icon = 0; @@ -1194,10 +1194,10 @@ bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struc bool ZoneDatabase::LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Struct* pp){ std::string query = StringFormat("SELECT `zone_id`, `instance_id`, `x`, `y`, `z`, `heading`, `is_home` FROM `character_bind` WHERE `id` = %u LIMIT 2", character_id); auto results = database.QueryDatabase(query); int i = 0; - for (auto row = results.begin(); row != results.end(); ++row) { + for (auto row = results.begin(); row != results.end(); ++row) { i = 0; /* Is home bind */ - if (atoi(row[6]) == 1){ + if (atoi(row[6]) == 1){ pp->binds[4].zoneId = atoi(row[i++]); pp->binds[4].instance_id = atoi(row[i++]); pp->binds[4].x = atoi(row[i++]); @@ -1225,7 +1225,7 @@ bool ZoneDatabase::SaveCharacterLanguage(uint32 character_id, uint32 lang_id, ui } bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading, uint8 is_home){ - if (zone_id <= 0) { + if (zone_id <= 0) { return false; } @@ -1233,7 +1233,7 @@ bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, u std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)" " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, zone_id, instance_id, x, y, z, heading, is_home); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterBindPoint for character ID: %i zone_id: %u instance_id: %u x: %f y: %f z: %f heading: %f ishome: %u", character_id, zone_id, instance_id, x, y, z, heading, is_home); - auto results = QueryDatabase(query); + auto results = QueryDatabase(query); if (!results.RowsAffected()) { LogFile->write(EQEMuLog::Debug, "ERROR Bind Home Save: %s. %s", results.ErrorMessage().c_str(), query.c_str()); } @@ -1241,9 +1241,9 @@ bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, u } bool ZoneDatabase::SaveCharacterMaterialColor(uint32 character_id, uint32 slot_id, uint32 color){ - uint8 red = (color & 0x00FF0000) >> 16; + uint8 red = (color & 0x00FF0000) >> 16; uint8 green = (color & 0x0000FF00) >> 8; - uint8 blue = (color & 0x000000FF); + uint8 blue = (color & 0x000000FF); std::string query = StringFormat("REPLACE INTO `character_material` (id, slot, red, green, blue, color, use_tint) VALUES (%u, %u, %u, %u, %u, %u, 255)", character_id, slot_id, red, green, blue, color); auto results = QueryDatabase(query); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterMaterialColor for character ID: %i, slot_id: %u color: %u done", character_id, slot_id, color); @@ -1257,30 +1257,30 @@ bool ZoneDatabase::SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint } bool ZoneDatabase::SaveCharacterDisc(uint32 character_id, uint32 slot_id, uint32 disc_id){ - std::string query = StringFormat("REPLACE INTO `character_disciplines` (id, slot_id, disc_id) VALUES (%u, %u, %u)", character_id, slot_id, disc_id); + std::string query = StringFormat("REPLACE INTO `character_disciplines` (id, slot_id, disc_id) VALUES (%u, %u, %u)", character_id, slot_id, disc_id); auto results = QueryDatabase(query); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterDisc for character ID: %i, slot:%u disc_id:%u done", character_id, slot_id, disc_id); - return true; + return true; } bool ZoneDatabase::SaveCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp){ - std::string query = StringFormat("DELETE FROM `character_tribute` WHERE `id` = %u", character_id); + std::string query = StringFormat("DELETE FROM `character_tribute` WHERE `id` = %u", character_id); QueryDatabase(query); /* Save Tributes only if we have values... */ for (int i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){ if (pp->tributes[i].tribute > 0 && pp->tributes[i].tribute != TRIBUTE_NONE){ - std::string query = StringFormat("REPLACE INTO `character_tribute` (id, tier, tribute) VALUES (%u, %u, %u)", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); + std::string query = StringFormat("REPLACE INTO `character_tribute` (id, tier, tribute) VALUES (%u, %u, %u)", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); QueryDatabase(query); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterTribute for character ID: %i, tier:%u tribute:%u done", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); } - } + } return true; } bool ZoneDatabase::SaveCharacterBandolier(uint32 character_id, uint8 bandolier_id, uint8 bandolier_slot, uint32 item_id, uint32 icon, const char* bandolier_name){ char bandolier_name_esc[64]; DoEscapeString(bandolier_name_esc, bandolier_name, strlen(bandolier_name)); - std::string query = StringFormat("REPLACE INTO `character_bandolier` (id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name) VALUES (%u, %u, %u, %u, %u,'%s')", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name_esc); + std::string query = StringFormat("REPLACE INTO `character_bandolier` (id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name) VALUES (%u, %u, %u, %u, %u,'%s')", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name_esc); auto results = QueryDatabase(query); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterBandolier for character ID: %i, bandolier_id: %u, bandolier_slot: %u item_id: %u, icon:%u band_name:%s done", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name); if (!results.RowsAffected()){ std::cout << "ERROR Bandolier Save: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; } @@ -1501,7 +1501,7 @@ bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, Pla "%u," // e_aa_effects "%u," // e_percent_to_aa "%u" // e_expended_aa_spent - ")", + ")", character_id, // " id, " account_id, // " account_id, " EscapeString(pp->name).c_str(), // " `name`, " @@ -1637,8 +1637,8 @@ bool ZoneDatabase::SaveCharacterCurrency(uint32 character_id, PlayerProfile_Stru pp->careerRadCrystals, pp->currentEbonCrystals, pp->careerEbonCrystals); - auto results = database.QueryDatabase(query); - LogFile->write(EQEMuLog::Debug, "Saving Currency for character ID: %i, done", character_id); + auto results = database.QueryDatabase(query); + LogFile->write(EQEMuLog::Debug, "Saving Currency for character ID: %i, done", character_id); return true; } @@ -1653,62 +1653,62 @@ bool ZoneDatabase::SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 cur bool ZoneDatabase::SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){ if (spell_id > SPDAT_RECORDS){ return false; } - std::string query = StringFormat("REPLACE INTO `character_memmed_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id); - QueryDatabase(query); + std::string query = StringFormat("REPLACE INTO `character_memmed_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id); + QueryDatabase(query); return true; } bool ZoneDatabase::SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){ if (spell_id > SPDAT_RECORDS){ return false; } - std::string query = StringFormat("REPLACE INTO `character_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id); - QueryDatabase(query); + std::string query = StringFormat("REPLACE INTO `character_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id); + QueryDatabase(query); return true; } bool ZoneDatabase::DeleteCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){ - std::string query = StringFormat("DELETE FROM `character_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); - QueryDatabase(query); + std::string query = StringFormat("DELETE FROM `character_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); + QueryDatabase(query); return true; } bool ZoneDatabase::DeleteCharacterDisc(uint32 character_id, uint32 slot_id){ - std::string query = StringFormat("DELETE FROM `character_disciplines` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); - QueryDatabase(query); - return true; + std::string query = StringFormat("DELETE FROM `character_disciplines` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); + QueryDatabase(query); + return true; } bool ZoneDatabase::DeleteCharacterBandolier(uint32 character_id, uint32 band_id){ - std::string query = StringFormat("DELETE FROM `character_bandolier` WHERE `bandolier_id` = %u AND `id` = %u", band_id, character_id); - QueryDatabase(query); - return true; + std::string query = StringFormat("DELETE FROM `character_bandolier` WHERE `bandolier_id` = %u AND `id` = %u", band_id, character_id); + QueryDatabase(query); + return true; } bool ZoneDatabase::DeleteCharacterLeadershipAAs(uint32 character_id){ - std::string query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", character_id); - QueryDatabase(query); - return true; + std::string query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", character_id); + QueryDatabase(query); + return true; } bool ZoneDatabase::DeleteCharacterAAs(uint32 character_id){ - std::string query = StringFormat("DELETE FROM `character_alternate_abilities` WHERE `id` = %u", character_id); - QueryDatabase(query); + std::string query = StringFormat("DELETE FROM `character_alternate_abilities` WHERE `id` = %u", character_id); + QueryDatabase(query); return true; } bool ZoneDatabase::DeleteCharacterDye(uint32 character_id){ std::string query = StringFormat("DELETE FROM `character_material` WHERE `id` = %u", character_id); - QueryDatabase(query); + QueryDatabase(query); return true; } -bool ZoneDatabase::DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){ - std::string query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); - QueryDatabase(query); +bool ZoneDatabase::DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){ + std::string query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); + QueryDatabase(query); return true; } bool ZoneDatabase::NoRentExpired(const char* name){ - std::string query = StringFormat("SELECT (UNIX_TIMESTAMP(NOW()) - last_login) FROM `character_data` WHERE name = '%s'", name); + std::string query = StringFormat("SELECT (UNIX_TIMESTAMP(NOW()) - last_login) FROM `character_data` WHERE name = '%s'", name); auto results = QueryDatabase(query); if (!results.Success()) return false; @@ -2113,7 +2113,7 @@ bool ZoneDatabase::LoadMercInfo(Client *client) { auto results = QueryDatabase(query); if (!results.Success()) return false; - + if(results.RowCount() == 0) return false; @@ -2169,7 +2169,7 @@ bool ZoneDatabase::LoadCurrentMerc(Client *client) { if(!results.Success()) return false; - + if(results.RowCount() == 0) return false; @@ -2750,7 +2750,7 @@ void ZoneDatabase::QGlobalPurge() database.QueryDatabase(query); } -void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoor_name, float dxpos, float dypos, float dzpos, float dheading, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize){ +void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoor_name, const xyz_heading& position, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize){ std::string query = StringFormat("REPLACE INTO doors (id, doorid, zone, version, name, " "pos_x, pos_y, pos_z, heading, opentype, guild, lockpick, " @@ -2758,8 +2758,8 @@ void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoo "VALUES('%i', '%i', '%s', '%i', '%s', '%f', '%f', " "'%f', '%f', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i')", ddoordbid, ddoorid, zone->GetShortName(), zone->GetInstanceVersion(), - ddoor_name, dxpos, dypos, dzpos, dheading, dopentype, dguildid, - dlockpick, dkeyitem, ddoor_param, dinvert, dincline, dsize); + ddoor_name, position.m_X, position.m_Y, position.m_Z, position.m_Heading, + dopentype, dguildid, dlockpick, dkeyitem, ddoor_param, dinvert, dincline, dsize); auto results = QueryDatabase(query); if (!results.Success()) std::cerr << "Error in InsertDoor" << query << "' " << results.ErrorMessage() << std::endl; @@ -3332,13 +3332,13 @@ bool ZoneDatabase::DeleteGraveyard(uint32 zone_id, uint32 graveyard_id) { if (results.Success() && results2.Success()){ return true; } - + return false; } uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) { std::string query = StringFormat( - "UPDATE `zone` SET `graveyard_id` = %u WHERE `zone_idnumber` = %u AND `version` = 0", + "UPDATE `zone` SET `graveyard_id` = %u WHERE `zone_idnumber` = %u AND `version` = 0", graveyard_id, zone_id ); auto results = QueryDatabase(query); @@ -3347,7 +3347,7 @@ uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) { uint32 ZoneDatabase::CreateGraveyardRecord(uint32 graveyard_zone_id, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading) { std::string query = StringFormat( - "INSERT INTO `graveyard` SET `zone_id` = %u, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f", + "INSERT INTO `graveyard` SET `zone_id` = %u, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f", graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, graveyard_heading ); auto results = QueryDatabase(query); @@ -3360,7 +3360,7 @@ uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id, std::string query = StringFormat( "UPDATE `character_corpses` " "SET `zone_id` = %u, `instance_id` = 0, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f, `was_at_graveyard` = 1 " - "WHERE `id` = %d", + "WHERE `id` = %d", zone_id, x, y, z, heading, dbid ); QueryDatabase(query); @@ -3372,7 +3372,7 @@ uint32 ZoneDatabase::GetCharacterCorpseDecayTimer(uint32 corpse_db_id){ auto results = QueryDatabase(query); auto row = results.begin(); if (results.Success() && results.RowsAffected() != 0){ - return atoll(row[0]); + return atoll(row[0]); } return 0; } @@ -3421,12 +3421,12 @@ uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const c "`wc_8` = %u,\n" "`wc_9` = %u \n" "WHERE `id` = %u", - EscapeString(char_name).c_str(), - zone_id, - instance_id, - char_id, - x, - y, + EscapeString(char_name).c_str(), + zone_id, + instance_id, + char_id, + x, + y, z, heading, dbpc->locked, @@ -3562,29 +3562,29 @@ uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, ui dbpc->item_tint[7].color, dbpc->item_tint[8].color ); - auto results = QueryDatabase(query); + auto results = QueryDatabase(query); uint32 last_insert_id = results.LastInsertedID(); /* Dump Items from Inventory */ uint8 first_entry = 0; - for (unsigned int i = 0; i < dbpc->itemcount; i++) { + for (unsigned int i = 0; i < dbpc->itemcount; i++) { if (first_entry != 1){ query = StringFormat("REPLACE INTO `character_corpse_items` \n" " (corpse_id, equip_slot, item_id, charges, aug_1, aug_2, aug_3, aug_4, aug_5, attuned) \n" " VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n", - last_insert_id, + last_insert_id, dbpc->items[i].equip_slot, - dbpc->items[i].item_id, - dbpc->items[i].charges, - dbpc->items[i].aug_1, - dbpc->items[i].aug_2, - dbpc->items[i].aug_3, - dbpc->items[i].aug_4, + dbpc->items[i].item_id, + dbpc->items[i].charges, + dbpc->items[i].aug_1, + dbpc->items[i].aug_2, + dbpc->items[i].aug_3, + dbpc->items[i].aug_4, dbpc->items[i].aug_5 ); first_entry = 1; } - else{ + else{ query = query + StringFormat(", (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n", last_insert_id, dbpc->items[i].equip_slot, @@ -3598,13 +3598,13 @@ uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, ui ); } } - auto sc_results = QueryDatabase(query); + auto sc_results = QueryDatabase(query); return last_insert_id; } uint32 ZoneDatabase::GetCharacterBuriedCorpseCount(uint32 char_id) { std::string query = StringFormat("SELECT COUNT(*) FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 1", char_id); - auto results = QueryDatabase(query); + auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { return atoi(row[0]); @@ -3614,7 +3614,7 @@ uint32 ZoneDatabase::GetCharacterBuriedCorpseCount(uint32 char_id) { uint32 ZoneDatabase::GetCharacterCorpseCount(uint32 char_id) { std::string query = StringFormat("SELECT COUNT(*) FROM `character_corpses` WHERE `charid` = '%u'", char_id); - auto results = QueryDatabase(query); + auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { return atoi(row[0]); @@ -3698,7 +3698,7 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct "WHERE `id` = %u LIMIT 1\n", corpse_id ); - auto results = QueryDatabase(query); + auto results = QueryDatabase(query); uint16 i = 0; for (auto row = results.begin(); row != results.end(); ++row) { pcs->locked = atoi(row[i++]); // is_locked, @@ -3755,7 +3755,7 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct ); results = QueryDatabase(query); - i = 0; + i = 0; pcs->itemcount = results.RowCount(); uint16 r = 0; for (auto row = results.begin(); row != results.end(); ++row) { @@ -3778,7 +3778,7 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, float dest_x, float dest_y, float dest_z, float dest_heading) { Corpse* NewCorpse = 0; std::string query = StringFormat( - "SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 1 ORDER BY `time_of_death` LIMIT 1", + "SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 1 ORDER BY `time_of_death` LIMIT 1", char_id ); auto results = QueryDatabase(query); @@ -3796,7 +3796,7 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z atoi(row[3]) == 1, // bool rezzed false // bool was_at_graveyard ); - if (NewCorpse) { + if (NewCorpse) { entity_list.AddCorpse(NewCorpse); NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); NewCorpse->Spawn(); @@ -3820,7 +3820,7 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id query = StringFormat( "SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u'" - "ORDER BY time_of_death", + "ORDER BY time_of_death", char_id ); results = QueryDatabase(query); @@ -3853,7 +3853,7 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint16 new_instance_id, float new_x, float new_y, float new_z, float new_heading) { std::string query = StringFormat( - "UPDATE `character_corpses` SET `is_buried` = 0, `zone_id` = %u, `instance_id` = %u, `x` = %f, `y` = %f, `z` = %f, `heading` = %f, `time_of_death` = Now(), `was_at_graveyard` = 0 WHERE `id` = %u", + "UPDATE `character_corpses` SET `is_buried` = 0, `zone_id` = %u, `instance_id` = %u, `x` = %f, `y` = %f, `z` = %f, `heading` = %f, `time_of_death` = Now(), `was_at_graveyard` = 0 WHERE `id` = %u", new_zone_id, new_instance_id, new_x, new_y, new_z, new_heading, db_id ); auto results = QueryDatabase(query); @@ -3866,7 +3866,7 @@ bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint1 Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) { Corpse* NewCorpse = 0; std::string query = StringFormat( - "SELECT `id`, `charid`, `charname`, `x`, `y`, `z`, `heading`, `time_of_death`, `is_rezzed`, `was_at_graveyard` FROM `character_corpses` WHERE `id` = '%u' LIMIT 1", + "SELECT `id`, `charid`, `charname`, `x`, `y`, `z`, `heading`, `time_of_death`, `is_rezzed`, `was_at_graveyard` FROM `character_corpses` WHERE `id` = '%u' LIMIT 1", player_corpse_id ); auto results = QueryDatabase(query); @@ -3889,7 +3889,7 @@ Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) { } bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) { - std::string query; + std::string query; if (!RuleB(Zone, EnableShadowrest)){ query = StringFormat("SELECT id, charid, charname, x, y, z, heading, time_of_death, is_rezzed, was_at_graveyard FROM character_corpses WHERE zone_id='%u' AND instance_id='%u'", zone_id, instance_id); } @@ -3905,7 +3905,7 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) { // std::cout << row[3] << std::endl; // std::cout << row[4] << std::endl; // std::cout << row[5] << std::endl; - // std::cout << row[6] << std::endl; + // std::cout << row[6] << std::endl; // std::cout << row[7] << std::endl; // std::cout << row[8] << std::endl; // std::cout << row[9] << std::endl; @@ -3914,7 +3914,7 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) { Corpse::LoadFromDBData( atoll(row[0]), // id uint32 in_dbid atoll(row[1]), // charid uint32 in_charid - row[2], // char_name + row[2], // char_name atof(row[3]), // x float in_x atof(row[4]), // y float in_y atof(row[5]), // z float in_z @@ -3929,7 +3929,7 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) { } uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) { - std::string query = StringFormat("SELECT `id` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 0 ORDER BY `time_of_death` LIMIT 1", char_id); + std::string query = StringFormat("SELECT `id` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 0 ORDER BY `time_of_death` LIMIT 1", char_id); auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { return atoi(row[0]); @@ -3940,10 +3940,10 @@ uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) { bool ZoneDatabase::ClearCorpseItems(uint32 db_id){ std::string query = StringFormat("DELETE FROM `character_corpse_items` WHERE `corpse_id` = %u", db_id); auto results = QueryDatabase(query); - if (results.Success() && results.RowsAffected() != 0){ + if (results.Success() && results.RowsAffected() != 0){ return true; } - return false; + return false; } bool ZoneDatabase::DeleteItemOffCharacterCorpse(uint32 db_id, uint32 equip_slot, uint32 item_id){ @@ -3978,7 +3978,7 @@ bool ZoneDatabase::BuryAllCharacterCorpses(uint32 char_id) { bool ZoneDatabase::DeleteCharacterCorpse(uint32 db_id) { std::string query = StringFormat("DELETE FROM `character_corpses` WHERE `id` = %d", db_id); auto results = QueryDatabase(query); - if (results.Success() && results.RowsAffected() != 0){ + if (results.Success() && results.RowsAffected() != 0){ return true; } return false; diff --git a/zone/zonedb.h b/zone/zonedb.h index 33554aac3..2dc240817 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -5,6 +5,7 @@ #include "../common/eq_packet_structs.h" #include "../common/loottable.h" #include "zonedump.h" +#include "position.h" #include "../common/faction.h" #include @@ -226,7 +227,7 @@ public: /* Traders */ void SaveTraderItem(uint32 char_id,uint32 itemid,uint32 uniqueid, int32 charges,uint32 itemcost,uint8 slot); void UpdateTraderItemCharges(int char_id, uint32 ItemInstID, int32 charges); - void UpdateTraderItemPrice(int CharID, uint32 ItemID, uint32 Charges, uint32 NewPrice); + void UpdateTraderItemPrice(int CharID, uint32 ItemID, uint32 Charges, uint32 NewPrice); void DeleteTraderItem(uint32 char_id); void DeleteTraderItem(uint32 char_id,uint16 slot_id); @@ -302,14 +303,14 @@ public: Corpse* LoadCharacterCorpse(uint32 player_corpse_id); Corpse* SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); void MarkCorpseAsRezzed(uint32 dbid); - bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes); + bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes); bool BuryCharacterCorpse(uint32 dbid); bool BuryAllCharacterCorpses(uint32 charid); - bool DeleteCharacterCorpse(uint32 dbid); + bool DeleteCharacterCorpse(uint32 dbid); bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); - bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); + bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, float new_x, float new_y, float new_z, float new_heading); - bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID); + bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID); bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id); uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id); uint32 GetCharacterBuriedCorpseCount(uint32 char_id); @@ -378,7 +379,7 @@ public: int GetHighestWaypoint(uint32 zoneid, uint32 gridid); /* NPCs */ - + uint32 NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn = 0, uint32 extra = 0); // 0 = Create 1 = Add; 2 = Update; 3 = Remove; 4 = Delete uint32 CreateNewNPCCommand(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 extra); uint32 AddNewNPCSpawnGroupCommand(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 respawnTime); @@ -445,7 +446,7 @@ public: int32 GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 version); int32 GetDoorsCountPlusOne(const char *zone_name, int16 version); int32 GetDoorsDBCountPlusOne(const char *zone_name, int16 version); - void InsertDoor(uint32 did, uint16 ddoorid, const char* ddoor_name, float dxpos, float dypos, float dzpos, float dheading, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize); + void InsertDoor(uint32 did, uint16 ddoorid, const char* ddoor_name, const xyz_heading& position, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize); /* Blocked Spells */ int32 GetBlockedSpellsCount(uint32 zoneid); From 2fe80d32f961b4b1f7e181ff5ae4e95c0fd225bb Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 13:05:40 -0800 Subject: [PATCH 063/253] ZoneSpellsBlocked converted x,y, and z to m_Location as xyz_location --- zone/zone.cpp | 12 ++++++------ zone/zonedb.cpp | 4 +--- zone/zonedb.h | 4 +--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index eaf73f1da..946f432f9 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1919,9 +1919,9 @@ bool Zone::IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz) } case 2: { - if ((( nx >= (blocked_spells[x].x-blocked_spells[x].xdiff)) && (nx <= (blocked_spells[x].x+blocked_spells[x].xdiff))) && - (( ny >= (blocked_spells[x].y-blocked_spells[x].ydiff)) && (ny <= (blocked_spells[x].y+blocked_spells[x].ydiff))) && - (( nz >= (blocked_spells[x].z-blocked_spells[x].zdiff)) && (nz <= (blocked_spells[x].z+blocked_spells[x].zdiff)))) + if ((( nx >= (blocked_spells[x].m_Location.m_X-blocked_spells[x].xdiff)) && (nx <= (blocked_spells[x].m_Location.m_X+blocked_spells[x].xdiff))) && + (( ny >= (blocked_spells[x].m_Location.m_Y-blocked_spells[x].ydiff)) && (ny <= (blocked_spells[x].m_Location.m_Y+blocked_spells[x].ydiff))) && + (( nz >= (blocked_spells[x].m_Location.m_Z-blocked_spells[x].zdiff)) && (nz <= (blocked_spells[x].m_Location.m_Z+blocked_spells[x].zdiff)))) { return true; } @@ -1957,9 +1957,9 @@ const char* Zone::GetSpellBlockedMessage(uint32 spell_id, float nx, float ny, fl } case 2: { - if((( nx > (blocked_spells[x].x-blocked_spells[x].xdiff)) && (nx < (blocked_spells[x].x+blocked_spells[x].xdiff))) && - (( ny > (blocked_spells[x].y-blocked_spells[x].ydiff)) && (ny < (blocked_spells[x].y+blocked_spells[x].ydiff))) && - (( nz > (blocked_spells[x].z-blocked_spells[x].zdiff)) && (nz < (blocked_spells[x].z+blocked_spells[x].zdiff)))) + if((( nx > (blocked_spells[x].m_Location.m_X-blocked_spells[x].xdiff)) && (nx < (blocked_spells[x].m_Location.m_X+blocked_spells[x].xdiff))) && + (( ny > (blocked_spells[x].m_Location.m_Y-blocked_spells[x].ydiff)) && (ny < (blocked_spells[x].m_Location.m_Y+blocked_spells[x].ydiff))) && + (( nz > (blocked_spells[x].m_Location.m_Z-blocked_spells[x].zdiff)) && (nz < (blocked_spells[x].m_Location.m_Z+blocked_spells[x].zdiff)))) { return blocked_spells[x].message; } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 3b9c69943..740b67a49 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -2666,9 +2666,7 @@ bool ZoneDatabase::LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked memset(&into[index], 0, sizeof(ZoneSpellsBlocked)); into[index].spellid = atoi(row[1]); into[index].type = atoi(row[2]); - into[index].x = atof(row[3]); - into[index].y = atof(row[4]); - into[index].z = atof(row[5]); + into[index].m_Location = xyz_location(atof(row[3]), atof(row[4]), atof(row[5])); into[index].xdiff = atof(row[6]); into[index].ydiff = atof(row[7]); into[index].zdiff = atof(row[8]); diff --git a/zone/zonedb.h b/zone/zonedb.h index 2dc240817..73192f8d2 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -116,9 +116,7 @@ struct PetInfo { struct ZoneSpellsBlocked { uint32 spellid; int8 type; - float x; - float y; - float z; + xyz_location m_Location; float xdiff; float ydiff; float zdiff; From 81d2e7d242de8d72fb4ebaae2f825d9c4b65acdd Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 13:32:19 -0800 Subject: [PATCH 064/253] xdiff, ydiff, and zdiff in ZoneSpellsBlocked converted to xyz_location m_Difference --- zone/zone.cpp | 12 ++++++------ zone/zonedb.cpp | 4 +--- zone/zonedb.h | 4 +--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 946f432f9..b343c335b 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1919,9 +1919,9 @@ bool Zone::IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz) } case 2: { - if ((( nx >= (blocked_spells[x].m_Location.m_X-blocked_spells[x].xdiff)) && (nx <= (blocked_spells[x].m_Location.m_X+blocked_spells[x].xdiff))) && - (( ny >= (blocked_spells[x].m_Location.m_Y-blocked_spells[x].ydiff)) && (ny <= (blocked_spells[x].m_Location.m_Y+blocked_spells[x].ydiff))) && - (( nz >= (blocked_spells[x].m_Location.m_Z-blocked_spells[x].zdiff)) && (nz <= (blocked_spells[x].m_Location.m_Z+blocked_spells[x].zdiff)))) + if ((( nx >= (blocked_spells[x].m_Location.m_X-blocked_spells[x].m_Difference.m_X)) && (nx <= (blocked_spells[x].m_Location.m_X+blocked_spells[x].m_Difference.m_X))) && + (( ny >= (blocked_spells[x].m_Location.m_Y-blocked_spells[x].m_Difference.m_Y)) && (ny <= (blocked_spells[x].m_Location.m_Y+blocked_spells[x].m_Difference.m_Y))) && + (( nz >= (blocked_spells[x].m_Location.m_Z-blocked_spells[x].m_Difference.m_Z)) && (nz <= (blocked_spells[x].m_Location.m_Z+blocked_spells[x].m_Difference.m_Z)))) { return true; } @@ -1957,9 +1957,9 @@ const char* Zone::GetSpellBlockedMessage(uint32 spell_id, float nx, float ny, fl } case 2: { - if((( nx > (blocked_spells[x].m_Location.m_X-blocked_spells[x].xdiff)) && (nx < (blocked_spells[x].m_Location.m_X+blocked_spells[x].xdiff))) && - (( ny > (blocked_spells[x].m_Location.m_Y-blocked_spells[x].ydiff)) && (ny < (blocked_spells[x].m_Location.m_Y+blocked_spells[x].ydiff))) && - (( nz > (blocked_spells[x].m_Location.m_Z-blocked_spells[x].zdiff)) && (nz < (blocked_spells[x].m_Location.m_Z+blocked_spells[x].zdiff)))) + if((( nx > (blocked_spells[x].m_Location.m_X-blocked_spells[x].m_Difference.m_X)) && (nx < (blocked_spells[x].m_Location.m_X+blocked_spells[x].m_Difference.m_X))) && + (( ny > (blocked_spells[x].m_Location.m_Y-blocked_spells[x].m_Difference.m_Y)) && (ny < (blocked_spells[x].m_Location.m_Y+blocked_spells[x].m_Difference.m_Y))) && + (( nz > (blocked_spells[x].m_Location.m_Z-blocked_spells[x].m_Difference.m_Z)) && (nz < (blocked_spells[x].m_Location.m_Z+blocked_spells[x].m_Difference.m_Z)))) { return blocked_spells[x].message; } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 740b67a49..7f49a1ca1 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -2667,9 +2667,7 @@ bool ZoneDatabase::LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked into[index].spellid = atoi(row[1]); into[index].type = atoi(row[2]); into[index].m_Location = xyz_location(atof(row[3]), atof(row[4]), atof(row[5])); - into[index].xdiff = atof(row[6]); - into[index].ydiff = atof(row[7]); - into[index].zdiff = atof(row[8]); + into[index].m_Difference = xyz_location(atof(row[6]), atof(row[7]), atof(row[8])); strn0cpy(into[index].message, row[9], 255); } diff --git a/zone/zonedb.h b/zone/zonedb.h index 73192f8d2..30b51760b 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -117,9 +117,7 @@ struct ZoneSpellsBlocked { uint32 spellid; int8 type; xyz_location m_Location; - float xdiff; - float ydiff; - float zdiff; + xyz_location m_Difference; char message[256]; }; From fb9d76f851e5bc7a05ad59be7e153c643c4cf784 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 14:16:53 -0800 Subject: [PATCH 065/253] GetSpellBlockedMessage converted to xyz_location --- zone/spells.cpp | 4 ++-- zone/zone.cpp | 8 ++++---- zone/zone.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/zone/spells.cpp b/zone/spells.cpp index 52bb094fa..da6e4f40c 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -522,7 +522,7 @@ bool Mob::DoCastingChecks() } if (zone->IsSpellBlocked(spell_id, GetX(), GetY(), GetZ())) { - const char *msg = zone->GetSpellBlockedMessage(spell_id, GetX(), GetY(), GetZ()); + const char *msg = zone->GetSpellBlockedMessage(spell_id, GetPosition()); if (msg) { Message(13, msg); return false; @@ -1894,7 +1894,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 if(IsClient() && !CastToClient()->GetGM()){ if(zone->IsSpellBlocked(spell_id, GetX(), GetY(), GetZ())){ - const char *msg = zone->GetSpellBlockedMessage(spell_id, GetX(), GetY(), GetZ()); + const char *msg = zone->GetSpellBlockedMessage(spell_id, GetPosition()); if(msg){ Message(13, msg); return false; diff --git a/zone/zone.cpp b/zone/zone.cpp index b343c335b..b61cb3968 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1939,7 +1939,7 @@ bool Zone::IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz) return false; } -const char* Zone::GetSpellBlockedMessage(uint32 spell_id, float nx, float ny, float nz) +const char* Zone::GetSpellBlockedMessage(uint32 spell_id, const xyz_location& location) { if(blocked_spells) { @@ -1957,9 +1957,9 @@ const char* Zone::GetSpellBlockedMessage(uint32 spell_id, float nx, float ny, fl } case 2: { - if((( nx > (blocked_spells[x].m_Location.m_X-blocked_spells[x].m_Difference.m_X)) && (nx < (blocked_spells[x].m_Location.m_X+blocked_spells[x].m_Difference.m_X))) && - (( ny > (blocked_spells[x].m_Location.m_Y-blocked_spells[x].m_Difference.m_Y)) && (ny < (blocked_spells[x].m_Location.m_Y+blocked_spells[x].m_Difference.m_Y))) && - (( nz > (blocked_spells[x].m_Location.m_Z-blocked_spells[x].m_Difference.m_Z)) && (nz < (blocked_spells[x].m_Location.m_Z+blocked_spells[x].m_Difference.m_Z)))) + if((( location.m_X > (blocked_spells[x].m_Location.m_X-blocked_spells[x].m_Difference.m_X)) && (location.m_X < (blocked_spells[x].m_Location.m_X+blocked_spells[x].m_Difference.m_X))) && + (( location.m_Y > (blocked_spells[x].m_Location.m_Y-blocked_spells[x].m_Difference.m_Y)) && (location.m_Y < (blocked_spells[x].m_Location.m_Y+blocked_spells[x].m_Difference.m_Y))) && + (( location.m_Z > (blocked_spells[x].m_Location.m_Z-blocked_spells[x].m_Difference.m_Z)) && (location.m_Z < (blocked_spells[x].m_Location.m_Z+blocked_spells[x].m_Difference.m_Z)))) { return blocked_spells[x].message; } diff --git a/zone/zone.h b/zone/zone.h index 0fa390512..48557ccad 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -246,7 +246,7 @@ public: void LoadBlockedSpells(uint32 zoneid); void ClearBlockedSpells(); bool IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz); - const char *GetSpellBlockedMessage(uint32 spell_id, float nx, float ny, float nz); + const char *GetSpellBlockedMessage(uint32 spell_id, const xyz_location& location); int GetTotalBlockedSpells() { return totalBS; } inline bool HasMap() { return zonemap != nullptr; } inline bool HasWaterMap() { return watermap != nullptr; } @@ -324,7 +324,7 @@ private: Timer* Instance_Warning_timer; LinkedList client_auth_list; QGlobalCache *qGlobals; - + Timer hotzone_timer; }; From feac1728dc69bd6ba44eded3e40a46b7b9db5291 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 15:25:37 -0800 Subject: [PATCH 066/253] Added two axis aligned bounding box check functions --- zone/position.cpp | 32 ++++++++++++++++++++++++++++++++ zone/position.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/zone/position.cpp b/zone/position.cpp index 90b85726d..6f9a31d29 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -95,6 +95,10 @@ const xyz_location xyz_location::operator -(const xyz_location& rhs) const { return xyz_location(m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z); } +const xyz_location xyz_location::operator +(const xyz_location& rhs) const { + return xyz_location(m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z + rhs.m_Z); +} + void xyz_location::ABS_XYZ(void) { m_X = abs(m_X); m_Y = abs(m_Y); @@ -113,3 +117,31 @@ std::string to_string(const xy_location &position){ return StringFormat("(%.3f, %.3f)", position.m_X,position.m_Y); } +/** +* Determines if 'position' is within (inclusive) the axis aligned +* box (3 dimensional) formed from the points minimum and maximum. +*/ +bool IsWithinAxisAlignedBox(const xyz_location &position, const xyz_location &minimum, const xyz_location &maximum) { + auto actualMinimum = xyz_location(std::min(minimum.m_X, maximum.m_X), std::min(minimum.m_Y, maximum.m_Y),std::min(minimum.m_Z, maximum.m_Z)); + auto actualMaximum = xyz_location(std::max(minimum.m_X, maximum.m_X), std::max(minimum.m_Y, maximum.m_Y),std::max(minimum.m_Z, maximum.m_Z)); + + bool xcheck = position.m_X >= actualMinimum.m_X && position.m_X <= actualMaximum.m_X; + bool ycheck = position.m_Y >= actualMinimum.m_Y && position.m_Y <= actualMaximum.m_Y; + bool zcheck = position.m_Z >= actualMinimum.m_Z && position.m_Z <= actualMaximum.m_Z; + + return xcheck && ycheck && zcheck; +} + +/** +* Determines if 'position' is within (inclusive) the axis aligned +* box (2 dimensional) formed from the points minimum and maximum. +*/ +bool IsWithinAxisAlignedBox(const xy_location &position, const xy_location &minimum, const xy_location &maximum) { + auto actualMinimum = xy_location(std::min(minimum.m_X, maximum.m_X), std::min(minimum.m_Y, maximum.m_Y)); + auto actualMaximum = xy_location(std::max(minimum.m_X, maximum.m_X), std::max(minimum.m_Y, maximum.m_Y)); + + bool xcheck = position.m_X >= actualMinimum.m_X && position.m_X <= actualMaximum.m_X; + bool ycheck = position.m_Y >= actualMinimum.m_Y && position.m_Y <= actualMaximum.m_Y; + + return xcheck && ycheck; +} diff --git a/zone/position.h b/zone/position.h index 653cd4ba6..77c09603e 100644 --- a/zone/position.h +++ b/zone/position.h @@ -44,6 +44,7 @@ public: operator xy_location() const; const xyz_location operator -(const xyz_location& rhs) const; + const xyz_location operator +(const xyz_location& rhs) const; void ABS_XYZ(); bool isOrigin() const { return m_X == 0 && m_Y == 0 && m_Z == 0;} @@ -82,4 +83,7 @@ std::string to_string(const xyz_heading &position); std::string to_string(const xyz_location &position); std::string to_string(const xy_location &position); +bool IsWithinAxisAlignedBox(const xyz_location &position, const xyz_location &minimum, const xyz_location &maximum); +bool IsWithinAxisAlignedBox(const xy_location &position, const xy_location &minimum, const xy_location &maximum); + #endif From b06647b7638ad51897145e23fab15c6c4a82636d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 15:48:59 -0800 Subject: [PATCH 067/253] Zone::GetSpellBlockedMessage convered to use IsWithinAxisAlignedBox --- zone/zone.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index b61cb3968..8ed12673e 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1957,12 +1957,8 @@ const char* Zone::GetSpellBlockedMessage(uint32 spell_id, const xyz_location& lo } case 2: { - if((( location.m_X > (blocked_spells[x].m_Location.m_X-blocked_spells[x].m_Difference.m_X)) && (location.m_X < (blocked_spells[x].m_Location.m_X+blocked_spells[x].m_Difference.m_X))) && - (( location.m_Y > (blocked_spells[x].m_Location.m_Y-blocked_spells[x].m_Difference.m_Y)) && (location.m_Y < (blocked_spells[x].m_Location.m_Y+blocked_spells[x].m_Difference.m_Y))) && - (( location.m_Z > (blocked_spells[x].m_Location.m_Z-blocked_spells[x].m_Difference.m_Z)) && (location.m_Z < (blocked_spells[x].m_Location.m_Z+blocked_spells[x].m_Difference.m_Z)))) - { + if(!IsWithinAxisAlignedBox(location, blocked_spells[x].m_Location - blocked_spells[x].m_Difference, blocked_spells[x].m_Location + blocked_spells[x].m_Difference)) return blocked_spells[x].message; - } break; } default: From f5a94ed07b1f2b5f0bb8a7a2a3fa6ea46b67055c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 16:00:48 -0800 Subject: [PATCH 068/253] IsSpellBlocked converted to use xyz_location --- zone/bot.cpp | 2 +- zone/spells.cpp | 4 ++-- zone/zone.cpp | 8 ++------ zone/zone.h | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 76363ab7c..8d84899f3 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -9128,7 +9128,7 @@ void Bot::DoBuffTic(uint16 spell_id, int slot, uint32 ticsremaining, uint8 caste bool Bot::CastSpell(uint16 spell_id, uint16 target_id, uint16 slot, int32 cast_time, int32 mana_cost, uint32* oSpellWillFinish, uint32 item_slot, int16 *resist_adjust) { bool Result = false; - if(zone && !zone->IsSpellBlocked(spell_id, GetX(), GetY(), GetZ())) { + if(zone && !zone->IsSpellBlocked(spell_id, GetPosition())) { mlog(SPELLS__CASTING, "CastSpell called for spell %s (%d) on entity %d, slot %d, time %d, mana %d, from item slot %d", spells[spell_id].name, spell_id, target_id, slot, cast_time, mana_cost, (item_slot==0xFFFFFFFF)?999:item_slot); diff --git a/zone/spells.cpp b/zone/spells.cpp index da6e4f40c..223a584f3 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -521,7 +521,7 @@ bool Mob::DoCastingChecks() return false; } - if (zone->IsSpellBlocked(spell_id, GetX(), GetY(), GetZ())) { + if (zone->IsSpellBlocked(spell_id, GetPosition())) { const char *msg = zone->GetSpellBlockedMessage(spell_id, GetPosition()); if (msg) { Message(13, msg); @@ -1893,7 +1893,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 if(IsClient() && !CastToClient()->GetGM()){ - if(zone->IsSpellBlocked(spell_id, GetX(), GetY(), GetZ())){ + if(zone->IsSpellBlocked(spell_id, GetPosition())){ const char *msg = zone->GetSpellBlockedMessage(spell_id, GetPosition()); if(msg){ Message(13, msg); diff --git a/zone/zone.cpp b/zone/zone.cpp index 8ed12673e..292d4fc79 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1869,7 +1869,7 @@ void Zone::ClearBlockedSpells() } } -bool Zone::IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz) +bool Zone::IsSpellBlocked(uint32 spell_id, const xyz_location& location) { if (blocked_spells) { @@ -1919,12 +1919,8 @@ bool Zone::IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz) } case 2: { - if ((( nx >= (blocked_spells[x].m_Location.m_X-blocked_spells[x].m_Difference.m_X)) && (nx <= (blocked_spells[x].m_Location.m_X+blocked_spells[x].m_Difference.m_X))) && - (( ny >= (blocked_spells[x].m_Location.m_Y-blocked_spells[x].m_Difference.m_Y)) && (ny <= (blocked_spells[x].m_Location.m_Y+blocked_spells[x].m_Difference.m_Y))) && - (( nz >= (blocked_spells[x].m_Location.m_Z-blocked_spells[x].m_Difference.m_Z)) && (nz <= (blocked_spells[x].m_Location.m_Z+blocked_spells[x].m_Difference.m_Z)))) - { + if (!IsWithinAxisAlignedBox(location, blocked_spells[x].m_Location - blocked_spells[x].m_Difference, blocked_spells[x].m_Location + blocked_spells[x].m_Difference)) return true; - } break; } default: diff --git a/zone/zone.h b/zone/zone.h index 48557ccad..e0a89ac50 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -245,7 +245,7 @@ public: void LoadBlockedSpells(uint32 zoneid); void ClearBlockedSpells(); - bool IsSpellBlocked(uint32 spell_id, float nx, float ny, float nz); + bool IsSpellBlocked(uint32 spell_id, const xyz_location& location); const char *GetSpellBlockedMessage(uint32 spell_id, const xyz_location& location); int GetTotalBlockedSpells() { return totalBS; } inline bool HasMap() { return zonemap != nullptr; } From 40ec1f805f1754662f49d2f744d91925b8773e8d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 22:35:46 -0800 Subject: [PATCH 069/253] psafe_x, psafe_y, and psafe_z replaced with xyz_location m_SafePoint --- zone/zone.cpp | 8 +++----- zone/zone.h | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 292d4fc79..73ea2c643 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -750,7 +750,8 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) clientauth_timer(AUTHENTICATION_TIMEOUT * 1000), spawn2_timer(1000), qglobal_purge_timer(30000), - hotzone_timer(120000) + hotzone_timer(120000), + m_SafePoint(0.0f,0.0f,0.0f) { zoneid = in_zoneid; instanceid = in_instanceid; @@ -777,9 +778,6 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) long_name = 0; aggroedmobs =0; - psafe_x = 0; - psafe_y = 0; - psafe_z = 0; pgraveyard_id = 0; pgraveyard_zoneid = 0; pgraveyard_x = 0; @@ -791,7 +789,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) pvpzone = false; if(database.GetServerType() == 1) pvpzone = true; - database.GetZoneLongName(short_name, &long_name, file_name, &psafe_x, &psafe_y, &psafe_z, &pgraveyard_id, &pMaxClients); + database.GetZoneLongName(short_name, &long_name, file_name, &m_SafePoint.m_X, &m_SafePoint.m_Y, &m_SafePoint.m_Z, &pgraveyard_id, &pMaxClients); if(graveyard_id() > 0) { LogFile->write(EQEMuLog::Debug, "Graveyard ID is %i.", graveyard_id()); diff --git a/zone/zone.h b/zone/zone.h index e0a89ac50..7553a855d 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -109,9 +109,9 @@ public: inline Timer* GetInstanceTimer() { return Instance_Timer; } - inline const float& safe_x() { return psafe_x; } - inline const float& safe_y() { return psafe_y; } - inline const float& safe_z() { return psafe_z; } + inline const float& safe_x() { return m_SafePoint.m_X; } + inline const float& safe_y() { return m_SafePoint.m_Y; } + inline const float& safe_z() { return m_SafePoint.m_Z; } inline const uint32& graveyard_zoneid() { return pgraveyard_zoneid; } inline const float& graveyard_x() { return pgraveyard_x; } inline const float& graveyard_y() { return pgraveyard_y; } @@ -281,7 +281,7 @@ private: char* long_name; char* map_name; bool pvpzone; - float psafe_x, psafe_y, psafe_z; + xyz_location m_SafePoint; uint32 pMaxClients; bool can_bind; bool is_city; From c3333a46c99ad7090c95809fbfb18716e0158ed2 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 23:12:19 -0800 Subject: [PATCH 070/253] pgraveyard_x, pgraveyard_y, pgraveyard_z, and pgraveyard_heading converted to xyz_heading as m_Graveyard --- zone/zone.cpp | 15 ++++----------- zone/zone.h | 10 +++++----- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 73ea2c643..1c26b9785 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -751,7 +751,8 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) spawn2_timer(1000), qglobal_purge_timer(30000), hotzone_timer(120000), - m_SafePoint(0.0f,0.0f,0.0f) + m_SafePoint(0.0f,0.0f,0.0f), + m_Graveyard(0.0f,0.0f,0.0f,0.0f) { zoneid = in_zoneid; instanceid = in_instanceid; @@ -777,13 +778,8 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) memset(file_name, 0, sizeof(file_name)); long_name = 0; aggroedmobs =0; - pgraveyard_id = 0; pgraveyard_zoneid = 0; - pgraveyard_x = 0; - pgraveyard_y = 0; - pgraveyard_z = 0; - pgraveyard_heading = 0; pMaxClients = 0; pQueuedMerchantsWorkID = 0; pvpzone = false; @@ -793,7 +789,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) if(graveyard_id() > 0) { LogFile->write(EQEMuLog::Debug, "Graveyard ID is %i.", graveyard_id()); - bool GraveYardLoaded = database.GetZoneGraveyard(graveyard_id(), &pgraveyard_zoneid, &pgraveyard_x, &pgraveyard_y, &pgraveyard_z, &pgraveyard_heading); + bool GraveYardLoaded = database.GetZoneGraveyard(graveyard_id(), &pgraveyard_zoneid, &m_Graveyard.m_X, &m_Graveyard.m_Y, &m_Graveyard.m_Z, &m_Graveyard.m_Heading); if(GraveYardLoaded) LogFile->write(EQEMuLog::Debug, "Loaded a graveyard for zone %s: graveyard zoneid is %u x is %f y is %f z is %f heading is %f.", short_name, graveyard_zoneid(), graveyard_x(), graveyard_y(), graveyard_z(), graveyard_heading()); else @@ -1837,10 +1833,7 @@ bool Zone::HasGraveyard() { void Zone::SetGraveyard(uint32 zoneid, uint32 x, uint32 y, uint32 z, uint32 heading) { pgraveyard_zoneid = zoneid; - pgraveyard_x = x; - pgraveyard_y = y; - pgraveyard_z = z; - pgraveyard_heading = heading; + m_Graveyard = xyz_heading(x, y, z, heading); } void Zone::LoadBlockedSpells(uint32 zoneid) diff --git a/zone/zone.h b/zone/zone.h index 7553a855d..b790fad5d 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -113,10 +113,10 @@ public: inline const float& safe_y() { return m_SafePoint.m_Y; } inline const float& safe_z() { return m_SafePoint.m_Z; } inline const uint32& graveyard_zoneid() { return pgraveyard_zoneid; } - inline const float& graveyard_x() { return pgraveyard_x; } - inline const float& graveyard_y() { return pgraveyard_y; } - inline const float& graveyard_z() { return pgraveyard_z; } - inline const float& graveyard_heading() { return pgraveyard_heading; } + inline const float& graveyard_x() { return m_Graveyard.m_X; } + inline const float& graveyard_y() { return m_Graveyard.m_Y; } + inline const float& graveyard_z() { return m_Graveyard.m_Z; } + inline const float& graveyard_heading() { return m_Graveyard.m_Heading; } inline const uint32& graveyard_id() { return pgraveyard_id; } inline const uint32& GetMaxClients() { return pMaxClients; } @@ -292,7 +292,7 @@ private: uint8 zone_type; bool allow_mercs; uint32 pgraveyard_id, pgraveyard_zoneid; - float pgraveyard_x, pgraveyard_y, pgraveyard_z, pgraveyard_heading; + xyz_heading m_Graveyard; int default_ruleset; int totalBS; From 14608c972aa401024764b51c4907473938079e2a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 1 Dec 2014 23:34:41 -0800 Subject: [PATCH 071/253] SetGraveyard to xyz_header --- zone/zone.cpp | 4 ++-- zone/zone.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 1c26b9785..cc333c5fa 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1831,9 +1831,9 @@ bool Zone::HasGraveyard() { return Result; } -void Zone::SetGraveyard(uint32 zoneid, uint32 x, uint32 y, uint32 z, uint32 heading) { +void Zone::SetGraveyard(uint32 zoneid, const xyz_heading& graveyardPosition) { pgraveyard_zoneid = zoneid; - m_Graveyard = xyz_heading(x, y, z, heading); + m_Graveyard = graveyardPosition; } void Zone::LoadBlockedSpells(uint32 zoneid) diff --git a/zone/zone.h b/zone/zone.h index b790fad5d..0701c26e2 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -241,7 +241,7 @@ public: uint8 lootvar; bool HasGraveyard(); - void SetGraveyard(uint32 zoneid, uint32 x, uint32 y, uint32 z, uint32 heading); + void SetGraveyard(uint32 zoneid, const xyz_heading& graveyardPosition); void LoadBlockedSpells(uint32 zoneid); void ClearBlockedSpells(); From 2995b20d62507955114444da28a428e3df7eb3c4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 10:29:35 -0800 Subject: [PATCH 072/253] SaveCharacterBindPoint converted to xyz_heading --- zone/client.cpp | 6 ++++-- zone/zonedb.cpp | 6 +++--- zone/zonedb.h | 2 +- zone/zoning.cpp | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index e2ec14178..1bc23b38f 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -534,8 +534,10 @@ bool Client::Save(uint8 iCommitNow) { database.SaveCharacterCurrency(CharacterID(), &m_pp); /* Save Current Bind Points */ - database.SaveCharacterBindPoint(CharacterID(), m_pp.binds[0].zoneId, m_pp.binds[0].instance_id, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0, 0); /* Regular bind */ - database.SaveCharacterBindPoint(CharacterID(), m_pp.binds[4].zoneId, m_pp.binds[4].instance_id, m_pp.binds[4].x, m_pp.binds[4].y, m_pp.binds[4].z, 0, 1); /* Home Bind */ + auto regularBindPosition = xyz_heading(m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0.0f); + auto homeBindPosition = xyz_heading(m_pp.binds[4].x, m_pp.binds[4].y, m_pp.binds[4].z, 0.0f); + database.SaveCharacterBindPoint(CharacterID(), m_pp.binds[0].zoneId, m_pp.binds[0].instance_id, regularBindPosition, 0); /* Regular bind */ + database.SaveCharacterBindPoint(CharacterID(), m_pp.binds[4].zoneId, m_pp.binds[4].instance_id, homeBindPosition, 1); /* Home Bind */ /* Save Character Buffs */ database.SaveBuffs(this); diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 7f49a1ca1..184ecdf92 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1224,15 +1224,15 @@ bool ZoneDatabase::SaveCharacterLanguage(uint32 character_id, uint32 lang_id, ui return true; } -bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading, uint8 is_home){ +bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, const xyz_heading& position, uint8 is_home){ if (zone_id <= 0) { return false; } /* Save Home Bind Point */ std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)" - " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, zone_id, instance_id, x, y, z, heading, is_home); - LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterBindPoint for character ID: %i zone_id: %u instance_id: %u x: %f y: %f z: %f heading: %f ishome: %u", character_id, zone_id, instance_id, x, y, z, heading, is_home); + " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, zone_id, instance_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading, is_home); + LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterBindPoint for character ID: %i zone_id: %u instance_id: %u position: %s ishome: %u", character_id, zone_id, instance_id, to_string(position).c_str(), is_home); auto results = QueryDatabase(query); if (!results.RowsAffected()) { LogFile->write(EQEMuLog::Debug, "ERROR Bind Home Save: %s. %s", results.ErrorMessage().c_str(), query.c_str()); diff --git a/zone/zonedb.h b/zone/zonedb.h index 30b51760b..b5af4484a 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -264,7 +264,7 @@ public: bool LoadCharacterLeadershipAA(uint32 character_id, PlayerProfile_Struct* pp); /* Character Data Saves */ - bool SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading, uint8 is_home); + bool SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, const xyz_heading& position, uint8 is_home); bool SaveCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp); bool SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp, ExtendedProfile_Struct* m_epp); bool SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 current_level); diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 49a5601aa..758bb48f9 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -720,7 +720,8 @@ void Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y m_pp.binds[0].y = new_y; m_pp.binds[0].z = new_z; } - database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[0].zoneId, m_pp.binds[0].instance_id, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0, 0); + auto regularBindPoint = xyz_heading(m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0.0f); + database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[0].zoneId, m_pp.binds[0].instance_id, regularBindPoint, 0); } void Client::GoToBind(uint8 bindnum) { From 7ce7af05f3f18041cb44dd596e37020caebb447d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 10:47:46 -0800 Subject: [PATCH 073/253] SetBindPoint converted to xyz_location --- zone/client.h | 2 +- zone/lua_client.cpp | 12 ++++++------ zone/perl_client.cpp | 14 +++++++------- zone/questmgr.cpp | 2 +- zone/zoning.cpp | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/zone/client.h b/zone/client.h index 004adfede..caec8513d 100644 --- a/zone/client.h +++ b/zone/client.h @@ -578,7 +578,7 @@ public: void GoToBind(uint8 bindnum = 0); void GoToSafeCoords(uint16 zone_id, uint16 instance_id); void Gate(); - void SetBindPoint(int to_zone = -1, int to_instance = 0, float new_x = 0.0f, float new_y = 0.0f, float new_z = 0.0f); + void SetBindPoint(int to_zone = -1, int to_instance = 0, const xyz_location& location = xyz_location::Origin()); void SetStartZone(uint32 zoneid, float x = 0.0f, float y =0.0f, float z = 0.0f); uint32 GetStartZone(void); void MovePC(const char* zonename, float x, float y, float z, float heading, uint8 ignorerestrictions = 0, ZoneMode zm = ZoneSolicited); diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index 22e38b21d..ac7fe6eec 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -242,17 +242,17 @@ void Lua_Client::SetBindPoint(int to_zone, int to_instance) { void Lua_Client::SetBindPoint(int to_zone, int to_instance, float new_x) { Lua_Safe_Call_Void(); - self->SetBindPoint(to_zone, to_instance, new_x); + self->SetBindPoint(to_zone, to_instance, xyz_location(new_x,0.0f,0.0f)); } void Lua_Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y) { Lua_Safe_Call_Void(); - self->SetBindPoint(to_zone, to_instance, new_x, new_y); + self->SetBindPoint(to_zone, to_instance, xyz_location(new_x, new_y, 0.0f)); } void Lua_Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y, float new_z) { Lua_Safe_Call_Void(); - self->SetBindPoint(to_zone, to_instance, new_x, new_y, new_z); + self->SetBindPoint(to_zone, to_instance, xyz_location(new_x, new_y, new_z)); } float Lua_Client::GetBindX() { @@ -700,13 +700,13 @@ void Lua_Client::SummonItem(uint32 item_id, int charges, uint32 aug1, uint32 aug self->SummonItem(item_id, charges, aug1, aug2, aug3, aug4, aug5); } -void Lua_Client::SummonItem(uint32 item_id, int charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, +void Lua_Client::SummonItem(uint32 item_id, int charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, bool attuned) { Lua_Safe_Call_Void(); self->SummonItem(item_id, charges, aug1, aug2, aug3, aug4, aug5, attuned); } -void Lua_Client::SummonItem(uint32 item_id, int charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, +void Lua_Client::SummonItem(uint32 item_id, int charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, bool attuned, int to_slot) { Lua_Safe_Call_Void(); self->SummonItem(item_id, charges, aug1, aug2, aug3, aug4, aug5, attuned, to_slot); @@ -1396,7 +1396,7 @@ luabind::scope lua_register_client() { .def("SummonItem", (void(Lua_Client::*)(uint32,int,uint32,uint32,uint32,uint32))&Lua_Client::SummonItem) .def("SummonItem", (void(Lua_Client::*)(uint32,int,uint32,uint32,uint32,uint32,uint32))&Lua_Client::SummonItem) .def("SummonItem", (void(Lua_Client::*)(uint32,int,uint32,uint32,uint32,uint32,uint32,bool))&Lua_Client::SummonItem) - .def("SummonItem", (void(Lua_Client::*)(uint32,int,uint32,uint32,uint32,uint32,uint32,bool,int))&Lua_Client::SummonItem) + .def("SummonItem", (void(Lua_Client::*)(uint32,int,uint32,uint32,uint32,uint32,uint32,bool,int))&Lua_Client::SummonItem) .def("SetStats", (void(Lua_Client::*)(int,int))&Lua_Client::SetStats) .def("IncStats", (void(Lua_Client::*)(int,int))&Lua_Client::IncStats) .def("DropItem", (void(Lua_Client::*)(int))&Lua_Client::DropItem) diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 2a0c055af..ed0371924 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -1072,7 +1072,7 @@ XS(XS_Client_SetBindPoint) new_z = (float)SvNV(ST(5)); } - THIS->SetBindPoint(to_zone, to_instance, new_x, new_y, new_z); + THIS->SetBindPoint(to_zone, to_instance, xyz_location(new_x, new_y, new_z)); } XSRETURN_EMPTY; } @@ -1277,7 +1277,7 @@ XS(XS_Client_MovePC) #ifdef BOTS else if (THIS->IsBot()) _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process a type Bot reference"); - #endif + #endif else _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process an Unknown type reference"); @@ -1327,7 +1327,7 @@ XS(XS_Client_MovePCInstance) else _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process an Unknown type reference"); - Perl_croak(aTHX_ "THIS is not of type Client"); + Perl_croak(aTHX_ "THIS is not of type Client"); Perl_croak(aTHX_ "THIS is not of type Client"); } @@ -5087,7 +5087,7 @@ XS(XS_Client_GetTaskActivityDoneCount) Perl_croak(aTHX_ "Usage: Client::GetTaskActivityDoneCount(THIS, TaskID, ActivityID)"); { Client * THIS; - int RETVAL; + int RETVAL; int TaskID = (int)SvIV(ST(1)); int ActivityID = (int)SvIV(ST(2)); dXSTARG; @@ -5101,7 +5101,7 @@ XS(XS_Client_GetTaskActivityDoneCount) if (THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - + RETVAL = THIS->GetTaskActivityDoneCountFromTaskID(TaskID, ActivityID); XSprePUSH; PUSHi((IV)RETVAL); } @@ -5945,7 +5945,7 @@ XS(XS_Client_SilentMessage) { Client * THIS; dXSTARG; - + if (sv_derived_from(ST(0), "Client")) { IV tmp = SvIV((SV*)SvRV(ST(0))); THIS = INT2PTR(Client *,tmp); @@ -6344,7 +6344,7 @@ XS(boot_Client) newXSproto(strcpy(buf, "SendMarqueeMessage"), XS_Client_SendMarqueeMessage, file, "$$$$$$$"); newXSproto(strcpy(buf, "SendColoredText"), XS_Client_SendColoredText, file, "$$$"); newXSproto(strcpy(buf, "SendSpellAnim"), XS_Client_SendSpellAnim, file, "$$$"); - + XSRETURN_YES; } diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index bd3c07cef..a1a6a419f 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1525,7 +1525,7 @@ void QuestManager::ding() { void QuestManager::rebind(int zoneid, float x, float y, float z) { QuestManagerCurrentQuestVars(); if(initiator && initiator->IsClient()) { - initiator->SetBindPoint(zoneid, x, y, z); + initiator->SetBindPoint(zoneid, 0, xyz_location(x, y, z)); } } diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 758bb48f9..266951f1b 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -705,7 +705,7 @@ void NPC::Gate() { Mob::Gate(); } -void Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y, float new_z) { +void Client::SetBindPoint(int to_zone, int to_instance, const xyz_location& location) { if (to_zone == -1) { m_pp.binds[0].zoneId = zone->GetZoneID(); m_pp.binds[0].instance_id = (zone->GetInstanceID() != 0 && zone->IsInstancePersistent()) ? zone->GetInstanceID() : 0; @@ -716,9 +716,9 @@ void Client::SetBindPoint(int to_zone, int to_instance, float new_x, float new_y else { m_pp.binds[0].zoneId = to_zone; m_pp.binds[0].instance_id = to_instance; - m_pp.binds[0].x = new_x; - m_pp.binds[0].y = new_y; - m_pp.binds[0].z = new_z; + m_pp.binds[0].x = location.m_X; + m_pp.binds[0].y = location.m_Y; + m_pp.binds[0].z = location.m_Z; } auto regularBindPoint = xyz_heading(m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0.0f); database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[0].zoneId, m_pp.binds[0].instance_id, regularBindPoint, 0); From 9d6a89c65db8ab3dccded9a750936f1184549d8e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 10:56:02 -0800 Subject: [PATCH 074/253] rebind converted to xyz_location --- zone/embparser_api.cpp | 6 ++---- zone/questmgr.cpp | 4 ++-- zone/questmgr.h | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 4faae7c8c..0e65240d4 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -1321,11 +1321,9 @@ XS(XS__rebind) Perl_croak(aTHX_ "Usage: rebind(zoneid, x, y, z)"); int zoneid = (int)SvIV(ST(0)); - float x = (float)SvNV(ST(1)); - float y = (float)SvNV(ST(2)); - float z = (float)SvNV(ST(3)); + auto location = xyz_location((float)SvNV(ST(1)),(float)SvNV(ST(2)),(float)SvNV(ST(3))); - quest_manager.rebind(zoneid, x, y, z); + quest_manager.rebind(zoneid, location); XSRETURN_EMPTY; } diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index a1a6a419f..425175e43 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1522,10 +1522,10 @@ void QuestManager::ding() { } -void QuestManager::rebind(int zoneid, float x, float y, float z) { +void QuestManager::rebind(int zoneid, const xyz_location& location) { QuestManagerCurrentQuestVars(); if(initiator && initiator->IsClient()) { - initiator->SetBindPoint(zoneid, 0, xyz_location(x, y, z)); + initiator->SetBindPoint(zoneid, 0, location); } } diff --git a/zone/questmgr.h b/zone/questmgr.h index 6e8c6f4b5..de824c8a2 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -131,7 +131,7 @@ public: void targlobal(const char *varname, const char *value, const char *duration, int npcid, int charid, int zoneid); void delglobal(const char *varname); void ding(); - void rebind(int zoneid, float x, float y, float z); + void rebind(int zoneid, const xyz_location& location); void start(int wp); void stop(); void pause(int duration); From 04e24ddce439f3ed550c724cc6faeaba62801501 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 11:20:10 -0800 Subject: [PATCH 075/253] moveto converted to xyz_heading --- zone/embparser_api.cpp | 2 +- zone/lua_general.cpp | 6 +++--- zone/questmgr.cpp | 3 +-- zone/questmgr.h | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 0e65240d4..3ec5801ef 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -1392,7 +1392,7 @@ XS(XS__moveto) else saveguard = false; - quest_manager.moveto(x, y, z, h, saveguard); + quest_manager.moveto(xyz_heading(x, y, z, h), saveguard); XSRETURN_EMPTY; } diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index efc6c48fe..9238278cc 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -421,15 +421,15 @@ void lua_pause(int duration) { } void lua_move_to(float x, float y, float z) { - quest_manager.moveto(x, y, z, 0, false); + quest_manager.moveto(xyz_heading(x, y, z, 0.0f), false); } void lua_move_to(float x, float y, float z, float h) { - quest_manager.moveto(x, y, z, h, false); + quest_manager.moveto(xyz_heading(x, y, z, h), false); } void lua_move_to(float x, float y, float z, float h, bool save_guard_spot) { - quest_manager.moveto(x, y, z, h, save_guard_spot); + quest_manager.moveto(xyz_heading(x, y, z, h), save_guard_spot); } void lua_path_resume() { diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 425175e43..e8da20496 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1553,12 +1553,11 @@ void QuestManager::pause(int duration) { owner->CastToNPC()->PauseWandering(duration); } -void QuestManager::moveto(float x, float y, float z, float h, bool saveguardspot) { +void QuestManager::moveto(const xyz_heading& position, bool saveguardspot) { QuestManagerCurrentQuestVars(); if (!owner || !owner->IsNPC()) return; - auto position = xyz_heading(x,y,z,h); owner->CastToNPC()->MoveTo(position, saveguardspot); } diff --git a/zone/questmgr.h b/zone/questmgr.h index de824c8a2..4a01a6e49 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -135,7 +135,7 @@ public: void start(int wp); void stop(); void pause(int duration); - void moveto(float x, float y, float z, float h, bool saveguardspot); + void moveto(const xyz_heading& position, bool saveguardspot); void resume(); void addldonpoints(int32 points, uint32 theme); void addldonwin(int32 wins, uint32 theme); From efc4ba0e27e89816c906001bd124a7649840d956 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 12:00:45 -0800 Subject: [PATCH 076/253] summonburriedplayercorpse converted to xyz_heading --- zone/embparser_api.cpp | 7 ++----- zone/lua_general.cpp | 2 +- zone/questmgr.cpp | 17 +++++++++-------- zone/questmgr.h | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 3ec5801ef..ba2e397b5 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -1747,12 +1747,9 @@ XS(XS__summonburriedplayercorpse) bool RETVAL; uint32 char_id = (int)SvIV(ST(0)); - float dest_x = (float)SvIV(ST(1)); - float dest_y = (float)SvIV(ST(2)); - float dest_z = (float)SvIV(ST(3)); - float dest_heading = (float)SvIV(ST(4)); + auto position = xyz_heading((float)SvIV(ST(1)), (float)SvIV(ST(2)), (float)SvIV(ST(3)),(float)SvIV(ST(4))); - RETVAL = quest_manager.summonburriedplayercorpse(char_id, dest_x, dest_y, dest_z, dest_heading); + RETVAL = quest_manager.summonburriedplayercorpse(char_id, position); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 9238278cc..7d619803a 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -485,7 +485,7 @@ void lua_toggle_spawn_event(int event_id, bool enable, bool strict, bool reset) } void lua_summon_burried_player_corpse(uint32 char_id, float x, float y, float z, float h) { - quest_manager.summonburriedplayercorpse(char_id, x, y, z, h); + quest_manager.summonburriedplayercorpse(char_id, xyz_heading(x, y, z, h)); } void lua_summon_all_player_corpses(uint32 char_id, float x, float y, float z, float h) { diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index e8da20496..d4e914204 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1734,16 +1734,17 @@ void QuestManager::sethp(int hpperc) { owner->Damage(owner, newhp, SPELL_UNKNOWN, SkillHandtoHand, false, 0, false); } -bool QuestManager::summonburriedplayercorpse(uint32 char_id, float dest_x, float dest_y, float dest_z, float dest_heading) { +bool QuestManager::summonburriedplayercorpse(uint32 char_id, const xyz_heading& position) { bool Result = false; - if(char_id > 0) { - Corpse* PlayerCorpse = database.SummonBuriedCharacterCorpses(char_id, zone->GetZoneID(), zone->GetInstanceID(), dest_x, dest_y, dest_z, dest_heading); - if(PlayerCorpse) { - Result = true; - } - } - return Result; + if(char_id <= 0) + return false; + + Corpse* PlayerCorpse = database.SummonBuriedCharacterCorpses(char_id, zone->GetZoneID(), zone->GetInstanceID(), position.m_X, position.m_Y, position.m_Z, position.m_Heading); + if(!PlayerCorpse) + return false; + + return true; } bool QuestManager::summonallplayercorpses(uint32 char_id, float dest_x, float dest_y, float dest_z, float dest_heading) { diff --git a/zone/questmgr.h b/zone/questmgr.h index 4a01a6e49..c6c28111e 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -156,7 +156,7 @@ public: void set_zone_flag(int zone_id); void clear_zone_flag(int zone_id); void sethp(int hpperc); - bool summonburriedplayercorpse(uint32 char_id, float dest_x, float dest_y, float dest_z, float dest_heading); + bool summonburriedplayercorpse(uint32 char_id, const xyz_heading& position); bool summonallplayercorpses(uint32 char_id, float dest_x, float dest_y, float dest_z, float dest_heading); uint32 getplayerburriedcorpsecount(uint32 char_id); bool buryplayercorpse(uint32 char_id); From dd5265dc02b564ed583f0400ee406e7a2b0d4f89 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 12:04:21 -0800 Subject: [PATCH 077/253] SummonBuriedCharacterCorpses converted to xyz_heading --- zone/command.cpp | 2 +- zone/questmgr.cpp | 2 +- zone/zonedb.cpp | 40 +++++++++++++++++++++------------------- zone/zonedb.h | 2 +- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index d74fedabe..030ce7de5 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -8522,7 +8522,7 @@ void command_summonburriedplayercorpse(Client *c, const Seperator *sep) return; } - Corpse* PlayerCorpse = database.SummonBuriedCharacterCorpses(t->CharacterID(), t->GetZoneID(), zone->GetInstanceID(), t->GetX(), t->GetY(), t->GetZ(), t->GetHeading()); + Corpse* PlayerCorpse = database.SummonBuriedCharacterCorpses(t->CharacterID(), t->GetZoneID(), zone->GetInstanceID(), t->GetPosition()); if(!PlayerCorpse) c->Message(0, "Your target doesn't have any burried corpses."); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index d4e914204..8ec522537 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1740,7 +1740,7 @@ bool QuestManager::summonburriedplayercorpse(uint32 char_id, const xyz_heading& if(char_id <= 0) return false; - Corpse* PlayerCorpse = database.SummonBuriedCharacterCorpses(char_id, zone->GetZoneID(), zone->GetInstanceID(), position.m_X, position.m_Y, position.m_Z, position.m_Heading); + Corpse* PlayerCorpse = database.SummonBuriedCharacterCorpses(char_id, zone->GetZoneID(), zone->GetInstanceID(), position); if(!PlayerCorpse) return false; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 184ecdf92..762484411 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3771,37 +3771,39 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct return true; } -Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, float dest_x, float dest_y, float dest_z, float dest_heading) { - Corpse* NewCorpse = 0; - std::string query = StringFormat( - "SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 1 ORDER BY `time_of_death` LIMIT 1", - char_id - ); +Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, const xyz_heading& position) { + Corpse* corpse = nullptr; + std::string query = StringFormat("SELECT `id`, `charname`, `time_of_death`, `is_rezzed` " + "FROM `character_corpses` " + "WHERE `charid` = '%u' AND `is_buried` = 1 " + "ORDER BY `time_of_death` LIMIT 1", + char_id); auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { - NewCorpse = Corpse::LoadFromDBData( + corpse = Corpse::LoadFromDBData( atoll(row[0]), // uint32 in_dbid char_id, // uint32 in_charid row[1], // char* in_charname - dest_x, // float in_x - dest_y, // float in_y - dest_z, // float in_z - dest_heading, // float in_heading + position.m_X, // float in_x + position.m_Y, // float in_y + position.m_Z, // float in_z + position.m_Heading, // float in_heading row[2], // char* time_of_death atoi(row[3]) == 1, // bool rezzed false // bool was_at_graveyard ); - if (NewCorpse) { - entity_list.AddCorpse(NewCorpse); - NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); - NewCorpse->Spawn(); - if (!UnburyCharacterCorpse(NewCorpse->GetDBID(), dest_zone_id, dest_instance_id, dest_x, dest_y, dest_z, dest_heading)) - LogFile->write(EQEMuLog::Error, "Unable to unbury a summoned player corpse for character id %u.", char_id); - } + if (!corpse) + continue; + + entity_list.AddCorpse(corpse); + corpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); + corpse->Spawn(); + if (!UnburyCharacterCorpse(corpse->GetDBID(), dest_zone_id, dest_instance_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading)) + LogFile->write(EQEMuLog::Error, "Unable to unbury a summoned player corpse for character id %u.", char_id); } - return NewCorpse; + return corpse; } bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, float dest_x, float dest_y, float dest_z, float dest_heading) { diff --git a/zone/zonedb.h b/zone/zonedb.h index b5af4484a..ba9c6d924 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -297,7 +297,7 @@ public: uint32 GetCharacterCorpseItemCount(uint32 corpse_id); bool LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct* pcs); Corpse* LoadCharacterCorpse(uint32 player_corpse_id); - Corpse* SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); + Corpse* SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const xyz_heading& position); void MarkCorpseAsRezzed(uint32 dbid); bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes); bool BuryCharacterCorpse(uint32 dbid); From 7a74df5ff16296a312777206b260e0d0d5319f9b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 12:42:47 -0800 Subject: [PATCH 078/253] summonallplayercorpses converted to xyz_heading --- zone/embparser_api.cpp | 7 ++----- zone/lua_general.cpp | 2 +- zone/questmgr.cpp | 16 ++++++++-------- zone/questmgr.h | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index ba2e397b5..6df722934 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -1765,12 +1765,9 @@ XS(XS__summonallplayercorpses) bool RETVAL; uint32 char_id = (int)SvIV(ST(0)); - float dest_x = (float)SvIV(ST(1)); - float dest_y = (float)SvIV(ST(2)); - float dest_z = (float)SvIV(ST(3)); - float dest_heading = (float)SvIV(ST(4)); + auto position = xyz_heading((float)SvIV(ST(1)),(float)SvIV(ST(2)),(float)SvIV(ST(3)),(float)SvIV(ST(4))); - RETVAL = quest_manager.summonallplayercorpses(char_id, dest_x, dest_y, dest_z, dest_heading); + RETVAL = quest_manager.summonallplayercorpses(char_id, position); ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 7d619803a..28dbba206 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -489,7 +489,7 @@ void lua_summon_burried_player_corpse(uint32 char_id, float x, float y, float z, } void lua_summon_all_player_corpses(uint32 char_id, float x, float y, float z, float h) { - quest_manager.summonallplayercorpses(char_id, x, y, z, h); + quest_manager.summonallplayercorpses(char_id, xyz_heading(x, y, z, h)); } int lua_get_player_burried_corpse_count(uint32 char_id) { diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 8ec522537..25e43752e 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1747,15 +1747,15 @@ bool QuestManager::summonburriedplayercorpse(uint32 char_id, const xyz_heading& return true; } -bool QuestManager::summonallplayercorpses(uint32 char_id, float dest_x, float dest_y, float dest_z, float dest_heading) { - bool Result = false; +bool QuestManager::summonallplayercorpses(uint32 char_id, const xyz_heading& position) { - if(char_id > 0) { - Client* c = entity_list.GetClientByCharID(char_id); - c->SummonAllCorpses(dest_x, dest_y, dest_z, dest_heading); - Result = true; - } - return Result; + if(char_id <= 0) + return false; + + Client* c = entity_list.GetClientByCharID(char_id); + c->SummonAllCorpses(position.m_X, position.m_Y, position.m_Z, position.m_Heading); + + return true; } uint32 QuestManager::getplayerburriedcorpsecount(uint32 char_id) { diff --git a/zone/questmgr.h b/zone/questmgr.h index c6c28111e..d001beab4 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -157,7 +157,7 @@ public: void clear_zone_flag(int zone_id); void sethp(int hpperc); bool summonburriedplayercorpse(uint32 char_id, const xyz_heading& position); - bool summonallplayercorpses(uint32 char_id, float dest_x, float dest_y, float dest_z, float dest_heading); + bool summonallplayercorpses(uint32 char_id, const xyz_heading& position); uint32 getplayerburriedcorpsecount(uint32 char_id); bool buryplayercorpse(uint32 char_id); void forcedooropen(uint32 doorid, bool altmode); From 3791c38f97e03d3fa0c5281e42540dd0103c9fe1 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 12:52:40 -0800 Subject: [PATCH 079/253] SummonAllCharacterCorpses converted to xyz_heading --- zone/client.cpp | 5 ++--- zone/zonedb.cpp | 15 +++++++-------- zone/zonedb.h | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 1bc23b38f..02c35feaa 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -4927,8 +4927,7 @@ void Client::SummonAndRezzAllCorpses() entity_list.RemoveAllCorpsesByCharID(CharacterID()); - int CorpseCount = database.SummonAllCharacterCorpses(CharacterID(), zone->GetZoneID(), zone->GetInstanceID(), - GetX(), GetY(), GetZ(), GetHeading()); + int CorpseCount = database.SummonAllCharacterCorpses(CharacterID(), zone->GetZoneID(), zone->GetInstanceID(), GetPosition()); if(CorpseCount <= 0) { Message(clientMessageYellow, "You have no corpses to summnon."); @@ -4966,7 +4965,7 @@ void Client::SummonAllCorpses(float dest_x, float dest_y, float dest_z, float de entity_list.RemoveAllCorpsesByCharID(CharacterID()); int CorpseCount = database.SummonAllCharacterCorpses(CharacterID(), zone->GetZoneID(), zone->GetInstanceID(), - dest_x, dest_y, dest_z, dest_heading); + xyz_heading(dest_x, dest_y, dest_z, dest_heading)); if(CorpseCount <= 0) { return; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 762484411..7b8cb2d6d 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3806,21 +3806,20 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z return corpse; } -bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, float dest_x, float dest_y, float dest_z, float dest_heading) { +bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, const xyz_heading& position) { Corpse* NewCorpse = 0; int CorpseCount = 0; std::string query = StringFormat( "UPDATE character_corpses SET zone_id = %i, instance_id = %i, x = %f, y = %f, z = %f, heading = %f, is_buried = 0, was_at_graveyard = 0 WHERE charid = %i", - dest_zone_id, dest_instance_id, dest_x, dest_y, dest_z, dest_heading, char_id + dest_zone_id, dest_instance_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading, char_id ); auto results = QueryDatabase(query); query = StringFormat( "SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u'" "ORDER BY time_of_death", - char_id - ); + char_id); results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { @@ -3828,10 +3827,10 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id atoll(row[0]), char_id, row[1], - dest_x, - dest_y, - dest_z, - dest_heading, + position.m_X, + position.m_Y, + position.m_Z, + position.m_Heading, row[2], atoi(row[3]) == 1, false); diff --git a/zone/zonedb.h b/zone/zonedb.h index ba9c6d924..e66448a47 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -303,7 +303,7 @@ public: bool BuryCharacterCorpse(uint32 dbid); bool BuryAllCharacterCorpses(uint32 charid); bool DeleteCharacterCorpse(uint32 dbid); - bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); + bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const xyz_heading& position); bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, float new_x, float new_y, float new_z, float new_heading); bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID); From 0ad62461f0d4ebf6575e6914df6b5525ccaa0398 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 13:13:04 -0800 Subject: [PATCH 080/253] CorpseLoadFromDBData converted to xyz_heading --- zone/corpse.cpp | 10 +++++----- zone/corpse.h | 12 ++++++------ zone/zonedb.cpp | 33 ++++++--------------------------- 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 766c70345..8f8d6a4e1 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -63,7 +63,7 @@ void Corpse::SendLootReqErrorPacket(Client* client, uint8 response) { safe_delete(outapp); } -Corpse* Corpse::LoadFromDBData(uint32 in_dbid, uint32 in_charid, std::string in_charname, float in_x, float in_y, float in_z, float in_heading, std::string time_of_death, bool rezzed, bool was_at_graveyard) +Corpse* Corpse::LoadFromDBData(uint32 in_dbid, uint32 in_charid, std::string in_charname, const xyz_heading& position, std::string time_of_death, bool rezzed, bool was_at_graveyard) { uint32 item_count = database.GetCharacterCorpseItemCount(in_dbid); char *buffer = new char[sizeof(PlayerCorpse_Struct) + (item_count * sizeof(player_lootitem::ServerLootItem_Struct))]; @@ -90,10 +90,10 @@ Corpse* Corpse::LoadFromDBData(uint32 in_dbid, uint32 in_charid, std::string in_ pcs->silver, // uint32 in_silver pcs->gold, // uint32 in_gold pcs->plat, // uint32 in_plat - in_x, // float in_x - in_y, // float in_y - in_z, // float in_z - in_heading, // float in_heading + position.m_X, // float in_x + position.m_Y, // float in_y + position.m_Z, // float in_z + position.m_Heading, // float in_heading pcs->size, // float in_size pcs->gender, // uint8 in_gender pcs->race, // uint16 in_race diff --git a/zone/corpse.h b/zone/corpse.h index f365dd041..ba2dfbecc 100644 --- a/zone/corpse.h +++ b/zone/corpse.h @@ -30,18 +30,18 @@ class Corpse : public Mob { public: static void SendEndLootErrorPacket(Client* client); - static void SendLootReqErrorPacket(Client* client, uint8 response = 2); - + static void SendLootReqErrorPacket(Client* client, uint8 response = 2); + Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NPCType** in_npctypedata, uint32 in_decaytime = 600000); Corpse(Client* client, int32 in_rezexp); Corpse(uint32 in_corpseid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture, uint32 in_rezexp, bool wasAtGraveyard = false); ~Corpse(); - static Corpse* LoadFromDBData(uint32 in_dbid, uint32 in_charid, std::string in_charname, float in_x, float in_y, float in_z, float in_heading, std::string time_of_death, bool rezzed, bool was_at_graveyard); + static Corpse* LoadFromDBData(uint32 in_dbid, uint32 in_charid, std::string in_charname, const xyz_heading& position, std::string time_of_death, bool rezzed, bool was_at_graveyard); //abstract virtual function implementations requird by base abstract class virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, SkillUseTypes attack_skill) { return true; } virtual void Damage(Mob* from, int32 damage, uint16 spell_id, SkillUseTypes attack_skill, bool avoidable = true, int8 buffslot = -1, bool iBuffTic = false) { return; } - virtual bool Attack(Mob* other, int Hand = MainPrimary, bool FromRiposte = false, + virtual bool Attack(Mob* other, int Hand = MainPrimary, bool FromRiposte = false, bool IsStrikethrough = true, bool IsFromSpell = false, ExtraAttackOptions *opts = nullptr) { return false; } virtual bool HasRaid() { return false; } virtual bool HasGroup() { return false; } @@ -119,7 +119,7 @@ protected: std::list MoveItemToCorpse(Client *client, ItemInst *item, int16 equipslot); private: - bool is_player_corpse; + bool is_player_corpse; bool is_corpse_changed; bool is_locked; int32 player_kill_item; @@ -137,7 +137,7 @@ private: bool can_rez; bool become_npc; int allowed_looters[MAX_LOOTERS]; // People allowed to loot the corpse, character id - Timer corpse_decay_timer; + Timer corpse_decay_timer; Timer corpse_res_timer; Timer corpse_delay_timer; Timer corpse_graveyard_timer; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 7b8cb2d6d..239608473 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3785,10 +3785,7 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z atoll(row[0]), // uint32 in_dbid char_id, // uint32 in_charid row[1], // char* in_charname - position.m_X, // float in_x - position.m_Y, // float in_y - position.m_Z, // float in_z - position.m_Heading, // float in_heading + position, row[2], // char* time_of_death atoi(row[3]) == 1, // bool rezzed false // bool was_at_graveyard @@ -3827,10 +3824,7 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id atoll(row[0]), char_id, row[1], - position.m_X, - position.m_Y, - position.m_Z, - position.m_Heading, + position, row[2], atoi(row[3]) == 1, false); @@ -3868,14 +3862,12 @@ Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) { ); auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { + auto position = xyz_heading(atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6])); NewCorpse = Corpse::LoadFromDBData( atoll(row[0]), // id uint32 in_dbid atoll(row[1]), // charid uint32 in_charid row[2], // char_name - atof(row[3]), // x float in_x - atof(row[4]), // y float in_y - atof(row[5]), // z float in_z - atof(row[6]), // heading float in_heading + position, row[7], // time_of_death char* time_of_death atoi(row[8]) == 1, // is_rezzed bool rezzed atoi(row[9]) // was_at_graveyard bool was_at_graveyard @@ -3896,26 +3888,13 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) { auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { - // std::cout << row[0] << std::endl; - // std::cout << row[1] << std::endl; - // std::cout << row[2] << std::endl; - // std::cout << row[3] << std::endl; - // std::cout << row[4] << std::endl; - // std::cout << row[5] << std::endl; - // std::cout << row[6] << std::endl; - // std::cout << row[7] << std::endl; - // std::cout << row[8] << std::endl; - // std::cout << row[9] << std::endl; - + auto position = xyz_heading(atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6])); entity_list.AddCorpse( Corpse::LoadFromDBData( atoll(row[0]), // id uint32 in_dbid atoll(row[1]), // charid uint32 in_charid row[2], // char_name - atof(row[3]), // x float in_x - atof(row[4]), // y float in_y - atof(row[5]), // z float in_z - atof(row[6]), // heading float in_heading + position, row[7], // time_of_death char* time_of_death atoi(row[8]) == 1, // is_rezzed bool rezzed atoi(row[9])) From 2e0cfa86bfda6cd437c93b484b5c7c95c4d83034 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 13:26:55 -0800 Subject: [PATCH 081/253] QuestManager::spawn2 converted to xyz_heading --- zone/embparser_api.cpp | 13 ++++--------- zone/lua_general.cpp | 4 ++-- zone/questmgr.cpp | 4 ++-- zone/questmgr.h | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 6df722934..45086093c 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -218,11 +218,9 @@ XS(XS__spawn) int npc_type = (int)SvIV(ST(0)); int grid = (int)SvIV(ST(1)); int unused = (int)SvIV(ST(2)); - float x = (float)SvNV(ST(3)); - float y = (float)SvNV(ST(4)); - float z = (float)SvNV(ST(5)); + auto position = xyz_heading((float)SvNV(ST(3)), (float)SvNV(ST(4)), (float)SvNV(ST(5)), 0.0f); - Mob *r = quest_manager.spawn2(npc_type, grid, unused, x, y, z, 0); + Mob *r = quest_manager.spawn2(npc_type, grid, unused, position); RETVAL = (r != nullptr) ? r->GetID() : 0; XSprePUSH; PUSHu((UV)RETVAL); @@ -242,12 +240,9 @@ XS(XS__spawn2) int npc_type = (int)SvIV(ST(0)); int grid = (int)SvIV(ST(1)); int unused = (int)SvIV(ST(2)); - float x = (float)SvNV(ST(3)); - float y = (float)SvNV(ST(4)); - float z = (float)SvNV(ST(5)); - float heading = (float)SvNV(ST(6)); + auto position = xyz_heading((float)SvNV(ST(3)), (float)SvNV(ST(4)), (float)SvNV(ST(5)), (float)SvNV(ST(6))); - Mob *r = quest_manager.spawn2(npc_type, grid, unused, x, y, z, heading); + Mob *r = quest_manager.spawn2(npc_type, grid, unused, position); RETVAL = (r != nullptr) ? r->GetID() : 0; XSprePUSH; PUSHu((UV)RETVAL); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 28dbba206..915efe780 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -251,8 +251,8 @@ void unregister_spell_event(int evt, int spell_id) { } Lua_Mob lua_spawn2(int npc_type, int grid, int unused, double x, double y, double z, double heading) { - return Lua_Mob(quest_manager.spawn2(npc_type, grid, unused, - static_cast(x), static_cast(y), static_cast(z), static_cast(heading))); + auto position = xyz_heading(x, y, z, heading); + return Lua_Mob(quest_manager.spawn2(npc_type, grid, unused, position)); } Lua_Mob lua_unique_spawn(int npc_type, int grid, int unused, double x, double y, double z, double heading = 0.0) { diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 25e43752e..48c94f1cc 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -241,11 +241,11 @@ void QuestManager::write(const char *file, const char *str) { fclose (pFile); } -Mob* QuestManager::spawn2(int npc_type, int grid, int unused, float x, float y, float z, float heading) { +Mob* QuestManager::spawn2(int npc_type, int grid, int unused, const xyz_heading& position) { const NPCType* tmp = 0; if (tmp = database.GetNPCType(npc_type)) { - NPC* npc = new NPC(tmp, nullptr, xyz_heading(x, y, z, heading), FlyMode3); + NPC* npc = new NPC(tmp, nullptr, position, FlyMode3); npc->AddLootTable(); entity_list.AddNPC(npc,true,true); if(grid > 0) diff --git a/zone/questmgr.h b/zone/questmgr.h index d001beab4..072fceb31 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -56,7 +56,7 @@ public: void me(const char *str); void summonitem(uint32 itemid, int16 charges = -1); void write(const char *file, const char *str); - Mob* spawn2(int npc_type, int grid, int unused, float x, float y, float z, float heading); + Mob* spawn2(int npc_type, int grid, int unused, const xyz_heading& position); Mob* unique_spawn(int npc_type, int grid, int unused, float x, float y, float z, float heading = 0); Mob* spawn_from_spawn2(uint32 spawn2_id); void enable_spawn2(uint32 spawn2_id); From 4daf4ab50785ebee4e8af656359aa9536abed44d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 14:36:51 -0800 Subject: [PATCH 082/253] QuestManager::unique_spawn converted to xyz_heading --- zone/embparser_api.cpp | 3 ++- zone/lua_general.cpp | 4 ++-- zone/questmgr.cpp | 4 ++-- zone/questmgr.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 45086093c..034c9e80e 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -269,7 +269,8 @@ XS(XS__unique_spawn) if(items == 7) heading = (float)SvNV(ST(6)); - Mob *r = quest_manager.unique_spawn(npc_type, grid, unused, x, y, z, heading); + + Mob *r = quest_manager.unique_spawn(npc_type, grid, unused, xyz_heading(x, y, z, heading)); RETVAL = (r != nullptr) ? r->GetID() : 0; XSprePUSH; PUSHu((UV)RETVAL); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 915efe780..99e802c24 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -256,8 +256,8 @@ Lua_Mob lua_spawn2(int npc_type, int grid, int unused, double x, double y, doubl } Lua_Mob lua_unique_spawn(int npc_type, int grid, int unused, double x, double y, double z, double heading = 0.0) { - return Lua_Mob(quest_manager.unique_spawn(npc_type, grid, unused, - static_cast(x), static_cast(y), static_cast(z), static_cast(heading))); + auto position = xyz_heading(x,y,z,heading); + return Lua_Mob(quest_manager.unique_spawn(npc_type, grid, unused, position)); } Lua_Mob lua_spawn_from_spawn2(uint32 spawn2_id) { diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 48c94f1cc..3ced16e87 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -258,7 +258,7 @@ Mob* QuestManager::spawn2(int npc_type, int grid, int unused, const xyz_heading& return nullptr; } -Mob* QuestManager::unique_spawn(int npc_type, int grid, int unused, float x, float y, float z, float heading) { +Mob* QuestManager::unique_spawn(int npc_type, int grid, int unused, const xyz_heading& position) { Mob *other = entity_list.GetMobByNpcTypeID(npc_type); if(other != nullptr) { return other; @@ -267,7 +267,7 @@ Mob* QuestManager::unique_spawn(int npc_type, int grid, int unused, float x, flo const NPCType* tmp = 0; if (tmp = database.GetNPCType(npc_type)) { - NPC* npc = new NPC(tmp, nullptr, xyz_heading(x, y, z, heading), FlyMode3); + NPC* npc = new NPC(tmp, nullptr, position, FlyMode3); npc->AddLootTable(); entity_list.AddNPC(npc,true,true); if(grid > 0) diff --git a/zone/questmgr.h b/zone/questmgr.h index 072fceb31..a46b7adcd 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -57,7 +57,7 @@ public: void summonitem(uint32 itemid, int16 charges = -1); void write(const char *file, const char *str); Mob* spawn2(int npc_type, int grid, int unused, const xyz_heading& position); - Mob* unique_spawn(int npc_type, int grid, int unused, float x, float y, float z, float heading = 0); + Mob* unique_spawn(int npc_type, int grid, int unused, const xyz_heading& position); Mob* spawn_from_spawn2(uint32 spawn2_id); void enable_spawn2(uint32 spawn2_id); void disable_spawn2(uint32 spawn2_id); From f6c98132f08a08a5cdd71682e6dbcf0c6cfbe1c3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 14:50:48 -0800 Subject: [PATCH 083/253] SummonAllCorpses converted to xyz_heading --- zone/client.cpp | 17 +++++------------ zone/client.h | 2 +- zone/questmgr.cpp | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 02c35feaa..4bde10bc0 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -4942,13 +4942,11 @@ void Client::SummonAndRezzAllCorpses() Message(clientMessageYellow, "All your corpses have been summoned to your feet and have received a 100% resurrection."); } -void Client::SummonAllCorpses(float dest_x, float dest_y, float dest_z, float dest_heading) +void Client::SummonAllCorpses(const xyz_heading& position) { - - if(dest_x == 0 && dest_y == 0 && dest_z == 0 && dest_heading == 0) - { - dest_x = GetX(); dest_y = GetY(); dest_z = GetZ(); dest_heading = GetHeading(); - } + auto summonLocation = position; + if(position.m_X == 0.0f && position.m_Y == 0.0f && position.m_Z == 0.0f && position.m_Heading == 0.0f) + summonLocation = GetPosition(); ServerPacket *Pack = new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct)); @@ -4964,12 +4962,7 @@ void Client::SummonAllCorpses(float dest_x, float dest_y, float dest_z, float de entity_list.RemoveAllCorpsesByCharID(CharacterID()); - int CorpseCount = database.SummonAllCharacterCorpses(CharacterID(), zone->GetZoneID(), zone->GetInstanceID(), - xyz_heading(dest_x, dest_y, dest_z, dest_heading)); - if(CorpseCount <= 0) - { - return; - } + database.SummonAllCharacterCorpses(CharacterID(), zone->GetZoneID(), zone->GetInstanceID(), summonLocation); } void Client::DepopAllCorpses() diff --git a/zone/client.h b/zone/client.h index caec8513d..b39777046 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1026,7 +1026,7 @@ void SetConsumption(int32 in_hunger, int32 in_thirst); void DoItemEnterZone(); bool DoItemEnterZone(uint32 slot_x, uint32 slot_y); // behavior change: 'slot_y' is now [RANGE]_END and not [RANGE]_END + 1 void SummonAndRezzAllCorpses(); - void SummonAllCorpses(float dest_x, float dest_y, float dest_z, float dest_heading); + void SummonAllCorpses(const xyz_heading& position); void DepopAllCorpses(); void DepopPlayerCorpse(uint32 dbid); void BuryPlayerCorpses(); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 3ced16e87..d49528163 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1753,7 +1753,7 @@ bool QuestManager::summonallplayercorpses(uint32 char_id, const xyz_heading& pos return false; Client* c = entity_list.GetClientByCharID(char_id); - c->SummonAllCorpses(position.m_X, position.m_Y, position.m_Z, position.m_Heading); + c->SummonAllCorpses(position); return true; } From eb6c963c70bb9ab6750537b9ca5adb43320a39ef Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 15:04:13 -0800 Subject: [PATCH 084/253] SummonAllGraveyardCorpses converted to xyz_heading --- zone/zonedb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/zonedb.h b/zone/zonedb.h index e66448a47..ed2988048 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -304,7 +304,7 @@ public: bool BuryAllCharacterCorpses(uint32 charid); bool DeleteCharacterCorpse(uint32 dbid); bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const xyz_heading& position); - bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); + bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, const xyz_heading& position); bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, float new_x, float new_y, float new_z, float new_heading); bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID); bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id); From 361b4d1c62bb4d05db7a331e7317b8749fd88c0e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 15:18:16 -0800 Subject: [PATCH 085/253] UnburyCharacterCorpse converted to xyz_heading --- zone/zonedb.cpp | 19 +++++++++++-------- zone/zonedb.h | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 239608473..f54846185 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3796,7 +3796,7 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z entity_list.AddCorpse(corpse); corpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); corpse->Spawn(); - if (!UnburyCharacterCorpse(corpse->GetDBID(), dest_zone_id, dest_instance_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading)) + if (!UnburyCharacterCorpse(corpse->GetDBID(), dest_zone_id, dest_instance_id, position)) LogFile->write(EQEMuLog::Error, "Unable to unbury a summoned player corpse for character id %u.", char_id); } @@ -3842,15 +3842,18 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id return (CorpseCount > 0); } -bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint16 new_instance_id, float new_x, float new_y, float new_z, float new_heading) { - std::string query = StringFormat( - "UPDATE `character_corpses` SET `is_buried` = 0, `zone_id` = %u, `instance_id` = %u, `x` = %f, `y` = %f, `z` = %f, `heading` = %f, `time_of_death` = Now(), `was_at_graveyard` = 0 WHERE `id` = %u", - new_zone_id, new_instance_id, new_x, new_y, new_z, new_heading, db_id - ); +bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint16 new_instance_id, const xyz_heading& position) { + std::string query = StringFormat("UPDATE `character_corpses` " + "SET `is_buried` = 0, `zone_id` = %u, `instance_id` = %u, " + "`x` = %f, `y` = %f, `z` = %f, `heading` = %f, " + "`time_of_death` = Now(), `was_at_graveyard` = 0 " + "WHERE `id` = %u", + new_zone_id, new_instance_id, + position.m_X, position.m_Y, position.m_Z, position.m_Heading, db_id); auto results = QueryDatabase(query); - if (results.Success() && results.RowsAffected() != 0){ + if (results.Success() && results.RowsAffected() != 0) return true; - } + return false; } diff --git a/zone/zonedb.h b/zone/zonedb.h index ed2988048..b126efef4 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -305,7 +305,7 @@ public: bool DeleteCharacterCorpse(uint32 dbid); bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const xyz_heading& position); bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, const xyz_heading& position); - bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, float new_x, float new_y, float new_z, float new_heading); + bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, const xyz_heading& position); bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID); bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id); uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id); From d22f136eeae667f68b81302cd934caa35aadc412 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 15:27:43 -0800 Subject: [PATCH 086/253] SendCharacterCorpseToGraveyard to xyz_heading --- zone/corpse.cpp | 4 ++-- zone/zonedb.cpp | 14 +++++++------- zone/zonedb.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 8f8d6a4e1..8b8cfef14 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -769,8 +769,8 @@ bool Corpse::Process() { Save(); player_corpse_depop = true; database.SendCharacterCorpseToGraveyard(corpse_db_id, zone->graveyard_zoneid(), - (zone->GetZoneID() == zone->graveyard_zoneid()) ? zone->GetInstanceID() : 0, zone->graveyard_x(), - zone->graveyard_y(), zone->graveyard_z(), zone->graveyard_heading()); + (zone->GetZoneID() == zone->graveyard_zoneid()) ? zone->GetInstanceID() : 0, xyz_heading(zone->graveyard_x(), + zone->graveyard_y(), zone->graveyard_z(), zone->graveyard_heading())); corpse_graveyard_timer.Disable(); ServerPacket* pack = new ServerPacket(ServerOP_SpawnPlayerCorpse, sizeof(SpawnPlayerCorpse_Struct)); SpawnPlayerCorpse_Struct* spc = (SpawnPlayerCorpse_Struct*)pack->pBuffer; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index f54846185..4fec05758 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3352,13 +3352,13 @@ uint32 ZoneDatabase::CreateGraveyardRecord(uint32 graveyard_zone_id, float grave } return 0; } -uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id, uint16 instance_id, float x, float y, float z, float heading) { - std::string query = StringFormat( - "UPDATE `character_corpses` " - "SET `zone_id` = %u, `instance_id` = 0, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f, `was_at_graveyard` = 1 " - "WHERE `id` = %d", - zone_id, x, y, z, heading, dbid - ); +uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id, uint16 instance_id, const xyz_heading& position) { + std::string query = StringFormat("UPDATE `character_corpses` " + "SET `zone_id` = %u, `instance_id` = 0, " + "`x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f, " + "`was_at_graveyard` = 1 " + "WHERE `id` = %d", + zone_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading, dbid); QueryDatabase(query); return dbid; } diff --git a/zone/zonedb.h b/zone/zonedb.h index b126efef4..e72670e83 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -310,7 +310,7 @@ public: bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id); uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id); uint32 GetCharacterBuriedCorpseCount(uint32 char_id); - uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, float x, float y, float z, float heading); + uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, const xyz_heading& position); uint32 CreateGraveyardRecord(uint32 graveyard_zoneid, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading); uint32 AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id); uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading); From 76210e1f0e41afb25c98c7db10ece80346fd3ffe Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 15:42:30 -0800 Subject: [PATCH 087/253] CreateGraveyardRecord converted to xyz_heading --- zone/command.cpp | 2 +- zone/zonedb.cpp | 13 ++++++------- zone/zonedb.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 030ce7de5..0841149f2 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -8459,7 +8459,7 @@ void command_setgraveyard(Client *c, const Seperator *sep) zoneid = database.GetZoneID(sep->arg[1]); if(zoneid > 0) { - graveyard_id = database.CreateGraveyardRecord(zoneid, t->GetX(), t->GetY(), t->GetZ(), t->GetHeading()); + graveyard_id = database.CreateGraveyardRecord(zoneid, t->GetPosition()); if(graveyard_id > 0) { c->Message(0, "Successfuly added a new record for this graveyard!"); diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 4fec05758..a49ea0b98 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3341,15 +3341,14 @@ uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) { return zone_id; } -uint32 ZoneDatabase::CreateGraveyardRecord(uint32 graveyard_zone_id, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading) { - std::string query = StringFormat( - "INSERT INTO `graveyard` SET `zone_id` = %u, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f", - graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, graveyard_heading - ); +uint32 ZoneDatabase::CreateGraveyardRecord(uint32 graveyard_zone_id, const xyz_heading& position) { + std::string query = StringFormat("INSERT INTO `graveyard` " + "SET `zone_id` = %u, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f", + graveyard_zone_id, position.m_X, position.m_Y, position.m_Z, position.m_Heading); auto results = QueryDatabase(query); - if (results.Success()){ + if (results.Success()) return results.LastInsertedID(); - } + return 0; } uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id, uint16 instance_id, const xyz_heading& position) { diff --git a/zone/zonedb.h b/zone/zonedb.h index e72670e83..53fd89584 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -311,7 +311,7 @@ public: uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id); uint32 GetCharacterBuriedCorpseCount(uint32 char_id); uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, const xyz_heading& position); - uint32 CreateGraveyardRecord(uint32 graveyard_zoneid, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading); + uint32 CreateGraveyardRecord(uint32 graveyard_zoneid, const xyz_heading& position); uint32 AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id); uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading); uint32 UpdateCharacterCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading, bool rezzed = false); From 4243ce8582fbb93ab4e21daaf127564852286039 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 16:02:12 -0800 Subject: [PATCH 088/253] SaveCharacterCorpse converted to xyz_heading --- zone/corpse.cpp | 2 +- zone/zonedb.cpp | 112 +++++++++++------------------------------------- zone/zonedb.h | 2 +- 3 files changed, 27 insertions(+), 89 deletions(-) diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 8b8cfef14..c75725179 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -590,7 +590,7 @@ bool Corpse::Save() { /* Create New Corpse*/ if (corpse_db_id == 0) { - corpse_db_id = database.SaveCharacterCorpse(char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_Position.m_Heading); + corpse_db_id = database.SaveCharacterCorpse(char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position); } /* Update Corpse Data */ else{ diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index a49ea0b98..7859301dd 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3469,94 +3469,32 @@ void ZoneDatabase::MarkCorpseAsRezzed(uint32 db_id) { auto results = QueryDatabase(query); } -uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading) { +uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const xyz_heading& position) { /* Dump Basic Corpse Data */ - std::string query = StringFormat("INSERT INTO `character_corpses` SET \n" - "`charname` = '%s',\n" - "`zone_id` = %u,\n" - "`instance_id` = %u,\n" - "`charid` = %d,\n" - "`x` = %1.1f,\n" - "`y` = %1.1f,\n" - "`z` = %1.1f,\n" - "`heading` = %1.1f,\n" - "`time_of_death` = NOW(),\n" - "`is_buried` = 0," - "`is_locked` = %d,\n" - "`exp` = %u,\n" - "`size` = %f,\n" - "`level` = %u,\n" - "`race` = %u,\n" - "`gender` = %u,\n" - "`class` = %u,\n" - "`deity` = %u,\n" - "`texture` = %u,\n" - "`helm_texture` = %u,\n" - "`copper` = %u,\n" - "`silver` = %u,\n" - "`gold` = %u,\n" - "`platinum` = %u,\n" - "`hair_color` = %u,\n" - "`beard_color` = %u,\n" - "`eye_color_1` = %u,\n" - "`eye_color_2` = %u,\n" - "`hair_style` = %u,\n" - "`face` = %u,\n" - "`beard` = %u,\n" - "`drakkin_heritage` = %u,\n" - "`drakkin_tattoo` = %u,\n" - "`drakkin_details` = %u,\n" - "`wc_1` = %u,\n" - "`wc_2` = %u,\n" - "`wc_3` = %u,\n" - "`wc_4` = %u,\n" - "`wc_5` = %u,\n" - "`wc_6` = %u,\n" - "`wc_7` = %u,\n" - "`wc_8` = %u,\n" - "`wc_9` = %u \n", - EscapeString(charname).c_str(), - zoneid, - instanceid, - charid, - x, - y, - z, - heading, - dbpc->locked, - dbpc->exp, - dbpc->size, - dbpc->level, - dbpc->race, - dbpc->gender, - dbpc->class_, - dbpc->deity, - dbpc->texture, - dbpc->helmtexture, - dbpc->copper, - dbpc->silver, - dbpc->gold, - dbpc->plat, - dbpc->haircolor, - dbpc->beardcolor, - dbpc->eyecolor1, - dbpc->eyecolor2, - dbpc->hairstyle, - dbpc->face, - dbpc->beard, - dbpc->drakkin_heritage, - dbpc->drakkin_tattoo, - dbpc->drakkin_details, - dbpc->item_tint[0].color, - dbpc->item_tint[1].color, - dbpc->item_tint[2].color, - dbpc->item_tint[3].color, - dbpc->item_tint[4].color, - dbpc->item_tint[5].color, - dbpc->item_tint[6].color, - dbpc->item_tint[7].color, - dbpc->item_tint[8].color - ); + std::string query = StringFormat("INSERT INTO `character_corpses` " + "SET `charname` = '%s', `zone_id` = %u, `instance_id` = %u, `charid` = %d," + "`x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f," + "`time_of_death` = NOW(), `is_buried` = 0, `is_locked` = %d," + "`exp` = %u, `size` = %f, `level` = %u, `race` = %u, `gender` = %u," + "`class` = %u, `deity` = %u, `texture` = %u, `helm_texture` = %u," + "`copper` = %u, `silver` = %u,`gold` = %u,`platinum` = %u," + "`hair_color` = %u, `beard_color` = %u, `eye_color_1` = %u," + "`eye_color_2` = %u, `hair_style` = %u, `face` = %u," + "`beard` = %u, `drakkin_heritage` = %u, `drakkin_tattoo` = %u," + "`drakkin_details` = %u, `wc_1` = %u, `wc_2` = %u," + "`wc_3` = %u, `wc_4` = %u, `wc_5` = %u, `wc_6` = %u," + "`wc_7` = %u,`wc_8` = %u,`wc_9` = %u", + EscapeString(charname).c_str(), zoneid, instanceid, charid, + position.m_X, position.m_Y, position.m_Z, position.m_Heading, + dbpc->locked, dbpc->exp, dbpc->size, dbpc->level, dbpc->race, + dbpc->gender, dbpc->class_, dbpc->deity, dbpc->texture, + dbpc->helmtexture, dbpc->copper, dbpc->silver, dbpc->gold, + dbpc->plat, dbpc->haircolor, dbpc->beardcolor, dbpc->eyecolor1, + dbpc->eyecolor2, dbpc->hairstyle, dbpc->face, dbpc->beard, + dbpc->drakkin_heritage, dbpc->drakkin_tattoo, dbpc->drakkin_details, + dbpc->item_tint[0].color, dbpc->item_tint[1].color, dbpc->item_tint[2].color, + dbpc->item_tint[3].color, dbpc->item_tint[4].color, dbpc->item_tint[5].color, + dbpc->item_tint[6].color, dbpc->item_tint[7].color, dbpc->item_tint[8].color); auto results = QueryDatabase(query); uint32 last_insert_id = results.LastInsertedID(); diff --git a/zone/zonedb.h b/zone/zonedb.h index 53fd89584..a50c5d189 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -313,7 +313,7 @@ public: uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, const xyz_heading& position); uint32 CreateGraveyardRecord(uint32 graveyard_zoneid, const xyz_heading& position); uint32 AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id); - uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading); + uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const xyz_heading& position); uint32 UpdateCharacterCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading, bool rezzed = false); uint32 GetFirstCorpseID(uint32 char_id); uint32 GetCharacterCorpseCount(uint32 char_id); From 275f2aa80fee8889ec0f5c9610e59a4c71a14d07 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 16:21:20 -0800 Subject: [PATCH 089/253] UpdateCharacterCorpse converted to xyz_heading --- zone/corpse.cpp | 2 +- zone/zonedb.cpp | 113 +++++++++++------------------------------------- zone/zonedb.h | 2 +- 3 files changed, 28 insertions(+), 89 deletions(-) diff --git a/zone/corpse.cpp b/zone/corpse.cpp index c75725179..c37b2cde3 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -594,7 +594,7 @@ bool Corpse::Save() { } /* Update Corpse Data */ else{ - corpse_db_id = database.UpdateCharacterCorpse(corpse_db_id, char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_Position.m_Heading, IsRezzed()); + corpse_db_id = database.UpdateCharacterCorpse(corpse_db_id, char_id, orgname, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position, IsRezzed()); } safe_delete_array(dbpc); diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 7859301dd..a59223f68 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3372,93 +3372,32 @@ uint32 ZoneDatabase::GetCharacterCorpseDecayTimer(uint32 corpse_db_id){ return 0; } -uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const char* char_name, uint32 zone_id, uint16 instance_id, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading, bool is_rezzed) { - std::string query = StringFormat("UPDATE `character_corpses` SET \n" - "`charname` = '%s',\n" - "`zone_id` = %u,\n" - "`instance_id` = %u,\n" - "`charid` = %d,\n" - "`x` = %1.1f,\n" - "`y` = %1.1f,\n" - "`z` = %1.1f,\n" - "`heading` = %1.1f,\n" - "`is_locked` = %d,\n" - "`exp` = %u,\n" - "`size` = %f,\n" - "`level` = %u,\n" - "`race` = %u,\n" - "`gender` = %u,\n" - "`class` = %u,\n" - "`deity` = %u,\n" - "`texture` = %u,\n" - "`helm_texture` = %u,\n" - "`copper` = %u,\n" - "`silver` = %u,\n" - "`gold` = %u,\n" - "`platinum` = %u,\n" - "`hair_color` = %u,\n" - "`beard_color` = %u,\n" - "`eye_color_1` = %u,\n" - "`eye_color_2` = %u,\n" - "`hair_style` = %u,\n" - "`face` = %u,\n" - "`beard` = %u,\n" - "`drakkin_heritage` = %u,\n" - "`drakkin_tattoo` = %u,\n" - "`drakkin_details` = %u,\n" - "`wc_1` = %u,\n" - "`wc_2` = %u,\n" - "`wc_3` = %u,\n" - "`wc_4` = %u,\n" - "`wc_5` = %u,\n" - "`wc_6` = %u,\n" - "`wc_7` = %u,\n" - "`wc_8` = %u,\n" - "`wc_9` = %u \n" - "WHERE `id` = %u", - EscapeString(char_name).c_str(), - zone_id, - instance_id, - char_id, - x, - y, - z, - heading, - dbpc->locked, - dbpc->exp, - dbpc->size, - dbpc->level, - dbpc->race, - dbpc->gender, - dbpc->class_, - dbpc->deity, - dbpc->texture, - dbpc->helmtexture, - dbpc->copper, - dbpc->silver, - dbpc->gold, - dbpc->plat, - dbpc->haircolor, - dbpc->beardcolor, - dbpc->eyecolor1, - dbpc->eyecolor2, - dbpc->hairstyle, - dbpc->face, - dbpc->beard, - dbpc->drakkin_heritage, - dbpc->drakkin_tattoo, - dbpc->drakkin_details, - dbpc->item_tint[0].color, - dbpc->item_tint[1].color, - dbpc->item_tint[2].color, - dbpc->item_tint[3].color, - dbpc->item_tint[4].color, - dbpc->item_tint[5].color, - dbpc->item_tint[6].color, - dbpc->item_tint[7].color, - dbpc->item_tint[8].color, - db_id - ); +uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const char* char_name, uint32 zone_id, uint16 instance_id, PlayerCorpse_Struct* dbpc, const xyz_heading& position, bool is_rezzed) { + std::string query = StringFormat("UPDATE `character_corpses` " + "SET `charname` = '%s', `zone_id` = %u, `instance_id` = %u, `charid` = %d, " + "`x` = %1.1f,`y` = %1.1f,`z` = %1.1f, `heading` = %1.1f, " + "`is_locked` = %d, `exp` = %u, `size` = %f, `level` = %u, " + "`race` = %u, `gender` = %u, `class` = %u, `deity` = %u, " + "`texture` = %u, `helm_texture` = %u, `copper` = %u, " + "`silver` = %u, `gold` = %u, `platinum` = %u, `hair_color` = %u, " + "`beard_color` = %u, `eye_color_1` = %u, `eye_color_2` = %u, " + "`hair_style` = %u, `face` = %u, `beard` = %u, `drakkin_heritage` = %u, " + "`drakkin_tattoo` = %u, `drakkin_details` = %u, `wc_1` = %u, " + "`wc_2` = %u, `wc_3` = %u, `wc_4` = %u, `wc_5` = %u, `wc_6` = %u, " + "`wc_7` = %u, `wc_8` = %u, `wc_9` = %u " + "WHERE `id` = %u", + EscapeString(char_name).c_str(), zone_id, instance_id, char_id, + position.m_X, position.m_Y, position.m_Z, position.m_Heading, + dbpc->locked, dbpc->exp, dbpc->size, dbpc->level, dbpc->race, + dbpc->gender, dbpc->class_, dbpc->deity, dbpc->texture, + dbpc->helmtexture, dbpc->copper, dbpc->silver, dbpc->gold, + dbpc->plat, dbpc->haircolor, dbpc->beardcolor, dbpc->eyecolor1, + dbpc->eyecolor2, dbpc->hairstyle, dbpc->face, dbpc->beard, + dbpc->drakkin_heritage, dbpc->drakkin_tattoo, dbpc->drakkin_details, + dbpc->item_tint[0].color, dbpc->item_tint[1].color, dbpc->item_tint[2].color, + dbpc->item_tint[3].color, dbpc->item_tint[4].color, dbpc->item_tint[5].color, + dbpc->item_tint[6].color, dbpc->item_tint[7].color, dbpc->item_tint[8].color, + db_id); auto results = QueryDatabase(query); return db_id; diff --git a/zone/zonedb.h b/zone/zonedb.h index a50c5d189..7fadaf6cf 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -314,7 +314,7 @@ public: uint32 CreateGraveyardRecord(uint32 graveyard_zoneid, const xyz_heading& position); uint32 AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id); uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const xyz_heading& position); - uint32 UpdateCharacterCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading, bool rezzed = false); + uint32 UpdateCharacterCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, const xyz_heading& position, bool rezzed = false); uint32 GetFirstCorpseID(uint32 char_id); uint32 GetCharacterCorpseCount(uint32 char_id); uint32 GetCharacterCorpseID(uint32 char_id, uint8 corpse); From cafa266c89a16b3245118d18a4720e7c0d0f7a2a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 16:42:19 -0800 Subject: [PATCH 090/253] UpdateZoneSafeCoords converted to xyz_heading --- zone/zonedb.cpp | 5 +++-- zone/zonedb.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index a59223f68..029726bef 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -2471,10 +2471,11 @@ void ZoneDatabase::DeleteMerchantTemp(uint32 npcid, uint32 slot){ } -bool ZoneDatabase::UpdateZoneSafeCoords(const char* zonename, float x=0, float y=0, float z=0) { +bool ZoneDatabase::UpdateZoneSafeCoords(const char* zonename, const xyz_location& location) { std::string query = StringFormat("UPDATE zone SET safe_x='%f', safe_y='%f', safe_z='%f' " - "WHERE short_name='%s';", x, y, z, zonename); + "WHERE short_name='%s';", + location.m_X, location.m_Y, location.m_Z, zonename); auto results = QueryDatabase(query); if (!results.Success() || results.RowsAffected() == 0) return false; diff --git a/zone/zonedb.h b/zone/zonedb.h index 7fadaf6cf..f89bb5865 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -345,7 +345,7 @@ public: bool GetZoneCFG(uint32 zoneid, uint16 instance_id, NewZone_Struct *data, bool &can_bind, bool &can_combat, bool &can_levitate, bool &can_castoutdoor, bool &is_city, bool &is_hotzone, bool &allow_mercs, uint8 &zone_type, int &ruleset, char **map_filename); bool SaveZoneCFG(uint32 zoneid, uint16 instance_id, NewZone_Struct* zd); bool LoadStaticZonePoints(LinkedList* zone_point_list,const char* zonename, uint32 version); - bool UpdateZoneSafeCoords(const char* zonename, float x, float y, float z); + bool UpdateZoneSafeCoords(const char* zonename, const xyz_location& location); uint8 GetUseCFGSafeCoords(); int getZoneShutDownDelay(uint32 zoneID, uint32 version); From 2da6dfa9313a450e586100b03bfbc41a188ce883 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 16:53:52 -0800 Subject: [PATCH 091/253] CreateSpawn2 converted to xyz_heading --- zone/command.cpp | 2 +- zone/spawn2.cpp | 4 ++-- zone/zonedb.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 0841149f2..47cdbd754 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -1980,7 +1980,7 @@ void command_dbspawn2(Client *c, const Seperator *sep) if(sep->IsNumber(5)) cond_min = atoi(sep->arg[5]); } - database.CreateSpawn2(c, atoi(sep->arg[1]), zone->GetShortName(), c->GetHeading(), c->GetX(), c->GetY(), c->GetZ(), atoi(sep->arg[2]), atoi(sep->arg[3]), cond, cond_min); + database.CreateSpawn2(c, atoi(sep->arg[1]), zone->GetShortName(), c->GetPosition(), atoi(sep->arg[2]), atoi(sep->arg[3]), cond, cond_min); } else { c->Message(0, "Usage: #dbspawn2 spawngroup respawn variance [condition_id] [condition_min]"); diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 1e973ebc7..f052980b7 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -413,13 +413,13 @@ Spawn2* ZoneDatabase::LoadSpawn2(LinkedList &spawn2_list, uint32 spawn2 return newSpawn; } -bool ZoneDatabase::CreateSpawn2(Client *client, uint32 spawngroup, const char* zone, float heading, float x, float y, float z, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value) +bool ZoneDatabase::CreateSpawn2(Client *client, uint32 spawngroup, const char* zone, const xyz_heading& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value) { std::string query = StringFormat("INSERT INTO spawn2 (spawngroupID, zone, x, y, z, heading, " "respawntime, variance, _condition, cond_value) " "VALUES (%i, '%s', %f, %f, %f, %f, %i, %i, %u, %i)", - spawngroup, zone, x, y, z, heading, + spawngroup, zone, position.m_X, position.m_Y, position.m_Z, position.m_Heading, respawn, variance, condition, cond_value); auto results = QueryDatabase(query); if (!results.Success()) { diff --git a/zone/zonedb.h b/zone/zonedb.h index f89bb5865..877bc26c9 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -354,7 +354,7 @@ public: bool LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_group_list); bool PopulateZoneSpawnList(uint32 zoneid, LinkedList &spawn2_list, int16 version, uint32 repopdelay = 0); Spawn2* LoadSpawn2(LinkedList &spawn2_list, uint32 spawn2id, uint32 timeleft); - bool CreateSpawn2(Client *c, uint32 spawngroup, const char* zone, float heading, float x, float y, float z, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value); + bool CreateSpawn2(Client *c, uint32 spawngroup, const char* zone, const xyz_heading& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value); void UpdateSpawn2Timeleft(uint32 id, uint16 instance_id,uint32 timeleft); uint32 GetSpawnTimeLeft(uint32 id, uint16 instance_id); void UpdateSpawn2Status(uint32 id, uint8 new_status); From 6206133729302593f7b8e1aceae3fc9319f5b517 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 17:41:01 -0800 Subject: [PATCH 092/253] AddWP converted to xyz_heading --- zone/command.cpp | 6 ++++-- zone/waypoints.cpp | 4 ++-- zone/zonedb.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 47cdbd754..b47ec1fac 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -2059,10 +2059,12 @@ void command_wp(Client *c, const Seperator *sep) if (wp == 0) //default to highest if it's left blank, or we enter 0 wp = database.GetHighestWaypoint(zone->GetZoneID(), atoi(sep->arg[2])) + 1; if (strcasecmp("-h",sep->arg[5]) == 0) { - database.AddWP(c, atoi(sep->arg[2]),wp, c->GetX(), c->GetY(), c->GetZ(), atoi(sep->arg[3]),zone->GetZoneID(), c->GetHeading()); + database.AddWP(c, atoi(sep->arg[2]),wp, c->GetPosition(), atoi(sep->arg[3]),zone->GetZoneID()); } else { - database.AddWP(c, atoi(sep->arg[2]),wp, c->GetX(), c->GetY(), c->GetZ(), atoi(sep->arg[3]),zone->GetZoneID(), -1); + auto position = c->GetPosition(); + position.m_Heading = -1; + database.AddWP(c, atoi(sep->arg[2]),wp, position, atoi(sep->arg[3]),zone->GetZoneID()); } } else if (strcasecmp("delete",sep->arg[1]) == 0) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index b36f63106..a8b123fc3 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1168,11 +1168,11 @@ void ZoneDatabase::ModifyGrid(Client *client, bool remove, uint32 id, uint8 type /************************************** * AddWP - Adds a new waypoint to a specific grid for a specific zone. */ -void ZoneDatabase::AddWP(Client *client, uint32 gridid, uint32 wpnum, float xpos, float ypos, float zpos, uint32 pause, uint16 zoneid, float heading) +void ZoneDatabase::AddWP(Client *client, uint32 gridid, uint32 wpnum, const xyz_heading& position, uint32 pause, uint16 zoneid) { std::string query = StringFormat("INSERT INTO grid_entries (gridid, zoneid, `number`, x, y, z, pause, heading) " "VALUES (%i, %i, %i, %f, %f, %f, %i, %f)", - gridid, zoneid, wpnum, xpos, ypos, zpos, pause, heading); + gridid, zoneid, wpnum, position.m_X, position.m_Y, position.m_Z, pause, position.m_Heading); auto results = QueryDatabase(query); if (!results.Success()) { LogFile->write(EQEMuLog::Error, "Error adding waypoint '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); diff --git a/zone/zonedb.h b/zone/zonedb.h index 877bc26c9..832ad9f4b 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -363,7 +363,7 @@ public: uint32 GetFreeGrid(uint16 zoneid); void DeleteGrid(Client *c, uint32 sg2, uint32 grid_num, bool grid_too, uint16 zoneid); void DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num, uint16 zoneid); - void AddWP(Client *c, uint32 gridid, uint32 wpnum, float xpos, float ypos, float zpos, uint32 pause, uint16 zoneid, float heading); + void AddWP(Client *c, uint32 gridid, uint32 wpnum, const xyz_heading& position, uint32 pause, uint16 zoneid); uint32 AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float ypos, float zpos, uint32 pause, int type1, int type2, uint16 zoneid, float heading); void ModifyGrid(Client *c, bool remove, uint32 id, uint8 type = 0, uint8 type2 = 0, uint16 zoneid = 0); void ModifyWP(Client *c, uint32 grid_id, uint32 wp_num, float xpos, float ypos, float zpos, uint32 script = 0, uint16 zoneid = 0); From e58dc94b2cb16f35c8dedd0f220706e0d1dfbb1b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 18:15:51 -0800 Subject: [PATCH 093/253] AddWPForSpawn converted to xyz_heading --- zone/command.cpp | 11 ++++++----- zone/waypoints.cpp | 4 ++-- zone/zonedb.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index b47ec1fac..bd1626f85 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -5635,8 +5635,7 @@ void command_wpadd(Client *c, const Seperator *sep) { int type1=0, type2=0, - pause=0, - heading=-1; // Defaults for a new grid + pause=0; // Defaults for a new grid Mob *t=c->GetTarget(); if (t && t->IsNPC()) @@ -5659,9 +5658,11 @@ void command_wpadd(Client *c, const Seperator *sep) return; } } - if (strcmp("-h",sep->arg[2]) == 0) - heading = c->GetHeading(); - uint32 tmp_grid = database.AddWPForSpawn(c, s2info->GetID(), c->GetX(),c->GetY(),c->GetZ(), pause, type1, type2, zone->GetZoneID(), heading); + auto position = c->GetPosition(); + if (strcmp("-h",sep->arg[2]) != 0) + position.m_Heading = -1; + + uint32 tmp_grid = database.AddWPForSpawn(c, s2info->GetID(), position, pause, type1, type2, zone->GetZoneID()); if (tmp_grid) t->CastToNPC()->SetGrid(tmp_grid); diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index a8b123fc3..bd012daca 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1217,7 +1217,7 @@ void ZoneDatabase::DeleteWaypoint(Client *client, uint32 grid_num, uint32 wp_num * Returns 0 if the function didn't have to create a new grid. If the function had to create a new grid for the spawn, then the ID of * the created grid is returned. */ -uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, float xpos, float ypos, float zpos, uint32 pause, int type1, int type2, uint16 zoneid, float heading) { +uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, const xyz_heading& position, uint32 pause, int type1, int type2, uint16 zoneid) { uint32 grid_num; // The grid number the spawn is assigned to (if spawn has no grid, will be the grid number we end up creating) uint32 next_wp_num; // The waypoint number we should be assigning to the new waypoint @@ -1280,7 +1280,7 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, float xpos, query = StringFormat("INSERT INTO grid_entries(gridid, zoneid, `number`, x, y, z, pause, heading) " "VALUES (%i, %i, %i, %f, %f, %f, %i, %f)", - grid_num, zoneid, next_wp_num, xpos, ypos, zpos, pause, heading); + grid_num, zoneid, next_wp_num, position.m_X, position.m_Y, position.m_Z, pause, position.m_Heading); results = QueryDatabase(query); if(!results.Success()) LogFile->write(EQEMuLog::Error, "Error adding grid entry '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); diff --git a/zone/zonedb.h b/zone/zonedb.h index 832ad9f4b..4a563f2b9 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -364,7 +364,7 @@ public: void DeleteGrid(Client *c, uint32 sg2, uint32 grid_num, bool grid_too, uint16 zoneid); void DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num, uint16 zoneid); void AddWP(Client *c, uint32 gridid, uint32 wpnum, const xyz_heading& position, uint32 pause, uint16 zoneid); - uint32 AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float ypos, float zpos, uint32 pause, int type1, int type2, uint16 zoneid, float heading); + uint32 AddWPForSpawn(Client *c, uint32 spawn2id, const xyz_heading& position, uint32 pause, int type1, int type2, uint16 zoneid); void ModifyGrid(Client *c, bool remove, uint32 id, uint8 type = 0, uint8 type2 = 0, uint16 zoneid = 0); void ModifyWP(Client *c, uint32 grid_id, uint32 wp_num, float xpos, float ypos, float zpos, uint32 script = 0, uint16 zoneid = 0); uint8 GetGridType(uint32 grid, uint32 zoneid); From 2b7ecfdb2c821d3dc5568a2eaa8b7326eca0643e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 18:24:56 -0800 Subject: [PATCH 094/253] ModifyWP converted to xyz_location --- zone/zonedb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/zonedb.h b/zone/zonedb.h index 4a563f2b9..f196e5127 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -366,7 +366,7 @@ public: void AddWP(Client *c, uint32 gridid, uint32 wpnum, const xyz_heading& position, uint32 pause, uint16 zoneid); uint32 AddWPForSpawn(Client *c, uint32 spawn2id, const xyz_heading& position, uint32 pause, int type1, int type2, uint16 zoneid); void ModifyGrid(Client *c, bool remove, uint32 id, uint8 type = 0, uint8 type2 = 0, uint16 zoneid = 0); - void ModifyWP(Client *c, uint32 grid_id, uint32 wp_num, float xpos, float ypos, float zpos, uint32 script = 0, uint16 zoneid = 0); + void ModifyWP(Client *c, uint32 grid_id, uint32 wp_num, const xyz_location& location, uint32 script = 0, uint16 zoneid = 0); uint8 GetGridType(uint32 grid, uint32 zoneid); uint8 GetGridType2(uint32 grid, uint16 zoneid); bool GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp); From ad506ece4db72eb3e023f00648420709cf7379ec Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 19:28:28 -0800 Subject: [PATCH 095/253] Added distance functions for position --- zone/command.cpp | 10 +-------- zone/position.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++--- zone/position.h | 14 +++++++++--- zone/waypoints.cpp | 12 +++++----- zone/zonedb.h | 2 +- 5 files changed, 70 insertions(+), 23 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index bd1626f85..31cc9aa19 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -1799,15 +1799,7 @@ void command_itemtest(Client *c, const Seperator *sep) void command_gassign(Client *c, const Seperator *sep) { if (sep->IsNumber(1) && c->GetTarget() && c->GetTarget()->IsNPC()) - { - auto npcBind = c->GetTarget()->CastToNPC()->m_SpawnPoint; - database.AssignGrid( - c, - npcBind.m_X, - npcBind.m_Y, - atoi(sep->arg[1]) - ); - } + database.AssignGrid(c, c->GetTarget()->CastToNPC()->m_SpawnPoint, atoi(sep->arg[1])); else c->Message(0,"Usage: #gassign [num] - must have an npc target!"); } diff --git a/zone/position.cpp b/zone/position.cpp index 6f9a31d29..ddbe429af 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -9,11 +9,16 @@ xy_location::xy_location(float x, float y) : m_Y(y) { } -const xy_location xy_location::operator -(const xy_location& rhs) { +xy_location xy_location::operator -(const xy_location& rhs) const { xy_location minus(m_X - rhs.m_X, m_Y - rhs.m_Y); return minus; } +xy_location xy_location::operator +(const xy_location& rhs) const { + xy_location addition(m_X + rhs.m_X, m_Y + rhs.m_Y); + return addition; +} + xyz_heading::xyz_heading(float x, float y, float z, float heading) : m_X(x), m_Y(y), @@ -91,11 +96,11 @@ xyz_location::operator xy_location() const { return xy_location(m_X, m_Y); } -const xyz_location xyz_location::operator -(const xyz_location& rhs) const { +xyz_location xyz_location::operator -(const xyz_location& rhs) const { return xyz_location(m_X - rhs.m_X, m_Y - rhs.m_Y, m_Z - rhs.m_Z); } -const xyz_location xyz_location::operator +(const xyz_location& rhs) const { +xyz_location xyz_location::operator +(const xyz_location& rhs) const { return xyz_location(m_X + rhs.m_X, m_Y + rhs.m_Y, m_Z + rhs.m_Z); } @@ -117,6 +122,50 @@ std::string to_string(const xy_location &position){ return StringFormat("(%.3f, %.3f)", position.m_X,position.m_Y); } +/** +* Produces the non square root'ed distance between the two points within the XY plane. +*/ +float ComparativeDistance(const xy_location& point1, const xy_location& point2) { + auto diff = point1 - point2; + return diff.m_X * diff.m_X + diff.m_Y * diff.m_Y; +} + +/** +* Produces the distance between the two points on the XY plane. +*/ +float Distance(const xy_location& point1, const xy_location& point2) { + return sqrt(ComparativeDistance(point1, point2)); +} + +/** +* Produces the non square root'ed distance between the two points. +*/ +float ComparativeDistance(const xyz_location& point1, const xyz_location& point2) { + auto diff = point1 - point2; + return diff.m_X * diff.m_X + diff.m_Y * diff.m_Y + diff.m_Z * diff.m_Z; +} + +/** +* Produces the distance between the two points. +*/ +float Distance(const xyz_location& point1, const xyz_location& point2) { + return sqrt(ComparativeDistance(point1, point2)); +} + +/** +* Produces the distance between the two points within the XY plane. +*/ +float DistanceNoZ(const xyz_location& point1, const xyz_location& point2) { + return Distance(static_cast(point1),static_cast(point2)); +} + +/** +* Produces the non square root'ed distance between the two points within the XY plane. +*/ +float ComparativeDistanceNoZ(const xyz_location& point1, const xyz_location& point2) { + return ComparativeDistance(static_cast(point1),static_cast(point2)); +} + /** * Determines if 'position' is within (inclusive) the axis aligned * box (3 dimensional) formed from the points minimum and maximum. diff --git a/zone/position.h b/zone/position.h index 77c09603e..fd66ede5f 100644 --- a/zone/position.h +++ b/zone/position.h @@ -27,7 +27,8 @@ public: xy_location(float x = 0.0f, float y = 0.0f); - const xy_location operator -(const xy_location& rhs); + xy_location operator -(const xy_location& rhs) const; + xy_location operator +(const xy_location& rhs) const; }; class xyz_location { @@ -43,8 +44,8 @@ public: operator xy_location() const; - const xyz_location operator -(const xyz_location& rhs) const; - const xyz_location operator +(const xyz_location& rhs) const; + xyz_location operator -(const xyz_location& rhs) const; + xyz_location operator +(const xyz_location& rhs) const; void ABS_XYZ(); bool isOrigin() const { return m_X == 0 && m_Y == 0 && m_Z == 0;} @@ -86,4 +87,11 @@ std::string to_string(const xy_location &position); bool IsWithinAxisAlignedBox(const xyz_location &position, const xyz_location &minimum, const xyz_location &maximum); bool IsWithinAxisAlignedBox(const xy_location &position, const xy_location &minimum, const xy_location &maximum); +float ComparativeDistance(const xy_location& point1, const xy_location& point2); +float Distance(const xy_location& point1, const xy_location& point2); +float ComparativeDistance(const xyz_location& point1, const xyz_location& point2); +float Distance(const xyz_location& point1, const xyz_location& point2); +float DistanceNoZ(const xyz_location& point1, const xyz_location& point2); +float ComparativeDistanceNoZ(const xyz_location& point1, const xyz_location& point2); + #endif diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index bd012daca..12a81254e 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1046,15 +1046,14 @@ bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* return true; } -void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid) +void ZoneDatabase::AssignGrid(Client *client, const xy_location& location, uint32 grid) { int matches = 0, fuzzy = 0, spawn2id = 0; - float dbx = 0, dby = 0; // looks like most of the stuff in spawn2 is straight integers // so let's try that first std::string query = StringFormat("SELECT id, x, y FROM spawn2 WHERE zone = '%s' AND x = %i AND y = %i", - zone->GetShortName(), (int)x, (int)y); + zone->GetShortName(), (int)location.m_X, (int)location.m_Y); auto results = QueryDatabase(query); if(!results.Success()) { LogFile->write(EQEMuLog::Error, "Error querying spawn2 '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); @@ -1068,7 +1067,7 @@ void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid) query = StringFormat("SELECT id,x,y FROM spawn2 WHERE zone='%s' AND " "ABS( ABS(x) - ABS(%f) ) < %f AND " "ABS( ABS(y) - ABS(%f) ) < %f", - zone->GetShortName(), x, _GASSIGN_TOLERANCE, y, _GASSIGN_TOLERANCE); + zone->GetShortName(), location.m_X, _GASSIGN_TOLERANCE, location.m_Y, _GASSIGN_TOLERANCE); results = QueryDatabase(query); if (!results.Success()) { LogFile->write(EQEMuLog::Error, "Error querying fuzzy spawn2 '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); @@ -1094,8 +1093,7 @@ void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid) auto row = results.begin(); spawn2id = atoi(row[0]); - dbx = atof(row[1]); - dby = atof(row[2]); + xy_location dbLocation = xy_location(atof(row[1]), atof(row[2])); query = StringFormat("UPDATE spawn2 SET pathgrid = %d WHERE id = %d", grid, spawn2id); results = QueryDatabase(query); @@ -1120,7 +1118,7 @@ void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid) return; } - float difference = sqrtf(pow(fabs(x - dbx) , 2) + pow(fabs(y - dby), 2)); + float difference = sqrtf(pow(fabs(location.m_X - dbLocation.m_X) , 2) + pow(fabs(location.m_Y - dbLocation.m_Y), 2)); client->Message(0, "Grid assign: spawn2 id = %d updated - fuzzy match: deviation %f", spawn2id, difference); } diff --git a/zone/zonedb.h b/zone/zonedb.h index f196e5127..9e0d50e3f 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -370,7 +370,7 @@ public: uint8 GetGridType(uint32 grid, uint32 zoneid); uint8 GetGridType2(uint32 grid, uint16 zoneid); bool GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp); - void AssignGrid(Client *client, float x, float y, uint32 id); + void AssignGrid(Client *client, const xy_location& location, uint32 id); int GetHighestGrid(uint32 zoneid); int GetHighestWaypoint(uint32 zoneid, uint32 gridid); From 7c211e1e1150d521082d558ac621cdb61cd83e26 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 19:29:43 -0800 Subject: [PATCH 096/253] simplified SummonAllCorpses --- zone/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client.cpp b/zone/client.cpp index 4bde10bc0..826e22b00 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -4945,7 +4945,7 @@ void Client::SummonAndRezzAllCorpses() void Client::SummonAllCorpses(const xyz_heading& position) { auto summonLocation = position; - if(position.m_X == 0.0f && position.m_Y == 0.0f && position.m_Z == 0.0f && position.m_Heading == 0.0f) + if(position.isOrigin() && position.m_Heading == 0.0f) summonLocation = GetPosition(); ServerPacket *Pack = new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct)); From 75c1a302c978eb89b9e66f46ade278420b562c5e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 19:38:15 -0800 Subject: [PATCH 097/253] Converted Corpse constructor to xyz_heading --- zone/corpse.cpp | 13 +++++-------- zone/corpse.h | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/zone/corpse.cpp b/zone/corpse.cpp index c37b2cde3..205eddf83 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -90,10 +90,7 @@ Corpse* Corpse::LoadFromDBData(uint32 in_dbid, uint32 in_charid, std::string in_ pcs->silver, // uint32 in_silver pcs->gold, // uint32 in_gold pcs->plat, // uint32 in_plat - position.m_X, // float in_x - position.m_Y, // float in_y - position.m_Z, // float in_z - position.m_Heading, // float in_heading + position, pcs->size, // float in_size pcs->gender, // uint8 in_gender pcs->race, // uint16 in_race @@ -423,7 +420,7 @@ std::list Corpse::MoveItemToCorpse(Client *client, ItemInst *item, int16 // To be called from LoadFromDBData // Mongrel: added see_invis and see_invis_undead -Corpse::Corpse(uint32 in_dbid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture,uint32 in_rezexp, bool wasAtGraveyard) +Corpse::Corpse(uint32 in_dbid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, const xyz_heading& position, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture,uint32 in_rezexp, bool wasAtGraveyard) : Mob("Unnamed_Corpse", "", 0, @@ -437,7 +434,7 @@ in_level, 0, in_size, 0, -xyz_heading(in_x, in_y,in_z,in_heading), +position, 0, in_texture, in_helmtexture, @@ -503,9 +500,9 @@ in_helmtexture, this->platinum = in_plat; rezzexp = in_rezexp; - for (int i = 0; i < MAX_LOOTERS; i++){ + for (int i = 0; i < MAX_LOOTERS; i++) allowed_looters[i] = 0; - } + SetPKItem(0); } diff --git a/zone/corpse.h b/zone/corpse.h index ba2dfbecc..6d1d45575 100644 --- a/zone/corpse.h +++ b/zone/corpse.h @@ -34,7 +34,7 @@ public: Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NPCType** in_npctypedata, uint32 in_decaytime = 600000); Corpse(Client* client, int32 in_rezexp); - Corpse(uint32 in_corpseid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture, uint32 in_rezexp, bool wasAtGraveyard = false); + Corpse(uint32 in_corpseid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, const xyz_heading& position, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture, uint32 in_rezexp, bool wasAtGraveyard = false); ~Corpse(); static Corpse* LoadFromDBData(uint32 in_dbid, uint32 in_charid, std::string in_charname, const xyz_heading& position, std::string time_of_death, bool rezzed, bool was_at_graveyard); From 0275e9646ca9c4820a84e8f578ad80391ec7d8ee Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 19:55:29 -0800 Subject: [PATCH 098/253] Added GetSafePoint to Zone --- zone/zone.h | 1 + 1 file changed, 1 insertion(+) diff --git a/zone/zone.h b/zone/zone.h index 0701c26e2..32b17c274 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -109,6 +109,7 @@ public: inline Timer* GetInstanceTimer() { return Instance_Timer; } + inline xyz_heading GetSafePoint() { return m_SafePoint; } inline const float& safe_x() { return m_SafePoint.m_X; } inline const float& safe_y() { return m_SafePoint.m_Y; } inline const float& safe_z() { return m_SafePoint.m_Z; } From e64e131c9c22a3feeb770ba9a571e2e421ec4608 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 20:17:14 -0800 Subject: [PATCH 099/253] Removed safe_x(), safe_y(), safe_z() from Zone --- zone/client_packet.cpp | 7 ++++--- zone/zone.h | 5 +---- zone/zoning.cpp | 8 +++++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 475188975..ad6e3745b 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1460,9 +1460,10 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) strcpy(lastname, m_pp.last_name); /* If PP is set to weird coordinates */ if ((m_pp.x == -1 && m_pp.y == -1 && m_pp.z == -1) || (m_pp.x == -2 && m_pp.y == -2 && m_pp.z == -2)) { - m_pp.x = zone->safe_x(); - m_pp.y = zone->safe_y(); - m_pp.z = zone->safe_z(); + auto safePoint = zone->GetSafePoint(); + m_pp.x = safePoint.m_X; + m_pp.y = safePoint.m_Y; + m_pp.z = safePoint.m_Z; } /* If too far below ground, then fix */ // float ground_z = GetGroundZ(m_pp.x, m_pp.y, m_pp.z); diff --git a/zone/zone.h b/zone/zone.h index 32b17c274..7bb1d196e 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -109,10 +109,7 @@ public: inline Timer* GetInstanceTimer() { return Instance_Timer; } - inline xyz_heading GetSafePoint() { return m_SafePoint; } - inline const float& safe_x() { return m_SafePoint.m_X; } - inline const float& safe_y() { return m_SafePoint.m_Y; } - inline const float& safe_z() { return m_SafePoint.m_Z; } + inline xyz_location GetSafePoint() { return m_SafePoint; } inline const uint32& graveyard_zoneid() { return pgraveyard_zoneid; } inline const float& graveyard_x() { return m_Graveyard.m_X; } inline const float& graveyard_y() { return m_Graveyard.m_Y; } diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 266951f1b..4a22746c8 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -488,13 +488,15 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z return; } iZoneNameLength = strlen(pZoneName); + xyz_heading safePoint; switch(zm) { case EvacToSafeCoords: case ZoneToSafeCoords: - x = zone->safe_x(); - y = zone->safe_y(); - z = zone->safe_z(); + safePoint = zone->GetSafePoint(); + x = safePoint.m_X; + y = safePoint.m_Y; + z = safePoint.m_Z; SetHeading(heading); break; case GMSummon: From ff1942245ba0de8664242e56b97ffad214ad195b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 20:25:38 -0800 Subject: [PATCH 100/253] Added GetGraveyardPoint() to Zone --- zone/zone.h | 1 + 1 file changed, 1 insertion(+) diff --git a/zone/zone.h b/zone/zone.h index 7bb1d196e..1cc387f18 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -111,6 +111,7 @@ public: inline xyz_location GetSafePoint() { return m_SafePoint; } inline const uint32& graveyard_zoneid() { return pgraveyard_zoneid; } + inline xyz_heading GetGraveyardPoint() { return m_Graveyard; } inline const float& graveyard_x() { return m_Graveyard.m_X; } inline const float& graveyard_y() { return m_Graveyard.m_Y; } inline const float& graveyard_z() { return m_Graveyard.m_Z; } From f00cddd67e9aaaf54d66c6b06e486c770be13c16 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 21:00:31 -0800 Subject: [PATCH 101/253] graveyard_x(), graveyard_y(), graveyard_z(), and graveyard_heading() converted to GetGraveyardPoint() --- zone/corpse.cpp | 3 +-- zone/zone.cpp | 2 +- zone/zone.h | 4 ---- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 205eddf83..4abdc72e2 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -766,8 +766,7 @@ bool Corpse::Process() { Save(); player_corpse_depop = true; database.SendCharacterCorpseToGraveyard(corpse_db_id, zone->graveyard_zoneid(), - (zone->GetZoneID() == zone->graveyard_zoneid()) ? zone->GetInstanceID() : 0, xyz_heading(zone->graveyard_x(), - zone->graveyard_y(), zone->graveyard_z(), zone->graveyard_heading())); + (zone->GetZoneID() == zone->graveyard_zoneid()) ? zone->GetInstanceID() : 0, zone->GetGraveyardPoint()); corpse_graveyard_timer.Disable(); ServerPacket* pack = new ServerPacket(ServerOP_SpawnPlayerCorpse, sizeof(SpawnPlayerCorpse_Struct)); SpawnPlayerCorpse_Struct* spc = (SpawnPlayerCorpse_Struct*)pack->pBuffer; diff --git a/zone/zone.cpp b/zone/zone.cpp index cc333c5fa..333d3f4da 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -791,7 +791,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) LogFile->write(EQEMuLog::Debug, "Graveyard ID is %i.", graveyard_id()); bool GraveYardLoaded = database.GetZoneGraveyard(graveyard_id(), &pgraveyard_zoneid, &m_Graveyard.m_X, &m_Graveyard.m_Y, &m_Graveyard.m_Z, &m_Graveyard.m_Heading); if(GraveYardLoaded) - LogFile->write(EQEMuLog::Debug, "Loaded a graveyard for zone %s: graveyard zoneid is %u x is %f y is %f z is %f heading is %f.", short_name, graveyard_zoneid(), graveyard_x(), graveyard_y(), graveyard_z(), graveyard_heading()); + LogFile->write(EQEMuLog::Debug, "Loaded a graveyard for zone %s: graveyard zoneid is %u at %s.", short_name, graveyard_zoneid(), to_string(m_Graveyard).c_str()); else LogFile->write(EQEMuLog::Error, "Unable to load the graveyard id %i for zone %s.", graveyard_id(), short_name); } diff --git a/zone/zone.h b/zone/zone.h index 1cc387f18..6c2581d38 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -112,10 +112,6 @@ public: inline xyz_location GetSafePoint() { return m_SafePoint; } inline const uint32& graveyard_zoneid() { return pgraveyard_zoneid; } inline xyz_heading GetGraveyardPoint() { return m_Graveyard; } - inline const float& graveyard_x() { return m_Graveyard.m_X; } - inline const float& graveyard_y() { return m_Graveyard.m_Y; } - inline const float& graveyard_z() { return m_Graveyard.m_Z; } - inline const float& graveyard_heading() { return m_Graveyard.m_Heading; } inline const uint32& graveyard_id() { return pgraveyard_id; } inline const uint32& GetMaxClients() { return pMaxClients; } From 523562c152bb703f012acaff4fbdeeeb060dafd5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 2 Dec 2014 21:27:22 -0800 Subject: [PATCH 102/253] GetClosestZonePoint converted to xyz_location (id version) --- zone/zone.cpp | 6 +++--- zone/zone.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 333d3f4da..5b9910441 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1580,10 +1580,10 @@ ZonePoint* Zone::GetClosestZonePoint(float x, float y, float z, uint32 to, Clien return closest_zp; } -ZonePoint* Zone::GetClosestZonePoint(float x, float y, float z, const char* to_name, Client* client, float max_distance) { +ZonePoint* Zone::GetClosestZonePoint(const xyz_location& location, const char* to_name, Client* client, float max_distance) { if(to_name == nullptr) - return GetClosestZonePointWithoutZone(x,y,z, client, max_distance); - return GetClosestZonePoint(x, y, z, database.GetZoneID(to_name), client, max_distance); + return GetClosestZonePointWithoutZone(location.m_X, location.m_Y, location.m_Z, client, max_distance); + return GetClosestZonePoint(location.m_X, location.m_Y, location.m_Z, database.GetZoneID(to_name), client, max_distance); } ZonePoint* Zone::GetClosestZonePointWithoutZone(float x, float y, float z, Client* client, float max_distance) { diff --git a/zone/zone.h b/zone/zone.h index 6c2581d38..4716b3757 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -127,7 +127,7 @@ public: void ReloadStaticData(); uint32 CountSpawn2(); - ZonePoint* GetClosestZonePoint(float x, float y, float z, const char* to_name, Client *client, float max_distance = 40000.0f); + ZonePoint* GetClosestZonePoint(const xyz_location& location, const char* to_name, Client *client, float max_distance = 40000.0f); ZonePoint* GetClosestZonePoint(float x, float y, float z, uint32 to, Client *client, float max_distance = 40000.0f); ZonePoint* GetClosestZonePointWithoutZone(float x, float y, float z, Client *client, float max_distance = 40000.0f); SpawnGroupList spawn_group_list; From 100eca203f29dcfa508e9c37bc50419c3da85af3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Fri, 5 Dec 2014 17:57:07 -0800 Subject: [PATCH 103/253] GetClosestZonePoint converted to xyz_location --- zone/zone.cpp | 20 ++++++++------------ zone/zone.h | 2 +- zone/zoning.cpp | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 5b9910441..a4d746506 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1528,7 +1528,7 @@ void Zone::SetTime(uint8 hour, uint8 minute) } } -ZonePoint* Zone::GetClosestZonePoint(float x, float y, float z, uint32 to, Client* client, float max_distance) { +ZonePoint* Zone::GetClosestZonePoint(const xyz_location& location, uint32 to, Client* client, float max_distance) { LinkedListIterator iterator(zone_point_list); ZonePoint* closest_zp = 0; float closest_dist = FLT_MAX; @@ -1546,14 +1546,10 @@ ZonePoint* Zone::GetClosestZonePoint(float x, float y, float z, uint32 to, Clien if (zp->target_zone_id == to) { - float delta_x = zp->x - x; - float delta_y = zp->y - y; - if(zp->x == 999999 || zp->x == -999999) - delta_x = 0; - if(zp->y == 999999 || zp->y == -999999) - delta_y = 0; + auto dist = Distance(xy_location(zp->x,zp->y), location); + if ((zp->x == 999999 || zp->x == -999999) && (zp->y == 999999 || zp->y == -999999)) + dist = 0; - float dist = sqrt(delta_x * delta_x + delta_y * delta_y); if (dist < closest_dist) { closest_zp = zp; @@ -1566,16 +1562,16 @@ ZonePoint* Zone::GetClosestZonePoint(float x, float y, float z, uint32 to, Clien if(closest_dist > 400.0f && closest_dist < max_distance2) { if(client) - client->CheatDetected(MQZoneUnknownDest, x, y, z); // Someone is trying to use /zone + client->CheatDetected(MQZoneUnknownDest, location.m_X, location.m_Y, location.m_Z); // Someone is trying to use /zone LogFile->write(EQEMuLog::Status, "WARNING: Closest zone point for zone id %d is %f, you might need to update your zone_points table if you dont arrive at the right spot.", to, closest_dist); - LogFile->write(EQEMuLog::Status, ". %f x %f y %f z ", x, y, z); + LogFile->write(EQEMuLog::Status, ". %s", to_string(location).c_str()); } if(closest_dist > max_distance2) closest_zp = nullptr; if(!closest_zp) - closest_zp = GetClosestZonePointWithoutZone(x, y, z, client); + closest_zp = GetClosestZonePointWithoutZone(location.m_X, location.m_Y, location.m_Z, client); return closest_zp; } @@ -1583,7 +1579,7 @@ ZonePoint* Zone::GetClosestZonePoint(float x, float y, float z, uint32 to, Clien ZonePoint* Zone::GetClosestZonePoint(const xyz_location& location, const char* to_name, Client* client, float max_distance) { if(to_name == nullptr) return GetClosestZonePointWithoutZone(location.m_X, location.m_Y, location.m_Z, client, max_distance); - return GetClosestZonePoint(location.m_X, location.m_Y, location.m_Z, database.GetZoneID(to_name), client, max_distance); + return GetClosestZonePoint(location, database.GetZoneID(to_name), client, max_distance); } ZonePoint* Zone::GetClosestZonePointWithoutZone(float x, float y, float z, Client* client, float max_distance) { diff --git a/zone/zone.h b/zone/zone.h index 4716b3757..b4adf09f2 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -128,7 +128,7 @@ public: uint32 CountSpawn2(); ZonePoint* GetClosestZonePoint(const xyz_location& location, const char* to_name, Client *client, float max_distance = 40000.0f); - ZonePoint* GetClosestZonePoint(float x, float y, float z, uint32 to, Client *client, float max_distance = 40000.0f); + ZonePoint* GetClosestZonePoint(const xyz_location& location, uint32 to, Client *client, float max_distance = 40000.0f); ZonePoint* GetClosestZonePointWithoutZone(float x, float y, float z, Client *client, float max_distance = 40000.0f); SpawnGroupList spawn_group_list; diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 4a22746c8..1f83ca76d 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -121,7 +121,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { return; } - zone_point = zone->GetClosestZonePoint(GetX(), GetY(), GetZ(), target_zone_id, this, ZONEPOINT_ZONE_RANGE); + zone_point = zone->GetClosestZonePoint(GetPosition(), target_zone_id, this, ZONEPOINT_ZONE_RANGE); //if we didnt get a zone point, or its to a different zone, //then we assume this is invalid. if(!zone_point || zone_point->target_zone_id != target_zone_id) { From ea7453946ceac8f2025cf103af88ed88c5eeb98e Mon Sep 17 00:00:00 2001 From: RicardoCampos Date: Tue, 13 Jan 2015 21:47:51 +0000 Subject: [PATCH 104/253] Altered the way that start zone overrides work. These now no longer use an entry in the variables table, but rather use TitaniumStartZoneID, and SofStartZoneID in the rule_values table. If this is set, it will look for a match in the start_zones based on race/class/deity and the zone id. If it finds a matching row (by zone_id), it will use that row's details. If not, it will use a default. --- common/ruletypes.h | 1 + world/client.cpp | 42 +++---- world/worlddb.cpp | 266 +++++++++++++++++++-------------------------- world/worlddb.h | 9 +- 4 files changed, 137 insertions(+), 181 deletions(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index c5a4bb562..79e28c143 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -165,6 +165,7 @@ RULE_INT ( World, ExemptAccountLimitStatus, -1 ) //Min status required to be exe RULE_BOOL ( World, GMAccountIPList, false) // Check ip list against GM Accounts, AntiHack GM Accounts. RULE_INT ( World, MinGMAntiHackStatus, 1 ) //Minimum GM status to check against AntiHack list RULE_INT ( World, SoFStartZoneID, -1 ) //Sets the Starting Zone for SoF Clients separate from Titanium Clients (-1 is disabled) +RULE_INT ( World, TitaniumStartZoneID, -1) //Sets the Starting Zone for Titanium Clients (-1 is disabled). Replaces the old method. RULE_INT ( World, ExpansionSettings, 16383) // Sets the expansion settings for the server, This is sent on login to world and affects client expansion settings. Defaults to all expansions enabled up to TSS. RULE_INT ( World, PVPSettings, 0) // Sets the PVP settings for the server, 1 = Rallos Zek RuleSet, 2 = Tallon/Vallon Zek Ruleset, 4 = Sullon Zek Ruleset, 6 = Discord Ruleset, anything above 6 is the Discord Ruleset without the no-drop restrictions removed. TODO: Edit IsAttackAllowed in Zone to accomodate for these rules. RULE_BOOL (World, IsGMPetitionWindowEnabled, false) diff --git a/world/client.cpp b/world/client.cpp index 01130302d..1ceca8284 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -1439,33 +1439,27 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) pp.pvp = database.GetServerType() == 1 ? 1 : 0; /* If it is an SoF Client and the SoF Start Zone rule is set, send new chars there */ - if (ClientVersionBit & BIT_SoFAndLater && RuleI(World, SoFStartZoneID) > 0) { + if (ClientVersionBit & BIT_SoFAndLater) { clog(WORLD__CLIENT,"Found 'SoFStartZoneID' rule setting: %i", RuleI(World, SoFStartZoneID)); - pp.zone_id = RuleI(World, SoFStartZoneID); - if (pp.zone_id) - database.GetSafePoints(pp.zone_id, 0, &pp.x, &pp.y, &pp.z); - else - clog(WORLD__CLIENT_ERR,"Error getting zone id for Zone ID %i", RuleI(World, SoFStartZoneID)); - } else { - /* if there's a startzone variable put them in there */ - if (database.GetVariable("startzone", startzone, 50)) { - clog(WORLD__CLIENT,"Found 'startzone' variable setting: %s", startzone); - pp.zone_id = database.GetZoneID(startzone); - if (pp.zone_id) - database.GetSafePoints(pp.zone_id, 0, &pp.x, &pp.y, &pp.z); - else - clog(WORLD__CLIENT_ERR,"Error getting zone id for '%s'", startzone); - } else { /* otherwise use normal starting zone logic */ - bool ValidStartZone = false; - if (ClientVersionBit & BIT_TitaniumAndEarlier) - ValidStartZone = database.GetStartZone(&pp, cc); - else - ValidStartZone = database.GetStartZoneSoF(&pp, cc); - - if (!ValidStartZone) - return false; + if (RuleI(World, SoFStartZoneID) > 0) { + pp.zone_id = RuleI(World, SoFStartZoneID); + cc->start_zone = pp.zone_id; } } + else { + clog(WORLD__CLIENT, "Found 'TitaniumStartZoneID' rule setting: %i", RuleI(World, TitaniumStartZoneID)); + if (RuleI(World, TitaniumStartZoneID) > 0) { /* if there's a startzone variable put them in there */ + + pp.zone_id = RuleI(World, TitaniumStartZoneID); + cc->start_zone = pp.zone_id; + } + } + /* use normal starting zone logic to either get defaults, or if startzone was set, load that from the db table.*/ + bool ValidStartZone = database.GetStartZone(&pp, cc, ClientVersionBit & BIT_TitaniumAndEarlier); + + if (!ValidStartZone){ + return false; + } /* just in case */ if (!pp.zone_id) { diff --git a/world/worlddb.cpp b/world/worlddb.cpp index 91406b527..73a7a284b 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -282,117 +282,38 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) { return zone_id; } -bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc) + + +bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc,bool isTitanium) { + // SoF doesn't send the player_choice field in character creation, it now sends the real zoneID instead. + // + // For SoF, search for an entry in start_zones with a matching zone_id, class, race and deity. + // + // For now, if no row matching row is found, send them to Crescent Reach, as that is probably the most likely + // reason for no match being found. + // if(!in_pp || !in_cc) return false; in_pp->x = in_pp->y = in_pp->z = in_pp->heading = in_pp->zone_id = 0; in_pp->binds[0].x = in_pp->binds[0].y = in_pp->binds[0].z = in_pp->binds[0].zoneId = in_pp->binds[0].instance_id = 0; - std::string query = StringFormat("SELECT x, y, z, heading, zone_id, bind_id " - "FROM start_zones WHERE player_choice = % i " - "AND player_class = %i AND player_deity = %i " - "AND player_race = %i", - in_cc->start_zone, in_cc->class_, in_cc->deity, - in_cc->race); + //this is wrong. if start_zone is set we should use that id + std::string query = StringFormat("SELECT x, y, z, heading, start_zone, bind_id FROM start_zones WHERE zone_id = %i " + "AND player_class = %i AND player_deity = %i AND player_race = %i", + in_cc->start_zone, in_cc->class_, in_cc->deity, in_cc->race); auto results = QueryDatabase(query); if(!results.Success()) { - LogFile->write(EQEmuLog::Error, "Start zone query failed: %s : %s\n", query.c_str(), results.ErrorMessage().c_str()); + LogFile->write(EQEmuLog::Status, "SoF Start zone query failed: %s : %s\n", query.c_str(), results.ErrorMessage().c_str()); return false; } - LogFile->write(EQEmuLog::Status, "Start zone query: %s\n", query.c_str()); + LogFile->write(EQEmuLog::Status, "SoF Start zone query: %s\n", query.c_str()); if (results.RowCount() == 0) { printf("No start_zones entry in database, using defaults\n"); - switch(in_cc->start_zone) - { - case 0: - { - in_pp->zone_id = 24; // erudnext - in_pp->binds[0].zoneId = 38; // tox - break; - } - case 1: - { - in_pp->zone_id = 2; // qeynos2 - in_pp->binds[0].zoneId = 2; // qeynos2 - break; - } - case 2: - { - in_pp->zone_id = 29; // halas - in_pp->binds[0].zoneId = 30; // everfrost - break; - } - case 3: - { - in_pp->zone_id = 19; // rivervale - in_pp->binds[0].zoneId = 20; // kithicor - break; - } - case 4: - { - in_pp->zone_id = 9; // freportw - in_pp->binds[0].zoneId = 9; // freportw - break; - } - case 5: - { - in_pp->zone_id = 40; // neriaka - in_pp->binds[0].zoneId = 25; // nektulos - break; - } - case 6: - { - in_pp->zone_id = 52; // gukta - in_pp->binds[0].zoneId = 46; // innothule - break; - } - case 7: - { - in_pp->zone_id = 49; // oggok - in_pp->binds[0].zoneId = 47; // feerrott - break; - } - case 8: - { - in_pp->zone_id = 60; // kaladima - in_pp->binds[0].zoneId = 68; // butcher - break; - } - case 9: - { - in_pp->zone_id = 54; // gfaydark - in_pp->binds[0].zoneId = 54; // gfaydark - break; - } - case 10: - { - in_pp->zone_id = 61; // felwithea - in_pp->binds[0].zoneId = 54; // gfaydark - break; - } - case 11: - { - in_pp->zone_id = 55; // akanon - in_pp->binds[0].zoneId = 56; // steamfont - break; - } - case 12: - { - in_pp->zone_id = 82; // cabwest - in_pp->binds[0].zoneId = 78; // fieldofbone - break; - } - case 13: - { - in_pp->zone_id = 155; // sharvahl - in_pp->binds[0].zoneId = 155; // sharvahl - break; - } - } + isTitanium ? SetTitaniumDefaultStartZone(in_pp, in_cc) : SetSoFDefaultStartZone(in_pp, in_cc); } else { LogFile->write(EQEmuLog::Status, "Found starting location in start_zones"); @@ -413,65 +334,106 @@ bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* return true; } - -bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc) -{ - // SoF doesn't send the player_choice field in character creation, it now sends the real zoneID instead. - // - // For SoF, search for an entry in start_zones with a matching zone_id, class, race and deity. - // - // For now, if no row matching row is found, send them to Crescent Reach, as that is probably the most likely - // reason for no match being found. - // - if(!in_pp || !in_cc) - return false; - - in_pp->x = in_pp->y = in_pp->z = in_pp->heading = in_pp->zone_id = 0; - in_pp->binds[0].x = in_pp->binds[0].y = in_pp->binds[0].z = in_pp->binds[0].zoneId = in_pp->binds[0].instance_id = 0; - - std::string query = StringFormat("SELECT x, y, z, heading, bind_id FROM start_zones WHERE zone_id = %i " - "AND player_class = %i AND player_deity = %i AND player_race = %i", - in_cc->start_zone, in_cc->class_, in_cc->deity, in_cc->race); - auto results = QueryDatabase(query); - if(!results.Success()) { - LogFile->write(EQEmuLog::Status, "SoF Start zone query failed: %s : %s\n", query.c_str(), results.ErrorMessage().c_str()); - return false; - } - - LogFile->write(EQEmuLog::Status, "SoF Start zone query: %s\n", query.c_str()); - - if (results.RowCount() == 0) { - printf("No start_zones entry in database, using defaults\n"); - - if(in_cc->start_zone == RuleI(World, TutorialZoneID)) - in_pp->zone_id = in_cc->start_zone; - else { - in_pp->x = in_pp->binds[0].x = -51; - in_pp->y = in_pp->binds[0].y = -20; - in_pp->z = in_pp->binds[0].z = 0.79; - in_pp->zone_id = in_pp->binds[0].zoneId = 394; // Crescent Reach. - } - } - else { - LogFile->write(EQEmuLog::Status, "Found starting location in start_zones"); - auto row = results.begin(); - in_pp->x = atof(row[0]); - in_pp->y = atof(row[1]); - in_pp->z = atof(row[2]); - in_pp->heading = atof(row[3]); +void WorldDatabase::SetSoFDefaultStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc){ + if (in_cc->start_zone == RuleI(World, TutorialZoneID)) in_pp->zone_id = in_cc->start_zone; - in_pp->binds[0].zoneId = atoi(row[4]); + else { + in_pp->x = in_pp->binds[0].x = -51; + in_pp->y = in_pp->binds[0].y = -20; + in_pp->z = in_pp->binds[0].z = 0.79; + in_pp->zone_id = in_pp->binds[0].zoneId = 394; // Crescent Reach. + } +} +void WorldDatabase::SetTitaniumDefaultStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc) +{ + switch (in_cc->start_zone) + { + case 0: + { + in_pp->zone_id = 24; // erudnext + in_pp->binds[0].zoneId = 38; // tox + break; + } + case 1: + { + in_pp->zone_id = 2; // qeynos2 + in_pp->binds[0].zoneId = 2; // qeynos2 + break; + } + case 2: + { + in_pp->zone_id = 29; // halas + in_pp->binds[0].zoneId = 30; // everfrost + break; + } + case 3: + { + in_pp->zone_id = 19; // rivervale + in_pp->binds[0].zoneId = 20; // kithicor + break; + } + case 4: + { + in_pp->zone_id = 9; // freportw + in_pp->binds[0].zoneId = 9; // freportw + break; + } + case 5: + { + in_pp->zone_id = 40; // neriaka + in_pp->binds[0].zoneId = 25; // nektulos + break; + } + case 6: + { + in_pp->zone_id = 52; // gukta + in_pp->binds[0].zoneId = 46; // innothule + break; + } + case 7: + { + in_pp->zone_id = 49; // oggok + in_pp->binds[0].zoneId = 47; // feerrott + break; + } + case 8: + { + in_pp->zone_id = 60; // kaladima + in_pp->binds[0].zoneId = 68; // butcher + break; + } + case 9: + { + in_pp->zone_id = 54; // gfaydark + in_pp->binds[0].zoneId = 54; // gfaydark + break; + } + case 10: + { + in_pp->zone_id = 61; // felwithea + in_pp->binds[0].zoneId = 54; // gfaydark + break; + } + case 11: + { + in_pp->zone_id = 55; // akanon + in_pp->binds[0].zoneId = 56; // steamfont + break; + } + case 12: + { + in_pp->zone_id = 82; // cabwest + in_pp->binds[0].zoneId = 78; // fieldofbone + break; + } + case 13: + { + in_pp->zone_id = 155; // sharvahl + in_pp->binds[0].zoneId = 155; // sharvahl + break; + } } - - if(in_pp->x == 0 && in_pp->y == 0 && in_pp->z == 0) - database.GetSafePoints(in_pp->zone_id, 0, &in_pp->x, &in_pp->y, &in_pp->z); - - if(in_pp->binds[0].x == 0 && in_pp->binds[0].y == 0 && in_pp->binds[0].z == 0) - database.GetSafePoints(in_pp->binds[0].zoneId, 0, &in_pp->binds[0].x, &in_pp->binds[0].y, &in_pp->binds[0].z); - - return true; } - void WorldDatabase::GetLauncherList(std::vector &rl) { rl.clear(); diff --git a/world/worlddb.h b/world/worlddb.h index ecb39ef61..166248e72 100644 --- a/world/worlddb.h +++ b/world/worlddb.h @@ -28,9 +28,7 @@ struct CharacterSelect_Struct; class WorldDatabase : public SharedDatabase { public: - bool GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc); - bool GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc); - + bool GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc, bool isTitanium); void GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*, uint32 ClientVersion); int MoveCharacterToBind(int CharID, uint8 bindnum = 0); @@ -40,8 +38,9 @@ public: bool LoadCharacterCreateAllocations(); bool LoadCharacterCreateCombos(); -protected: - +private: + void SetTitaniumDefaultStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc); + void SetSoFDefaultStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc); }; extern WorldDatabase database; From 75501fbb5d54194a27a42e824823553436ffb72b Mon Sep 17 00:00:00 2001 From: ricardocampos23 Date: Thu, 15 Jan 2015 21:03:06 +0000 Subject: [PATCH 105/253] corrected comment --- world/worlddb.cpp | 177 +++++++++++++++++++++++----------------------- 1 file changed, 88 insertions(+), 89 deletions(-) diff --git a/world/worlddb.cpp b/world/worlddb.cpp index 73a7a284b..988b7b32c 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -282,8 +282,6 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) { return zone_id; } - - bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc,bool isTitanium) { // SoF doesn't send the player_choice field in character creation, it now sends the real zoneID instead. @@ -298,8 +296,7 @@ bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_pp->x = in_pp->y = in_pp->z = in_pp->heading = in_pp->zone_id = 0; in_pp->binds[0].x = in_pp->binds[0].y = in_pp->binds[0].z = in_pp->binds[0].zoneId = in_pp->binds[0].instance_id = 0; - - //this is wrong. if start_zone is set we should use that id + // see if we have an entry for start_zone. We can support both titanium & SOF+ by having two entries per class/race/deity combo with different zone_ids std::string query = StringFormat("SELECT x, y, z, heading, start_zone, bind_id FROM start_zones WHERE zone_id = %i " "AND player_class = %i AND player_deity = %i AND player_race = %i", in_cc->start_zone, in_cc->class_, in_cc->deity, in_cc->race); @@ -335,8 +332,9 @@ bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* return true; } void WorldDatabase::SetSoFDefaultStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc){ - if (in_cc->start_zone == RuleI(World, TutorialZoneID)) + if (in_cc->start_zone == RuleI(World, TutorialZoneID)) { in_pp->zone_id = in_cc->start_zone; + } else { in_pp->x = in_pp->binds[0].x = -51; in_pp->y = in_pp->binds[0].y = -20; @@ -344,94 +342,95 @@ void WorldDatabase::SetSoFDefaultStartZone(PlayerProfile_Struct* in_pp, CharCrea in_pp->zone_id = in_pp->binds[0].zoneId = 394; // Crescent Reach. } } + void WorldDatabase::SetTitaniumDefaultStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc) { switch (in_cc->start_zone) { - case 0: - { - in_pp->zone_id = 24; // erudnext - in_pp->binds[0].zoneId = 38; // tox - break; - } - case 1: - { - in_pp->zone_id = 2; // qeynos2 - in_pp->binds[0].zoneId = 2; // qeynos2 - break; - } - case 2: - { - in_pp->zone_id = 29; // halas - in_pp->binds[0].zoneId = 30; // everfrost - break; - } - case 3: - { - in_pp->zone_id = 19; // rivervale - in_pp->binds[0].zoneId = 20; // kithicor - break; - } - case 4: - { - in_pp->zone_id = 9; // freportw - in_pp->binds[0].zoneId = 9; // freportw - break; - } - case 5: - { - in_pp->zone_id = 40; // neriaka - in_pp->binds[0].zoneId = 25; // nektulos - break; - } - case 6: - { - in_pp->zone_id = 52; // gukta - in_pp->binds[0].zoneId = 46; // innothule - break; - } - case 7: - { - in_pp->zone_id = 49; // oggok - in_pp->binds[0].zoneId = 47; // feerrott - break; - } - case 8: - { - in_pp->zone_id = 60; // kaladima - in_pp->binds[0].zoneId = 68; // butcher - break; - } - case 9: - { - in_pp->zone_id = 54; // gfaydark - in_pp->binds[0].zoneId = 54; // gfaydark - break; - } - case 10: - { - in_pp->zone_id = 61; // felwithea - in_pp->binds[0].zoneId = 54; // gfaydark - break; - } - case 11: - { - in_pp->zone_id = 55; // akanon - in_pp->binds[0].zoneId = 56; // steamfont - break; - } - case 12: - { - in_pp->zone_id = 82; // cabwest - in_pp->binds[0].zoneId = 78; // fieldofbone - break; - } - case 13: - { - in_pp->zone_id = 155; // sharvahl - in_pp->binds[0].zoneId = 155; // sharvahl - break; - } + case 0: + { + in_pp->zone_id = 24; // erudnext + in_pp->binds[0].zoneId = 38; // tox + break; + } + case 1: + { + in_pp->zone_id = 2; // qeynos2 + in_pp->binds[0].zoneId = 2; // qeynos2 + break; + } + case 2: + { + in_pp->zone_id = 29; // halas + in_pp->binds[0].zoneId = 30; // everfrost + break; + } + case 3: + { + in_pp->zone_id = 19; // rivervale + in_pp->binds[0].zoneId = 20; // kithicor + break; + } + case 4: + { + in_pp->zone_id = 9; // freportw + in_pp->binds[0].zoneId = 9; // freportw + break; + } + case 5: + { + in_pp->zone_id = 40; // neriaka + in_pp->binds[0].zoneId = 25; // nektulos + break; + } + case 6: + { + in_pp->zone_id = 52; // gukta + in_pp->binds[0].zoneId = 46; // innothule + break; + } + case 7: + { + in_pp->zone_id = 49; // oggok + in_pp->binds[0].zoneId = 47; // feerrott + break; + } + case 8: + { + in_pp->zone_id = 60; // kaladima + in_pp->binds[0].zoneId = 68; // butcher + break; + } + case 9: + { + in_pp->zone_id = 54; // gfaydark + in_pp->binds[0].zoneId = 54; // gfaydark + break; + } + case 10: + { + in_pp->zone_id = 61; // felwithea + in_pp->binds[0].zoneId = 54; // gfaydark + break; + } + case 11: + { + in_pp->zone_id = 55; // akanon + in_pp->binds[0].zoneId = 56; // steamfont + break; + } + case 12: + { + in_pp->zone_id = 82; // cabwest + in_pp->binds[0].zoneId = 78; // fieldofbone + break; + } + case 13: + { + in_pp->zone_id = 155; // sharvahl + in_pp->binds[0].zoneId = 155; // sharvahl + break; + } } } void WorldDatabase::GetLauncherList(std::vector &rl) { From 4978999d78fbcd4b0c24692759f8a5331b0e8f06 Mon Sep 17 00:00:00 2001 From: Uleat Date: Fri, 16 Jan 2015 17:15:33 -0500 Subject: [PATCH 106/253] Pre-p'd a bot iter --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index bcc9a763c..a4780ddc8 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -8420,7 +8420,7 @@ void Bot::ProcessBotOwnerRefDelete(Mob* botOwner) { std::list BotList = entity_list.GetBotsByBotOwnerCharacterID(botOwner->CastToClient()->CharacterID()); if(!BotList.empty()) { - for(std::list::iterator botListItr = BotList.begin(); botListItr != BotList.end(); botListItr++) { + for(std::list::iterator botListItr = BotList.begin(); botListItr != BotList.end(); ++botListItr) { Bot* tempBot = *botListItr; if(tempBot) { From 0eb7eefcb539e75c59d8b3b5651d0cddd424596f Mon Sep 17 00:00:00 2001 From: Uleat Date: Fri, 16 Jan 2015 18:07:19 -0500 Subject: [PATCH 107/253] Fix for possible race/crash condition in ItemInst::ClearByFlags() --- common/item.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/item.cpp b/common/item.cpp index 044d55d3d..533a0817b 100644 --- a/common/item.cpp +++ b/common/item.cpp @@ -1710,9 +1710,17 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent) end = m_contents.end(); for (; cur != end;) { ItemInst* inst = cur->second; - if (inst == nullptr) + if (inst == nullptr) { + cur = m_contents.erase(cur); continue; + } + const Item_Struct* item = inst->GetItem(); + if (item == nullptr) { + cur = m_contents.erase(cur); + continue; + } + del = cur; ++cur; @@ -1723,6 +1731,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent) m_contents.erase(del->first); continue; } + // no 'break;' deletes 'byFlagNotSet' type - can't add at the moment because it really *breaks* the process somewhere case byFlagNotSet: if (item->NoDrop != 0) { safe_delete(inst); @@ -1740,6 +1749,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent) m_contents.erase(del->first); continue; } + // no 'break;' deletes 'byFlagNotSet' type - can't add at the moment because it really *breaks* the process somewhere case byFlagNotSet: if (item->NoRent != 0) { safe_delete(inst); From f9a7da61b8387a6496d167171ebdcfc8635dae0d Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 17 Jan 2015 16:18:09 -0500 Subject: [PATCH 108/253] Switch NUMHIT_ enum to a strongly typed enum --- zone/attack.cpp | 22 +++++++++++++--------- zone/bot.cpp | 6 +++--- zone/common.h | 24 ++++++++++++------------ zone/mob.cpp | 6 +++--- zone/mob.h | 2 +- zone/spell_effects.cpp | 14 +++++++------- zone/spells.cpp | 14 +++++++------- 7 files changed, 46 insertions(+), 42 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 8b9196adc..9f6011c52 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -3348,7 +3348,7 @@ int32 Mob::ReduceAllDamage(int32 damage) } } - CheckNumHitsRemaining(NUMHIT_IncomingDamage); + CheckNumHitsRemaining(NumHit::IncomingDamage); return(damage); } @@ -3464,10 +3464,10 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons } if (spell_id == SPELL_UNKNOWN && skill_used) { - CheckNumHitsRemaining(NUMHIT_IncomingHitAttempts); + CheckNumHitsRemaining(NumHit::IncomingHitAttempts); if (attacker) - attacker->CheckNumHitsRemaining(NUMHIT_OutgoingHitAttempts); + attacker->CheckNumHitsRemaining(NumHit::OutgoingHitAttempts); } if(attacker){ @@ -3544,7 +3544,7 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons } if (skill_used) - CheckNumHitsRemaining(NUMHIT_IncomingHitSuccess); + CheckNumHitsRemaining(NumHit::IncomingHitSuccess); if(IsClient() && CastToClient()->sneaking){ CastToClient()->sneaking = false; @@ -3917,7 +3917,8 @@ void Mob::TryDefensiveProc(const ItemInst* weapon, Mob *on, uint16 hand) { float chance = ProcChance * (static_cast(DefensiveProcs[i].chance)/100.0f); if (zone->random.Roll(chance)) { ExecWeaponProc(nullptr, DefensiveProcs[i].spellID, on); - CheckNumHitsRemaining(NUMHIT_DefensiveSpellProcs,0,DefensiveProcs[i].base_spellID); + CheckNumHitsRemaining(NumHit::DefensiveSpellProcs, 0, + DefensiveProcs[i].base_spellID); } } } @@ -4093,7 +4094,8 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on, "Spell proc %d procing spell %d (%.2f percent chance)", i, SpellProcs[i].spellID, chance); ExecWeaponProc(nullptr, SpellProcs[i].spellID, on); - CheckNumHitsRemaining(NUMHIT_OffensiveSpellProcs, 0, SpellProcs[i].base_spellID); + CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0, + SpellProcs[i].base_spellID); } else { mlog(COMBAT__PROCS, "Spell proc %d failed to proc %d (%.2f percent chance)", @@ -4109,7 +4111,8 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on, "Ranged proc %d procing spell %d (%.2f percent chance)", i, RangedProcs[i].spellID, chance); ExecWeaponProc(nullptr, RangedProcs[i].spellID, on); - CheckNumHitsRemaining(NUMHIT_OffensiveSpellProcs, 0, RangedProcs[i].base_spellID); + CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0, + RangedProcs[i].base_spellID); } else { mlog(COMBAT__PROCS, "Ranged proc %d failed to proc %d (%.2f percent chance)", @@ -4526,7 +4529,8 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui float final_chance = chance * (ProcMod / 100.0f); if (zone->random.Roll(final_chance)) { ExecWeaponProc(nullptr, proc_spell_id, on); - CheckNumHitsRemaining(NUMHIT_OffensiveSpellProcs,0, base_spell_id); + CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0, + base_spell_id); CanProc = false; break; } @@ -4772,7 +4776,7 @@ void Mob::CommonOutgoingHitSuccess(Mob* defender, int32 &damage, SkillUseTypes s ApplyMeleeDamageBonus(skillInUse, damage); damage += (damage * defender->GetSkillDmgTaken(skillInUse) / 100) + (GetSkillDmgAmt(skillInUse) + defender->GetFcDamageAmtIncoming(this, 0, true, skillInUse)); TryCriticalHit(defender, skillInUse, damage); - CheckNumHitsRemaining(NUMHIT_OutgoingHitSuccess); + CheckNumHitsRemaining(NumHit::OutgoingHitSuccess); } void Mob::CommonBreakInvisible() diff --git a/zone/bot.cpp b/zone/bot.cpp index a4780ddc8..eb919272a 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3184,7 +3184,7 @@ void Bot::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes return; if (damage > 0) - CheckNumHitsRemaining(NUMHIT_OutgoingHitSuccess); + CheckNumHitsRemaining(NumHit::OutgoingHitSuccess); if((skillinuse == SkillDragonPunch) && GetAA(aaDragonPunch) && zone->random.Int(0, 99) < 25){ SpellFinished(904, other, 10, 0, -1, spells[904].ResistDiff); @@ -6249,7 +6249,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b MeleeLifeTap(damage); if (damage > 0) - CheckNumHitsRemaining(NUMHIT_OutgoingHitSuccess); + CheckNumHitsRemaining(NumHit::OutgoingHitSuccess); //break invis when you attack if(invisible) { @@ -7707,7 +7707,7 @@ void Bot::DoSpecialAttackDamage(Mob *who, SkillUseTypes skill, int32 max_damage, if (HasDied()) return; if (max_damage > 0) - CheckNumHitsRemaining(NUMHIT_OutgoingHitSuccess); + CheckNumHitsRemaining(NumHit::OutgoingHitSuccess); //[AA Dragon Punch] value[0] = 100 for 25%, chance value[1] = skill if(aabonuses.SpecialAttackKBProc[0] && aabonuses.SpecialAttackKBProc[1] == skill){ diff --git a/zone/common.h b/zone/common.h index 45f3bdb09..3639f74a0 100644 --- a/zone/common.h +++ b/zone/common.h @@ -158,18 +158,18 @@ enum TradeState { TradeCompleting }; -enum { //Numhits type - NUMHIT_IncomingHitAttempts = 1, //Attempted incoming melee attacks (hit or miss) on YOU. - NUMHIT_OutgoingHitAttempts = 2, //Attempted outgoing melee attacks (hit or miss) on YOUR TARGET. - NUMHIT_IncomingSpells = 3, //Incoming detrimental spells - NUMHIT_OutgoingSpells = 4, //Outgoing deterimental spells - NUMHIT_OutgoingHitSuccess = 5, //Successful outgoing melee attack HIT on YOUR TARGET. - NUMHIT_IncomingHitSuccess = 6, //Successful incoming melee attack HIT on YOU. - NUMHIT_MatchingSpells = 7, //Any casted spell matching/triggering a focus effect. - NUMHIT_IncomingDamage = 8, //Successful incoming spell or melee dmg attack on YOU - NUMHIT_ReflectSpell = 9, //Incoming Reflected spells. - NUMHIT_DefensiveSpellProcs = 10, //Defensive buff procs - NUMHIT_OffensiveSpellProcs = 11 //Offensive buff procs +enum class NumHit { // Numhits type + IncomingHitAttempts = 1, // Attempted incoming melee attacks (hit or miss) on YOU. + OutgoingHitAttempts = 2, // Attempted outgoing melee attacks (hit or miss) on YOUR TARGET. + IncomingSpells = 3, // Incoming detrimental spells + OutgoingSpells = 4, // Outgoing detrimental spells + OutgoingHitSuccess = 5, // Successful outgoing melee attack HIT on YOUR TARGET. + IncomingHitSuccess = 6, // Successful incoming melee attack HIT on YOU. + MatchingSpells = 7, // Any casted spell matching/triggering a focus effect. + IncomingDamage = 8, // Successful incoming spell or melee dmg attack on YOU + ReflectSpell = 9, // Incoming Reflected spells. + DefensiveSpellProcs = 10, // Defensive buff procs + OffensiveSpellProcs = 11 // Offensive buff procs }; //this is our internal representation of the BUFF struct, can put whatever we want in it diff --git a/zone/mob.cpp b/zone/mob.cpp index 3ea572eb6..3c7243e03 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3383,7 +3383,7 @@ void Mob::TriggerOnCast(uint32 focus_spell, uint32 spell_id, bool aa_trigger) if(IsValidSpell(trigger_spell_id) && GetTarget()){ SpellFinished(trigger_spell_id, GetTarget(),10, 0, -1, spells[trigger_spell_id].ResistDiff); - CheckNumHitsRemaining(NUMHIT_MatchingSpells,-1, focus_spell); + CheckNumHitsRemaining(NumHit::MatchingSpells, -1, focus_spell); } } } @@ -3615,7 +3615,7 @@ int32 Mob::GetVulnerability(Mob* caster, uint32 spell_id, uint32 ticsremaining) value += tmp_focus; if (tmp_buffslot >= 0) - CheckNumHitsRemaining(NUMHIT_MatchingSpells, tmp_buffslot); + CheckNumHitsRemaining(NumHit::MatchingSpells, tmp_buffslot); } return value; } @@ -3720,7 +3720,7 @@ void Mob::TrySympatheticProc(Mob *target, uint32 spell_id) SpellFinished(focus_trigger, target, 10, 0, -1, spells[focus_trigger].ResistDiff); } - CheckNumHitsRemaining(NUMHIT_MatchingSpells, -1, focus_spell); + CheckNumHitsRemaining(NumHit::MatchingSpells, -1, focus_spell); } } diff --git a/zone/mob.h b/zone/mob.h index 2fc9a7287..515f484e1 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -282,7 +282,7 @@ public: int16 GetBuffSlotFromType(uint16 type); uint16 GetSpellIDFromSlot(uint8 slot); int CountDispellableBuffs(); - void CheckNumHitsRemaining(uint8 type, int32 buff_slot=-1, uint16 spell_id=SPELL_UNKNOWN); + void CheckNumHitsRemaining(NumHit type, int32 buff_slot = -1, uint16 spell_id = SPELL_UNKNOWN); bool HasNumhits() const { return has_numhits; } inline void Numhits(bool val) { has_numhits = val; } bool HasMGB() const { return has_MGB; } diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index cb21073ca..507c361dd 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -5645,7 +5645,7 @@ int16 NPC::GetFocusEffect(focusType type, uint16 spell_id) { return realTotal + realTotal2; } -void Mob::CheckNumHitsRemaining(uint8 type, int32 buff_slot, uint16 spell_id) +void Mob::CheckNumHitsRemaining(NumHit type, int32 buff_slot, uint16 spell_id) { /* Field 175 = numhits type @@ -5672,7 +5672,7 @@ void Mob::CheckNumHitsRemaining(uint8 type, int32 buff_slot, uint16 spell_id) if (IsValidSpell(spell_id)) { for (int d = 0; d < buff_max; d++) { if (buffs[d].spellid == spell_id && buffs[d].numhits > 0 && - spells[buffs[d].spellid].numhitstype == type) { + spells[buffs[d].spellid].numhitstype == static_cast(type)) { if (--buffs[d].numhits == 0) { CastOnNumHitFade(buffs[d].spellid); if (!TryFadeEffect(d)) @@ -5682,7 +5682,7 @@ void Mob::CheckNumHitsRemaining(uint8 type, int32 buff_slot, uint16 spell_id) } } } - } else if (type == NUMHIT_MatchingSpells) { + } else if (type == NumHit::MatchingSpells) { if (buff_slot >= 0) { if (--buffs[buff_slot].numhits == 0) { CastOnNumHitFade(buffs[buff_slot].spellid); @@ -5711,7 +5711,7 @@ void Mob::CheckNumHitsRemaining(uint8 type, int32 buff_slot, uint16 spell_id) } else { for (int d = 0; d < buff_max; d++) { if (IsValidSpell(buffs[d].spellid) && buffs[d].numhits > 0 && - spells[buffs[d].spellid].numhitstype == type) { + spells[buffs[d].spellid].numhitstype == static_cast(type)) { if (--buffs[d].numhits == 0) { CastOnNumHitFade(buffs[d].spellid); if (!TryFadeEffect(d)) @@ -5975,7 +5975,7 @@ int32 Mob::GetFcDamageAmtIncoming(Mob *caster, uint32 spell_id, bool use_skill, } if ((!limit_exists) || (limit_exists && skill_found)){ dmg += temp_dmg; - CheckNumHitsRemaining(NUMHIT_MatchingSpells,i); + CheckNumHitsRemaining(NumHit::MatchingSpells, i); } } @@ -5983,7 +5983,7 @@ int32 Mob::GetFcDamageAmtIncoming(Mob *caster, uint32 spell_id, bool use_skill, int32 focus = caster->CalcFocusEffect(focusFcDamageAmtIncoming, buffs[i].spellid, spell_id); if(focus){ dmg += focus; - CheckNumHitsRemaining(NUMHIT_MatchingSpells,i); + CheckNumHitsRemaining(NumHit::MatchingSpells, i); } } } @@ -6035,7 +6035,7 @@ int32 Mob::GetFocusIncoming(focusType type, int effect, Mob *caster, uint32 spel value = tmp_focus; if (tmp_buffslot >= 0) - CheckNumHitsRemaining(NUMHIT_MatchingSpells, tmp_buffslot); + CheckNumHitsRemaining(NumHit::MatchingSpells, tmp_buffslot); } diff --git a/zone/spells.cpp b/zone/spells.cpp index f749f062d..ef5dd165a 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -1268,7 +1268,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, uint16 slot, } if(IsClient()) { - CheckNumHitsRemaining(NUMHIT_MatchingSpells); + CheckNumHitsRemaining(NumHit::MatchingSpells); TrySympatheticProc(target, spell_id); } @@ -3573,7 +3573,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r if(IsEffectInSpell(buffs[b].spellid, SE_BlockNextSpellFocus)) { focus = CalcFocusEffect(focusBlockNextSpell, buffs[b].spellid, spell_id); if(focus) { - CheckNumHitsRemaining(NUMHIT_MatchingSpells,b); + CheckNumHitsRemaining(NumHit::MatchingSpells, b); Message_StringID(MT_SpellFailure, SPELL_WOULDNT_HOLD); safe_delete(action_packet); return false; @@ -3622,7 +3622,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r } if(reflect_chance) { Message_StringID(MT_Spells, SPELL_REFLECT, GetCleanName(), spelltar->GetCleanName()); - CheckNumHitsRemaining(NUMHIT_ReflectSpell); + CheckNumHitsRemaining(NumHit::ReflectSpell); SpellOnTarget(spell_id, this, true, use_resist_adjust, resist_adjust); safe_delete(action_packet); return false; @@ -3673,8 +3673,8 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r } } - spelltar->CheckNumHitsRemaining(NUMHIT_IncomingSpells); - CheckNumHitsRemaining(NUMHIT_OutgoingSpells); + spelltar->CheckNumHitsRemaining(NumHit::IncomingSpells); + CheckNumHitsRemaining(NumHit::OutgoingSpells); safe_delete(action_packet); return false; @@ -3732,10 +3732,10 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r if (IsDetrimentalSpell(spell_id)) { - CheckNumHitsRemaining(NUMHIT_OutgoingSpells); + CheckNumHitsRemaining(NumHit::OutgoingSpells); if (spelltar) - spelltar->CheckNumHitsRemaining(NUMHIT_IncomingSpells); + spelltar->CheckNumHitsRemaining(NumHit::IncomingSpells); } // send the action packet again now that the spell is successful From 53f3fbfb4d2c51c3b3a3cc71c33dce03f28e9785 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 14:16:23 -0800 Subject: [PATCH 109/253] 16 char copy not 32 --- zone/doors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index b6f529e91..152712c15 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -64,7 +64,7 @@ Doors::Doors(const Door* door) : close_timer.Disable(); - strn0cpy(dest_zone,door->dest_zone,32); + strn0cpy(dest_zone,door->dest_zone,16); dest_instance_id = door->dest_instance_id; is_ldon_door = door->is_ldon_door; From 136dee691ad6e5f4706dddcf345c11459159eeb4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 14:53:06 -0800 Subject: [PATCH 110/253] removed unused macro debug message --- zone/beacon.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/zone/beacon.cpp b/zone/beacon.cpp index c3988e866..aa44b2504 100644 --- a/zone/beacon.cpp +++ b/zone/beacon.cpp @@ -35,7 +35,7 @@ class Zone; #include "../common/races.h" #include "beacon.h" #include "entity.h" -#include "mob.h" +#include "mob.h" #ifdef BOTS @@ -68,19 +68,12 @@ Beacon::Beacon(Mob *at_mob, int lifetime) caster_id = 0; if(lifetime) - { remove_timer.Start(); - } -#ifdef SOLAR - entity_list.Message(0, 0, "Beacon being created at %0.2f %0.2f %0.2f heading %0.2f lifetime %d", GetX(), GetY(), GetZ(), GetHeading(), lifetime); -#endif } Beacon::~Beacon() { -#ifdef SOLAR - entity_list.Message(0, 0, "Beacon %d being removed at %0.2f %0.2f %0.2f heading %0.2f", GetID(), GetX(), GetY(), GetZ(), GetHeading()); -#endif + } bool Beacon::Process() From 9f8dad894c2755a27f4a8b9671bdcf1a9669fb73 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 15:22:46 -0800 Subject: [PATCH 111/253] Added 'GetTargetRingLocation' which will eventualy replace the individual GetTargetRing methods --- zone/mob.h | 1 + 1 file changed, 1 insertion(+) diff --git a/zone/mob.h b/zone/mob.h index 6e304c34a..89c3fc410 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -294,6 +294,7 @@ public: inline virtual uint32 GetNimbusEffect2() const { return nimbus_effect2; } inline virtual uint32 GetNimbusEffect3() const { return nimbus_effect3; } void RemoveNimbusEffect(int effectid); + inline const xyz_location& GetTargetRingLocation() const { return m_TargetRing; } inline float GetTargetRingX() const { return m_TargetRing.m_X; } inline float GetTargetRingY() const { return m_TargetRing.m_Y; } inline float GetTargetRingZ() const { return m_TargetRing.m_Z; } From e653a3943a11e9c7eb22f79ba8497f436c74a90b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 15:32:04 -0800 Subject: [PATCH 112/253] removed usage of mob distnoroot and used ComparativeDistance instead --- zone/effects.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zone/effects.cpp b/zone/effects.cpp index ec463bddf..0e71ca0eb 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -26,6 +26,7 @@ #include "string_ids.h" #include "worldserver.h" #include "zonedb.h" +#include "position.h" float Mob::GetActSpellRange(uint16 spell_id, float range, bool IsBard) { @@ -720,7 +721,7 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_ continue; if (spells[spell_id].targettype == ST_Ring) { - dist_targ = curmob->DistNoRoot(caster->GetTargetRingX(), caster->GetTargetRingY(), caster->GetTargetRingZ()); + dist_targ = ComparativeDistance(curmob->GetPosition(), caster->GetTargetRingLocation()); } else if (center) { dist_targ = center->DistNoRoot(*curmob); From 91b2e23e563f99b63ecaf6ec74327d9f5ea1e0f1 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 15:37:24 -0800 Subject: [PATCH 113/253] removed usage of mob->distnoroot and switched to ComparativeDistance --- zone/effects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/effects.cpp b/zone/effects.cpp index 0e71ca0eb..6206593ac 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -724,7 +724,7 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_ dist_targ = ComparativeDistance(curmob->GetPosition(), caster->GetTargetRingLocation()); } else if (center) { - dist_targ = center->DistNoRoot(*curmob); + dist_targ = ComparativeDistance(static_cast(curmob->GetPosition()), static_cast(center->GetPosition())); } if (dist_targ > dist2) //make sure they are in range From 70a9a4e7cdfa6d655f5e4c63129336e4bc5880e0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 15:42:58 -0800 Subject: [PATCH 114/253] Removed usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 6eb32b684..d62fd8880 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1558,7 +1558,7 @@ Client *EntityList::GetRandomClient(const xyz_location& location, float Distance for (auto it = client_list.begin();it != client_list.end(); ++it) - if ((it->second != ExcludeClient) && (it->second->DistNoRoot(location.m_X, location.m_Y, location.m_Z) <= Distance)) + if ((it->second != ExcludeClient) && (ComparativeDistance(it->second->GetPosition(), location) <= Distance)) ClientsInRange.push_back(it->second); if (ClientsInRange.empty()) From f1759421d1c28f33d5a28075b5c2bc6bc7a3c7a4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 15:51:26 -0800 Subject: [PATCH 115/253] Removed Mob::DistNoRoot(x,y,z) --- zone/mob.cpp | 10 ---------- zone/mob.h | 1 - 2 files changed, 11 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 1d2d7053e..4e2f3c9f2 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2302,16 +2302,6 @@ float Mob::DistNoRoot(const Mob &other) const { + (zDiff * zDiff) ); } -float Mob::DistNoRoot(float x, float y, float z) const { - float xDiff = x - m_Position.m_X; - float yDiff = y - m_Position.m_Y; - float zDiff = z - m_Position.m_Z; - - return ( (xDiff * xDiff) - + (yDiff * yDiff) - + (zDiff * zDiff) ); -} - float Mob::DistNoRootNoZ(float x, float y) const { float xDiff = x - m_Position.m_X; float yDiff = y - m_Position.m_Y; diff --git a/zone/mob.h b/zone/mob.h index 89c3fc410..2afcd4aa0 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -514,7 +514,6 @@ public: float Dist(const Mob &) const; float DistNoZ(const Mob &) const; float DistNoRoot(const Mob &) const; - float DistNoRoot(float x, float y, float z) const; float DistNoRootNoZ(float x, float y) const; float DistNoRootNoZ(const Mob &) const; static float GetReciprocalHeading(Mob* target); From 2eaeb38138e53d8abcb8a50e5fd9eebc4cd5b370 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 15:56:06 -0800 Subject: [PATCH 116/253] Removed a usage of Mob::Dist and used Distance instead --- zone/client.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zone/client.cpp b/zone/client.cpp index a988c04a6..ee48af831 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -40,6 +40,7 @@ extern volatile bool RunLoops; #include "../common/rulesys.h" #include "../common/string_util.h" #include "../common/data_verification.h" +#include "position.h" #include "net.h" #include "worldserver.h" #include "zonedb.h" @@ -3178,7 +3179,7 @@ void Client::Insight(uint32 t_id) Message(0,"This ability can only be used on NPCs."); return; } - if (Dist(*who) > 200) + if (Distance(static_cast(m_Position), static_cast(who->GetPosition())) > 200) { Message(0,"You must get closer to your target!"); return; From 77badffa299324ddf7e5b48187cd18036b8c8ad7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 16:00:12 -0800 Subject: [PATCH 117/253] Removed a usage of Mob::Dist and used Distance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 5cc3da16d..61a09094f 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3025,7 +3025,7 @@ void Client::Handle_OP_Assist(const EQApplicationPacket *app) if (assistee->GetTarget()) { Mob *new_target = assistee->GetTarget(); if (new_target && (GetGM() || - Dist(*assistee) <= TARGETING_RANGE)) { + Distance(static_cast(m_Position), static_cast(assistee->GetPosition())) <= TARGETING_RANGE)) { SetAssistExemption(true); eid->entity_id = new_target->GetID(); } From 6e06110b7552898c4a8328e1ef8470cced3b407b Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sat, 17 Jan 2015 19:03:13 -0500 Subject: [PATCH 118/253] Remove more extra and incorrect memsets --- zone/mob.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 1d2d7053e..d1e6ac7c5 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1524,7 +1524,6 @@ void Mob::SendIllusionPacket(uint16 in_race, uint8 in_gender, uint8 in_texture, } EQApplicationPacket* outapp = new EQApplicationPacket(OP_Illusion, sizeof(Illusion_Struct)); - memset(outapp->pBuffer, 0, sizeof(outapp->pBuffer)); Illusion_Struct* is = (Illusion_Struct*) outapp->pBuffer; is->spawnid = GetID(); strcpy(is->charname, GetCleanName()); @@ -1890,7 +1889,6 @@ void Mob::SendTargetable(bool on, Client *specific_target) { void Mob::QuestReward(Client *c, uint32 silver, uint32 gold, uint32 platinum) { EQApplicationPacket* outapp = new EQApplicationPacket(OP_Sound, sizeof(QuestReward_Struct)); - memset(outapp->pBuffer, 0, sizeof(outapp->pBuffer)); QuestReward_Struct* qr = (QuestReward_Struct*) outapp->pBuffer; qr->from_mob = GetID(); // Entity ID for the from mob name @@ -1910,7 +1908,6 @@ void Mob::CameraEffect(uint32 duration, uint32 intensity, Client *c, bool global if(global == true) { ServerPacket* pack = new ServerPacket(ServerOP_CameraShake, sizeof(ServerCameraShake_Struct)); - memset(pack->pBuffer, 0, sizeof(pack->pBuffer)); ServerCameraShake_Struct* scss = (ServerCameraShake_Struct*) pack->pBuffer; scss->duration = duration; scss->intensity = intensity; @@ -1920,7 +1917,6 @@ void Mob::CameraEffect(uint32 duration, uint32 intensity, Client *c, bool global } EQApplicationPacket* outapp = new EQApplicationPacket(OP_CameraEffect, sizeof(Camera_Struct)); - memset(outapp->pBuffer, 0, sizeof(outapp->pBuffer)); Camera_Struct* cs = (Camera_Struct*) outapp->pBuffer; cs->duration = duration; // Duration in milliseconds cs->intensity = ((intensity * 6710886) + 1023410176); // Intensity ranges from 1023410176 to 1090519040, so simplify it from 0 to 10. @@ -1936,7 +1932,6 @@ void Mob::CameraEffect(uint32 duration, uint32 intensity, Client *c, bool global void Mob::SendSpellEffect(uint32 effectid, uint32 duration, uint32 finish_delay, bool zone_wide, uint32 unk020, bool perm_effect, Client *c) { EQApplicationPacket* outapp = new EQApplicationPacket(OP_SpellEffect, sizeof(SpellEffect_Struct)); - memset(outapp->pBuffer, 0, sizeof(outapp->pBuffer)); SpellEffect_Struct* se = (SpellEffect_Struct*) outapp->pBuffer; se->EffectID = effectid; // ID of the Particle Effect se->EntityID = GetID(); @@ -1988,7 +1983,6 @@ void Mob::TempName(const char *newname) // Send the new name to all clients EQApplicationPacket* outapp = new EQApplicationPacket(OP_MobRename, sizeof(MobRename_Struct)); - memset(outapp->pBuffer, 0, sizeof(outapp->pBuffer)); MobRename_Struct* mr = (MobRename_Struct*) outapp->pBuffer; strn0cpy(mr->old_name, old_name, 64); strn0cpy(mr->old_name_again, old_name, 64); From a135a3d597fe9d9fdc1d9fa188c55ce935f0b6fe Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 16:08:45 -0800 Subject: [PATCH 119/253] Added explicit xyz_heading overrides for the 4 distance functions --- zone/effects.cpp | 4 ++-- zone/entity.cpp | 2 +- zone/position.cpp | 28 ++++++++++++++++++++++++++++ zone/position.h | 5 +++++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/zone/effects.cpp b/zone/effects.cpp index 6206593ac..d94f26159 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -721,10 +721,10 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_ continue; if (spells[spell_id].targettype == ST_Ring) { - dist_targ = ComparativeDistance(curmob->GetPosition(), caster->GetTargetRingLocation()); + dist_targ = ComparativeDistance(static_cast(curmob->GetPosition()), caster->GetTargetRingLocation()); } else if (center) { - dist_targ = ComparativeDistance(static_cast(curmob->GetPosition()), static_cast(center->GetPosition())); + dist_targ = ComparativeDistance(curmob->GetPosition(), center->GetPosition()); } if (dist_targ > dist2) //make sure they are in range diff --git a/zone/entity.cpp b/zone/entity.cpp index d62fd8880..7e3b925ca 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1558,7 +1558,7 @@ Client *EntityList::GetRandomClient(const xyz_location& location, float Distance for (auto it = client_list.begin();it != client_list.end(); ++it) - if ((it->second != ExcludeClient) && (ComparativeDistance(it->second->GetPosition(), location) <= Distance)) + if ((it->second != ExcludeClient) && (ComparativeDistance(static_cast(it->second->GetPosition()), location) <= Distance)) ClientsInRange.push_back(it->second); if (ClientsInRange.empty()) diff --git a/zone/position.cpp b/zone/position.cpp index ddbe429af..63c5b034f 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -145,6 +145,13 @@ float ComparativeDistance(const xyz_location& point1, const xyz_location& point2 return diff.m_X * diff.m_X + diff.m_Y * diff.m_Y + diff.m_Z * diff.m_Z; } +/** +* Produces the non square root'ed distance between the two points. +*/ +float ComparativeDistance(const xyz_heading& point1, const xyz_heading& point2) { + ComparativeDistance(static_cast(point1), static_cast(point2)); +} + /** * Produces the distance between the two points. */ @@ -152,6 +159,13 @@ float Distance(const xyz_location& point1, const xyz_location& point2) { return sqrt(ComparativeDistance(point1, point2)); } +/** +* Produces the distance between the two points. +*/ +float Distance(const xyz_heading& point1, const xyz_heading& point2) { + Distance(static_cast(point1), static_cast(point2)); +} + /** * Produces the distance between the two points within the XY plane. */ @@ -159,6 +173,13 @@ float DistanceNoZ(const xyz_location& point1, const xyz_location& point2) { return Distance(static_cast(point1),static_cast(point2)); } +/** +* Produces the distance between the two points within the XY plane. +*/ +float DistanceNoZ(const xyz_heading& point1, const xyz_heading& point2) { + return Distance(static_cast(point1),static_cast(point2)); +} + /** * Produces the non square root'ed distance between the two points within the XY plane. */ @@ -166,6 +187,13 @@ float ComparativeDistanceNoZ(const xyz_location& point1, const xyz_location& poi return ComparativeDistance(static_cast(point1),static_cast(point2)); } +/** +* Produces the non square root'ed distance between the two points within the XY plane. +*/ +float ComparativeDistanceNoZ(const xyz_heading& point1, const xyz_heading& point2) { + return ComparativeDistance(static_cast(point1),static_cast(point2)); +} + /** * Determines if 'position' is within (inclusive) the axis aligned * box (3 dimensional) formed from the points minimum and maximum. diff --git a/zone/position.h b/zone/position.h index fd66ede5f..30f8fcb1c 100644 --- a/zone/position.h +++ b/zone/position.h @@ -94,4 +94,9 @@ float Distance(const xyz_location& point1, const xyz_location& point2); float DistanceNoZ(const xyz_location& point1, const xyz_location& point2); float ComparativeDistanceNoZ(const xyz_location& point1, const xyz_location& point2); +float ComparativeDistance(const xyz_heading& point1, const xyz_heading& point2); +float Distance(const xyz_heading& point1, const xyz_heading& point2); +float DistanceNoZ(const xyz_heading& point1, const xyz_heading& point2); +float ComparativeDistanceNoZ(const xyz_heading& point1, const xyz_heading& point2); + #endif From 76afc1119902bb710e9e8914b9113a96d3c5e575 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 16:12:30 -0800 Subject: [PATCH 120/253] Overloads of xyz_heading means no longer need the static cast here --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 61a09094f..332a1cc98 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3025,7 +3025,7 @@ void Client::Handle_OP_Assist(const EQApplicationPacket *app) if (assistee->GetTarget()) { Mob *new_target = assistee->GetTarget(); if (new_target && (GetGM() || - Distance(static_cast(m_Position), static_cast(assistee->GetPosition())) <= TARGETING_RANGE)) { + Distance(m_Position, assistee->GetPosition()) <= TARGETING_RANGE)) { SetAssistExemption(true); eid->entity_id = new_target->GetID(); } From 1bd4d38537f37389168bcddc7b826e6b7d63d95d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 17:39:12 -0800 Subject: [PATCH 121/253] Removed usage of Mod::Dist and used Distance instead --- zone/command.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/command.cpp b/zone/command.cpp index ea527cbe8..3c42d00fb 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -10183,7 +10183,7 @@ void command_distance(Client *c, const Seperator *sep) { if(c && c->GetTarget()) { Mob* target = c->GetTarget(); - c->Message(0, "Your target, %s, is %1.1f units from you.", c->GetTarget()->GetName(), c->Dist(*target)); + c->Message(0, "Your target, %s, is %1.1f units from you.", c->GetTarget()->GetName(), Distance(c->GetPosition(), target->GetPosition())); } } From a60c37098cc540a3774baa8227b32e6ab190e144 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 17:41:26 -0800 Subject: [PATCH 122/253] Removed usage of Mod::Dist and used Distance instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 7e3b925ca..9884f825e 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1119,7 +1119,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; From 8895dd599e4d93b25e6078005320735f490456e4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 17:44:17 -0800 Subject: [PATCH 123/253] Removed usage of Mod::Dist and used Distance instead --- zone/entity.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 9884f825e..9cf0d45a5 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -2991,7 +2991,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; From ee0b9edc21720ec17563ad29203b3bd511351f36 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 17:49:16 -0800 Subject: [PATCH 124/253] Removed Mob::Dist --- zone/mob.cpp | 10 ---------- zone/mob.h | 1 - 2 files changed, 11 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 4e2f3c9f2..6b7db13b2 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2274,16 +2274,6 @@ bool Mob::CanThisClassBlock(void) const } } -float Mob::Dist(const Mob &other) const { - float xDiff = other.m_Position.m_X - m_Position.m_X; - float yDiff = other.m_Position.m_Y - m_Position.m_Y; - float zDiff = other.m_Position.m_Z - m_Position.m_Z; - - return sqrtf( (xDiff * xDiff) - + (yDiff * yDiff) - + (zDiff * zDiff) ); -} - float Mob::DistNoZ(const Mob &other) const { float xDiff = other.m_Position.m_X - m_Position.m_X; float yDiff = other.m_Position.m_Y - m_Position.m_Y; diff --git a/zone/mob.h b/zone/mob.h index 2afcd4aa0..d32777d8f 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -511,7 +511,6 @@ public: void ShowStats(Client* client); void ShowBuffs(Client* client); void ShowBuffList(Client* client); - float Dist(const Mob &) const; float DistNoZ(const Mob &) const; float DistNoRoot(const Mob &) const; float DistNoRootNoZ(float x, float y) const; From bff17cddf9d31805e7eae5f8a74f660d8eab411b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 17:50:08 -0800 Subject: [PATCH 125/253] Removed a usage of Mob::DistNoZ and used DistanceNoZ instead --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index e9d708d80..eeb005dd8 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -15811,7 +15811,7 @@ void EntityList::ShowSpawnWindow(Client* client, int Distance, bool NamedOnly) { for (auto it = mob_list.begin(); it != mob_list.end(); ++it) { curMob = it->second; - if (curMob && curMob->DistNoZ(*client)<=Distance) { + if (curMob && DistanceNoZ(curMob->GetPosition(), client->GetPosition()) <= Distance) { if(curMob->IsTrackable()) { Mob* cur_entity = curMob; int Extras = (cur_entity->IsBot() || cur_entity->IsPet() || cur_entity->IsFamiliar() || cur_entity->IsClient()); From 2d7297dc676c93005bf3dca955fbfcab3953d3b5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 17:51:52 -0800 Subject: [PATCH 126/253] Removed a usage of Mob::DistNoZ and used DistanceNoZ instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 9cf0d45a5..486a65972 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -2942,7 +2942,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; From 1e2198f5f4a760b8f4b0598568c77d2574e49533 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 17:53:41 -0800 Subject: [PATCH 127/253] Removed Mob::DistNoZ --- zone/mob.cpp | 8 -------- zone/mob.h | 1 - 2 files changed, 9 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 6b7db13b2..8b8a23747 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2274,14 +2274,6 @@ bool Mob::CanThisClassBlock(void) const } } -float Mob::DistNoZ(const Mob &other) const { - float xDiff = other.m_Position.m_X - m_Position.m_X; - float yDiff = other.m_Position.m_Y - m_Position.m_Y; - - return sqrtf( (xDiff * xDiff) - + (yDiff * yDiff) ); -} - float Mob::DistNoRoot(const Mob &other) const { float xDiff = other.m_Position.m_X - m_Position.m_X; float yDiff = other.m_Position.m_Y - m_Position.m_Y; diff --git a/zone/mob.h b/zone/mob.h index d32777d8f..c78eee65c 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -511,7 +511,6 @@ public: void ShowStats(Client* client); void ShowBuffs(Client* client); void ShowBuffList(Client* client); - float DistNoZ(const Mob &) const; float DistNoRoot(const Mob &) const; float DistNoRootNoZ(float x, float y) const; float DistNoRootNoZ(const Mob &) const; From eb2eaa4d68a07deea4240dfbbbbd42d6e8f47ae3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 17:57:36 -0800 Subject: [PATCH 128/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/aggro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index b2b3881bb..847840b50 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -88,7 +88,7 @@ void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbo if (mob->IsClient()) //also ensures that mob != around continue; - if (mob->DistNoRoot(*from_who) > d2) + if (ComparativeDistance(mob->GetPosition(), from_who->GetPosition()) > d2) continue; if (engaged) { From f1937335dd4675a49b3089147804c09137d7f531 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:01:20 -0800 Subject: [PATCH 129/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/aggro.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 847840b50..918b7de10 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -150,7 +150,8 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { return; } - float dist2 = mob->DistNoRoot(*this); + float dist2 = ComparativeDistance(mob->GetPosition(), m_Position); + float iAggroRange2 = iAggroRange*iAggroRange; if( dist2 > iAggroRange2 ) { towho->Message(0, "...%s is out of range. %.3f > %.3f ", mob->GetName(), From 254ec5997cdcea9ce6563fe2063ae0674c3575ef Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:05:03 -0800 Subject: [PATCH 130/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/aggro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 918b7de10..f68c77efa 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -296,7 +296,7 @@ bool Mob::CheckWillAggro(Mob *mob) { return(false); } - float dist2 = mob->DistNoRoot(*this); + float dist2 = ComparativeDistance(mob->GetPosition(), m_Position); float iAggroRange2 = iAggroRange*iAggroRange; if( dist2 > iAggroRange2 ) { From f43bf5542f1f04ecde6bd7e932a28fe2c4d5ed73 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:07:16 -0800 Subject: [PATCH 131/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/aggro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index f68c77efa..c0bd53d67 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -414,7 +414,7 @@ int EntityList::GetHatedCount(Mob *attacker, Mob *exclude) AggroRange *= AggroRange; - if (mob->DistNoRoot(*attacker) > AggroRange) + if (ComparativeDistance(mob->GetPosition(), attacker->GetPosition()) > AggroRange) continue; Count++; From f79bad8b4bbb0f562ed611d155875d3949c8e66b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:09:43 -0800 Subject: [PATCH 132/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/aggro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index c0bd53d67..98135153c 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -444,7 +444,7 @@ void EntityList::AIYellForHelp(Mob* sender, Mob* attacker) { // && !mob->IsCorpse() // && mob->IsAIControlled() && mob->GetPrimaryFaction() != 0 - && mob->DistNoRoot(*sender) <= r + && ComparativeDistance(mob->GetPosition(), sender->GetPosition()) <= r && !mob->IsEngaged() && ((!mob->IsPet()) || (mob->IsPet() && mob->GetOwner() && !mob->GetOwner()->IsClient())) // If we're a pet we don't react to any calls for help if our owner is a client From 64bd24d5f9a2d714532351533854f21aa3f94992 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:13:34 -0800 Subject: [PATCH 133/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/aggro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 98135153c..c3861f13e 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -471,7 +471,7 @@ void EntityList::AIYellForHelp(Mob* sender, Mob* attacker) { if(mob->CheckLosFN(sender)) { #if (EQDEBUG>=5) LogFile->write(EQEmuLog::Debug, "AIYellForHelp(\"%s\",\"%s\") %s attacking %s Dist %f Z %f", - sender->GetName(), attacker->GetName(), mob->GetName(), attacker->GetName(), mob->DistNoRoot(*sender), fabs(sender->GetZ()+mob->GetZ())); + sender->GetName(), attacker->GetName(), mob->GetName(), attacker->GetName(), ComparativeDistance(mob->GetPosition(), sender->GetPosition()), fabs(sender->GetZ()+mob->GetZ())); #endif mob->AddToHateList(attacker, 1, 0, false); } From 262ae383c9ef5e9ef13edcad7bfc04f47305d8ef Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:15:48 -0800 Subject: [PATCH 134/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/aggro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index c3861f13e..7e8080cc7 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -878,7 +878,7 @@ bool Mob::CombatRange(Mob* other) if (size_mod > 10000) size_mod = size_mod / 7; - float _DistNoRoot = DistNoRoot(*other); + float _DistNoRoot = ComparativeDistance(m_Position, other->GetPosition()); if (GetSpecialAbility(NPC_CHASE_DISTANCE)){ From 815a2084928841a83c52c24521fe94febb36a310 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:18:35 -0800 Subject: [PATCH 135/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index eeb005dd8..e368364b6 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3505,7 +3505,7 @@ void Bot::AI_Process() { if(IsBotCasterCombatRange(GetTarget())) atCombatRange = true; } - else if(DistNoRoot(*GetTarget()) <= meleeDistance) { + else if(ComparativeDistance(m_Position, GetTarget()->GetPosition()) <= meleeDistance) { atCombatRange = true; } From d71fc61511c1249084a6584be9d646fc791c0546 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:20:29 -0800 Subject: [PATCH 136/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index e368364b6..e420f7a99 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3732,7 +3732,7 @@ void Bot::AI_Process() { Mob* follow = entity_list.GetMob(GetFollowID()); if(follow) { - float dist = DistNoRoot(*follow); + float dist = ComparativeDistance(m_Position, follow->GetPosition()); float speed = follow->GetRunspeed(); if(dist < GetFollowDistance() + 1000) From 86639f924d260e38d05d19407fb02a48d87c23f7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:22:48 -0800 Subject: [PATCH 137/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index e420f7a99..7326a9e42 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -4003,7 +4003,7 @@ void Bot::PetAIProcess() { switch(pStandingPetOrder) { case SPO_Follow: { - float dist = botPet->DistNoRoot(*botPet->GetTarget()); + float dist = ComparativeDistance(botPet->GetPosition(), botPet->GetTarget()->GetPosition()); botPet->SetRunAnimSpeed(0); if(dist > 184) { botPet->CalculateNewPosition2(botPet->GetTarget()->GetX(), botPet->GetTarget()->GetY(), botPet->GetTarget()->GetZ(), botPet->GetTarget()->GetRunspeed()); From 1303a297c014c113512351958a7731254381b4b2 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:26:14 -0800 Subject: [PATCH 138/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/botspellsai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index a5be7341e..68da92cae 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -898,7 +898,7 @@ bool Bot::AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgain if (AIspells[i].type & SpellType_Escape) { dist2 = 0; } else - dist2 = DistNoRoot(*tar); + dist2 = ComparativeDistance(m_Position, tar->GetPosition()); if (((((spells[AIspells[i].spellid].targettype==ST_GroupTeleport && AIspells[i].type==2) || spells[AIspells[i].spellid].targettype==ST_AECaster From 78eb852ed3c64d01e7a8b45e342aa3ff03b4be1d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:32:41 -0800 Subject: [PATCH 139/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client.cpp b/zone/client.cpp index ee48af831..cee43648e 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -2540,7 +2540,7 @@ bool Client::BindWound(Mob* bindmob, bool start, bool fail){ } else { - if (!GetFeigned() && (bindmob->DistNoRoot(*this) <= 400)) { + if (!GetFeigned() && (ComparativeDistance(bindmob->GetPosition(), m_Position) <= 400)) { // send bindmob bind done if(!bindmob->IsAIControlled() && bindmob != this ) { From 9400b860a3c0db8e8a0ced779fbe386bab2e87e7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:37:01 -0800 Subject: [PATCH 140/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 332a1cc98..2092998d3 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2030,7 +2030,7 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app) return; //you have to be somewhat close to them to be properly using them - if (DistNoRoot(*tmp) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2) return; merchantid = tmp->CastToNPC()->MerchantType; From e8144cb3eee888af37fa61e8d69132a84f14dc3d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:39:59 -0800 Subject: [PATCH 141/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 2092998d3..b2e8ec43c 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2205,7 +2205,7 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) return; //you have to be somewhat close to them to be properly using them - if (DistNoRoot(*tmp) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2) return; merchantid = tmp->CastToNPC()->MerchantType; From 65bd2cf8aca6c87bc936c674993cbd4030577494 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:42:59 -0800 Subject: [PATCH 142/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index b2e8ec43c..be8defcfc 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2296,7 +2296,7 @@ void Client::Handle_OP_AdventureMerchantSell(const EQApplicationPacket *app) return; } - if (DistNoRoot(*vendor) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, vendor->GetPosition()) > USE_NPC_RANGE2) { Message(13, "Vendor is out of range."); return; From 8efb9e75f89af3625e1fda042d9ca4acd5a0d2b1 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:49:24 -0800 Subject: [PATCH 143/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index be8defcfc..6faed0e44 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2554,7 +2554,7 @@ void Client::Handle_OP_AltCurrencyMerchantRequest(const EQApplicationPacket *app NPC* tar = entity_list.GetNPCByID(*((uint32*)app->pBuffer)); if (tar) { - if (DistNoRoot(*tar) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tar->GetPosition()) > USE_NPC_RANGE2) return; if (tar->GetClass() != ALT_CURRENCY_MERCHANT) { @@ -2633,7 +2633,7 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app) AltCurrencyPurchaseItem_Struct *purchase = (AltCurrencyPurchaseItem_Struct*)app->pBuffer; NPC* tar = entity_list.GetNPCByID(purchase->merchant_entity_id); if (tar) { - if (DistNoRoot(*tar) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tar->GetPosition())> USE_NPC_RANGE2) return; if (tar->GetClass() != ALT_CURRENCY_MERCHANT) { From e54cdad85d0d953c498a0485e683d0d3c2744dab Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:51:06 -0800 Subject: [PATCH 144/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 6faed0e44..4f2298344 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2770,7 +2770,7 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app) NPC* tar = entity_list.GetNPCByID(sell->merchant_entity_id); if (tar) { - if (DistNoRoot(*tar) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tar->GetPosition()) > USE_NPC_RANGE2) return; if (tar->GetClass() != ALT_CURRENCY_MERCHANT) { From 6b3099daac2aa5c8e026c1a3fb3a449f9e510ccf Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:54:57 -0800 Subject: [PATCH 145/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 4f2298344..0b8315b57 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2867,7 +2867,7 @@ void Client::Handle_OP_AltCurrencySellSelection(const EQApplicationPacket *app) AltCurrencySelectItem_Struct *select = (AltCurrencySelectItem_Struct*)app->pBuffer; NPC* tar = entity_list.GetNPCByID(select->merchant_entity_id); if (tar) { - if (DistNoRoot(*tar) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tar->GetPosition()) > USE_NPC_RANGE2) return; if (tar->GetClass() != ALT_CURRENCY_MERCHANT) { From 926cba2cdc2520162fb4627dcf6187e5938dc1c7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 18:57:52 -0800 Subject: [PATCH 146/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 0b8315b57..265a1625d 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9414,7 +9414,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) int mercTypeCount = 0; int mercCount = 0; - if (DistNoRoot(*tar) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tar->GetPosition()) > USE_NPC_RANGE2) return; if (tar->GetClass() != MERCERNARY_MASTER) { From 6f209fd8b9a9fc08494e91776275cded7541852a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 19:00:57 -0800 Subject: [PATCH 147/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 265a1625d..867a90156 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9796,7 +9796,7 @@ void Client::Handle_OP_OpenGuildTributeMaster(const EQApplicationPacket *app) StartTribute_Struct* st = (StartTribute_Struct*)app->pBuffer; Mob* tribmast = entity_list.GetMob(st->tribute_master_id); if (tribmast && tribmast->IsNPC() && tribmast->GetClass() == GUILD_TRIBUTE_MASTER - && DistNoRoot(*tribmast) <= USE_NPC_RANGE2) { + && ComparativeDistance(m_Position, tribmast->GetPosition()) <= USE_NPC_RANGE2) { st->response = 1; QueuePacket(app); tribute_master_id = st->tribute_master_id; From bcc4c1e4b6a28c8001165d696614a9b100ec7fca Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 19:07:25 -0800 Subject: [PATCH 148/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 867a90156..70917df1d 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9828,7 +9828,7 @@ void Client::Handle_OP_OpenTributeMaster(const EQApplicationPacket *app) StartTribute_Struct* st = (StartTribute_Struct*)app->pBuffer; Mob* tribmast = entity_list.GetMob(st->tribute_master_id); if (tribmast && tribmast->IsNPC() && tribmast->GetClass() == TRIBUTE_MASTER - && DistNoRoot(*tribmast) <= USE_NPC_RANGE2) { + && ComparativeDistance(m_Position, tribmast->GetPosition()) <= USE_NPC_RANGE2) { st->response = 1; QueuePacket(app); tribute_master_id = st->tribute_master_id; @@ -12102,7 +12102,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) if (mp->quantity < 1) return; //you have to be somewhat close to them to be properly using them - if (DistNoRoot(*tmp) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2) return; merchantid = tmp->CastToNPC()->MerchantType; From 6b979d1c5de8155d064b26b72fd2f7aca78407c9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 19:09:32 -0800 Subject: [PATCH 149/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 70917df1d..cdaf755b3 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -12351,7 +12351,7 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) return; //you have to be somewhat close to them to be properly using them - if (DistNoRoot(*vendor) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, vendor->GetPosition()) > USE_NPC_RANGE2) return; uint32 price = 0; From 80154d06615e8603fc42581a0fc01f6d7a04abe4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 19:13:47 -0800 Subject: [PATCH 150/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index cdaf755b3..f0e411923 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -12510,7 +12510,7 @@ void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app) return; //you have to be somewhat close to them to be properly using them - if (DistNoRoot(*tmp) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2) return; merchantid = tmp->CastToNPC()->MerchantType; From 0c3efc3c4ff29d9cdf6629bc71d5c14fb4b37a52 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 19:16:45 -0800 Subject: [PATCH 151/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index f0e411923..e9482f8b8 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -13006,7 +13006,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) // For /target, send reject or success packet if (app->GetOpcode() == OP_TargetCommand) { - if (GetTarget() && !GetTarget()->CastToMob()->IsInvisible(this) && (DistNoRoot(*GetTarget()) <= TARGETING_RANGE*TARGETING_RANGE || GetGM())) { + if (GetTarget() && !GetTarget()->CastToMob()->IsInvisible(this) && (ComparativeDistance(m_Position, GetTarget()->GetPosition()) <= TARGETING_RANGE*TARGETING_RANGE || GetGM())) { if (GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special || GetTarget()->GetBodyType() == BT_NoTarget) { From 4174036ce7b0e03ce0780eb0d0940321e8aa2aaf Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 19:22:59 -0800 Subject: [PATCH 152/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index e9482f8b8..73b25b6b7 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -13097,7 +13097,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) { if (GetBindSightTarget()->DistNoRoot(*GetTarget()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) { - if (DistNoRoot(*GetTarget()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) + if (ComparativeDistance(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) { char *hacker_str = nullptr; MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units," From 6d7e8d7e9a0b5f506c8b6573f05e86b0ca0ad6be Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 19:32:34 -0800 Subject: [PATCH 153/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 73b25b6b7..b9e1fae0e 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -13095,7 +13095,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) } else if (GetBindSightTarget()) { - if (GetBindSightTarget()->DistNoRoot(*GetTarget()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) + if (ComparativeDistance(GetBindSightTarget()->GetPosition(), GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) { if (ComparativeDistance(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) { From 0351ea2d3387bc315f1c0c67a1f144e5747e2ee4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 19:35:39 -0800 Subject: [PATCH 154/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index b9e1fae0e..dc53a02f7 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -13111,7 +13111,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) } } } - else if (DistNoRoot(*GetTarget()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) + else if (ComparativeDistance(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip)) { char *hacker_str = nullptr; MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units," From dc1db1fa0d2d855916bd38f0eac5dc58c3c0b869 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 19:45:42 -0800 Subject: [PATCH 155/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index dc53a02f7..1474e024b 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -13743,7 +13743,7 @@ void Client::Handle_OP_TributeItem(const EQApplicationPacket *app) Mob* tribmast = entity_list.GetMob(t->tribute_master_id); if (!tribmast || !tribmast->IsNPC() || tribmast->GetClass() != TRIBUTE_MASTER) return; - if (DistNoRoot(*tribmast) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tribmast->GetPosition()) > USE_NPC_RANGE2) return; t->tribute_points = TributeItem(t->slot, t->quantity); From a5521badb157a0c5f3e2846376004a7755b5870d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 20:03:11 -0800 Subject: [PATCH 156/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 1474e024b..8bd986225 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -13772,7 +13772,7 @@ void Client::Handle_OP_TributeMoney(const EQApplicationPacket *app) Mob* tribmast = entity_list.GetMob(t->tribute_master_id); if (!tribmast || !tribmast->IsNPC() || tribmast->GetClass() != TRIBUTE_MASTER) return; - if (DistNoRoot(*tribmast) > USE_NPC_RANGE2) + if (ComparativeDistance(m_Position, tribmast->GetPosition()) > USE_NPC_RANGE2) return; t->tribute_points = TributeMoney(t->platinum); From 2b72a50f91ad07ed7cc39042a7a04c7f04e44407 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 20:08:29 -0800 Subject: [PATCH 157/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 542390da9..e7eef4bbc 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -1601,7 +1601,7 @@ void Client::OPGMTraining(const EQApplicationPacket *app) return; //you have to be somewhat close to a trainer to be properly using them - if(DistNoRoot(*pTrainer) > USE_NPC_RANGE2) + if(ComparativeDistance(m_Position,pTrainer->GetPosition()) > USE_NPC_RANGE2) return; // if this for-loop acts up again (crashes linux), try enabling the before and after #pragmas From e44d9ce77f700e9e8e05c38139a5ff8bcd5e79c7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 20:14:05 -0800 Subject: [PATCH 158/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index e7eef4bbc..2f2498530 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -1649,7 +1649,7 @@ void Client::OPGMEndTraining(const EQApplicationPacket *app) return; //you have to be somewhat close to a trainer to be properly using them - if(DistNoRoot(*pTrainer) > USE_NPC_RANGE2) + if(ComparativeDistance(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2) return; // goodbye message From 608809a5dcf5a3de77d9f264307010b8864650dc Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 20:45:32 -0800 Subject: [PATCH 159/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/client_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 2f2498530..fc94fd415 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -1678,7 +1678,7 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app) return; //you have to be somewhat close to a trainer to be properly using them - if(DistNoRoot(*pTrainer) > USE_NPC_RANGE2) + if(ComparativeDistance(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2) return; if (gmskill->skillbank == 0x01) From ef68b46c9cee578b8a0c93833d54028158f307f2 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 20:49:09 -0800 Subject: [PATCH 160/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/effects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/effects.cpp b/zone/effects.cpp index d94f26159..34b03de38 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -796,7 +796,7 @@ void EntityList::MassGroupBuff(Mob *caster, Mob *center, uint16 spell_id, bool a continue; if (curmob == caster && !affect_caster) //watch for caster too continue; - if (center->DistNoRoot(*curmob) > dist2) //make sure they are in range + if (ComparativeDistance(center->GetPosition(), curmob->GetPosition()) > dist2) //make sure they are in range continue; //Only npcs mgb should hit are client pets... From 4fa102cb2408a638169d3d7887ac1f33e56322e8 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 20:53:08 -0800 Subject: [PATCH 161/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/effects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/effects.cpp b/zone/effects.cpp index 34b03de38..103f3521d 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -838,7 +838,7 @@ void EntityList::AEBardPulse(Mob *caster, Mob *center, uint16 spell_id, bool aff continue; if (curmob == caster && !affect_caster) //watch for caster too continue; - if (center->DistNoRoot(*curmob) > dist2) //make sure they are in range + if (ComparativeDistance(center->GetPosition(), curmob->GetPosition()) > dist2) //make sure they are in range continue; if (isnpc && curmob->IsNPC()) { //check npc->npc casting FACTION_VALUE f = curmob->GetReverseFactionCon(caster); From 93c5422966f9fd8155c5eac87edf32a00283ff32 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 21:35:30 -0800 Subject: [PATCH 162/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/effects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/effects.cpp b/zone/effects.cpp index 103f3521d..1a988d500 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -888,7 +888,7 @@ void EntityList::AEAttack(Mob *attacker, float dist, int Hand, int count, bool I && curmob != attacker //this is not needed unless NPCs can use this &&(attacker->IsAttackAllowed(curmob)) && curmob->GetRace() != 216 && curmob->GetRace() != 472 /* dont attack horses */ - && (curmob->DistNoRoot(*attacker) <= dist2) + && (ComparativeDistance(curmob->GetPosition(), attacker->GetPosition()) <= dist2) ) { attacker->Attack(curmob, Hand, false, false, IsFromSpell); hit++; From 8eea92654fe68584f84e7489614cc1d3ddf06c0c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 21:38:44 -0800 Subject: [PATCH 163/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 486a65972..2cd9d740f 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1442,7 +1442,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); } } From 3f37aef41c0bf75b2778bca23d5d3745b1418a2e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 21:41:53 -0800 Subject: [PATCH 164/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 2cd9d740f..2f21f29d9 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1921,7 +1921,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); } } From 7dce5c4e6fbb89e378f4deebd1bc9e334bd9ebb6 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 21:45:31 -0800 Subject: [PATCH 165/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 2f21f29d9..95ae4bf8d 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1937,7 +1937,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); From 91221db4c9121709bf12a0e6d1dc57a7a7dc68a3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 22:07:17 -0800 Subject: [PATCH 166/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/entity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 95ae4bf8d..3393c19a9 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1985,7 +1985,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; } @@ -2460,7 +2460,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) { From 84c82ca4ab1fb08d87e17f8e457e9aa859788cec Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 22:12:36 -0800 Subject: [PATCH 167/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 3393c19a9..4dc914273 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3546,7 +3546,7 @@ void EntityList::RadialSetLogging(Mob *around, bool enabled, bool clients, continue; } - if (around->DistNoRoot(*mob) > range2) + if (ComparativeDistance(around->GetPosition(), mob->GetPosition()) > range2) continue; if (enabled) From d01f307edcc475954122a6d080c0916c1a9af863 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 22:34:49 -0800 Subject: [PATCH 168/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 4dc914273..bb985ddce 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3666,7 +3666,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); } } From 30eb545b0bd7faddce130bf6c76505e4fb19e7df Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 22:36:59 -0800 Subject: [PATCH 169/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index bb985ddce..2b0551a26 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3868,7 +3868,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; } From 55024a861535867d581dcd8dd73a2ad8e5083200 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 22:41:04 -0800 Subject: [PATCH 170/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/groups.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/groups.cpp b/zone/groups.cpp index 6adc6735a..4b18abb40 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -758,7 +758,7 @@ void Group::CastGroupSpell(Mob* caster, uint16 spell_id) { } else if(members[z] != nullptr) { - distance = caster->DistNoRoot(*members[z]); + distance = ComparativeDistance(caster->GetPosition(), members[z]->GetPosition()); if(distance <= range2 && distance >= min_range2) { members[z]->CalcSpellPowerDistanceMod(spell_id, distance); caster->SpellOnTarget(spell_id, members[z]); @@ -798,7 +798,7 @@ void Group::GroupBardPulse(Mob* caster, uint16 spell_id) { } else if(members[z] != nullptr) { - distance = caster->DistNoRoot(*members[z]); + distance = ComparativeDistance(caster->GetPosition(), members[z]->GetPosition()); if(distance <= range2) { members[z]->BardPulse(spell_id, caster); #ifdef GROUP_BUFF_PETS From 15bd08b365f799fefb9d1ea153085399515fd596 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 22:52:33 -0800 Subject: [PATCH 171/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/groups.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/groups.cpp b/zone/groups.cpp index 4b18abb40..e1bfcb695 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -1197,7 +1197,7 @@ void Group::HealGroup(uint32 heal_amt, Mob* caster, float range) for(; gi < MAX_GROUP_MEMBERS; gi++) { if(members[gi]){ - distance = caster->DistNoRoot(*members[gi]); + distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition()); if(distance <= range2){ numMem += 1; } From a9c5f80968a9e3a2cddba4324d2e4ddaf1b143a1 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:07:04 -0800 Subject: [PATCH 172/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/groups.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/groups.cpp b/zone/groups.cpp index e1bfcb695..a3e948fc1 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -1208,7 +1208,7 @@ void Group::HealGroup(uint32 heal_amt, Mob* caster, float range) for(gi = 0; gi < MAX_GROUP_MEMBERS; gi++) { if(members[gi]){ - distance = caster->DistNoRoot(*members[gi]); + distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition()); if(distance <= range2){ members[gi]->HealDamage(heal_amt, caster); members[gi]->SendHPUpdate(); @@ -1235,7 +1235,7 @@ void Group::BalanceHP(int32 penalty, float range, Mob* caster, int32 limit) for(; gi < MAX_GROUP_MEMBERS; gi++) { if(members[gi]){ - distance = caster->DistNoRoot(*members[gi]); + distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition()); if(distance <= range2){ dmgtaken_tmp = members[gi]->GetMaxHP() - members[gi]->GetHP(); From dc2534e38c66bd2a7286e7ccbc644b58f2ef6636 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:08:48 -0800 Subject: [PATCH 173/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/groups.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/groups.cpp b/zone/groups.cpp index a3e948fc1..dadddbb65 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -1253,7 +1253,7 @@ void Group::BalanceHP(int32 penalty, float range, Mob* caster, int32 limit) for(gi = 0; gi < MAX_GROUP_MEMBERS; gi++) { if(members[gi]){ - distance = caster->DistNoRoot(*members[gi]); + distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition()); if(distance <= range2){ if((members[gi]->GetMaxHP() - dmgtaken) < 1){ //this way the ability will never kill someone members[gi]->SetHP(1); //but it will come darn close From fa50ab8a18e36518f9caaa7f66bca8fb84e63332 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:12:25 -0800 Subject: [PATCH 174/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/groups.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/groups.cpp b/zone/groups.cpp index dadddbb65..35812dd88 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -1284,7 +1284,7 @@ void Group::BalanceMana(int32 penalty, float range, Mob* caster, int32 limit) for(; gi < MAX_GROUP_MEMBERS; gi++) { if(members[gi] && (members[gi]->GetMaxMana() > 0)){ - distance = caster->DistNoRoot(*members[gi]); + distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition()); if(distance <= range2){ manataken_tmp = members[gi]->GetMaxMana() - members[gi]->GetMana(); From a9c0920bc611a2ce728cf6e5b70a4f1ae97fccd5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:15:06 -0800 Subject: [PATCH 175/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/groups.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/groups.cpp b/zone/groups.cpp index 35812dd88..1b26d47b4 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -1306,7 +1306,7 @@ void Group::BalanceMana(int32 penalty, float range, Mob* caster, int32 limit) for(gi = 0; gi < MAX_GROUP_MEMBERS; gi++) { if(members[gi]){ - distance = caster->DistNoRoot(*members[gi]); + distance = ComparativeDistance(caster->GetPosition(), members[gi]->GetPosition()); if(distance <= range2){ if((members[gi]->GetMaxMana() - manataken) < 1){ members[gi]->SetMana(1); From 80941d23bd61d40f61dea398b90b57dc827fbc3c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:16:11 -0800 Subject: [PATCH 176/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/hate_list.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index b37b07f59..572781d06 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -592,7 +592,7 @@ void HateList::SpellCast(Mob *caster, uint32 spell_id, float range, Mob* ae_cent struct_HateList *h = (*iterator); if (range > 0) { - dist_targ = center->DistNoRoot(*h->entity_on_hatelist); + dist_targ = ComparativeDistance(center->GetPosition(), h->entity_on_hatelist->GetPosition()); if (dist_targ <= range && dist_targ >= min_range2) { id_list.push_back(h->entity_on_hatelist->GetID()); From 81f36675b397ef59807d532ae704e651ffa7b746 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:19:56 -0800 Subject: [PATCH 177/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index e50cb04c5..abbb481e4 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1480,7 +1480,7 @@ void Merc::AI_Process() { if(IsMercCasterCombatRange(GetTarget())) atCombatRange = true; } - else if(DistNoRoot(*GetTarget()) <= meleeDistance) { + else if(ComparativeDistance(m_Position, GetTarget()->GetPosition()) <= meleeDistance) { atCombatRange = true; } From c5f38ee700803b459f8118c584d4ef0a91cd1097 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:26:22 -0800 Subject: [PATCH 178/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index abbb481e4..21ee850dc 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1701,7 +1701,7 @@ void Merc::AI_Process() { if(follow) { - float dist = DistNoRoot(*follow); + float dist = ComparativeDistance(m_Position, follow->GetPosition()); float speed = GetRunspeed(); if(dist < GetFollowDistance() + 1000) From 9aa46a9af2367def529120905e4f6f34230a80a0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:27:57 -0800 Subject: [PATCH 179/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index 21ee850dc..df81db149 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1938,7 +1938,7 @@ bool Merc::AIDoSpellCast(uint16 spellid, Mob* tar, int32 mana_cost, uint32* oDon if (mercSpell.type & SpellType_Escape) { dist2 = 0; } else - dist2 = DistNoRoot(*tar); + dist2 = ComparativeDistance(m_Position, tar->GetPosition()); if (((((spells[spellid].targettype==ST_GroupTeleport && mercSpell.type==SpellType_Heal) || spells[spellid].targettype==ST_AECaster From 1bb4ff2d6a90c86461ecfb3e4157286922fef80f Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:30:18 -0800 Subject: [PATCH 180/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index df81db149..3ea3ac542 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -4201,7 +4201,7 @@ bool Merc::CheckConfidence() { AggroRange = AggroRange * AggroRange; - if(mob->DistNoRoot(*this) > AggroRange) continue; + if(ComparativeDistance(m_Position, mob->GetPosition()) > AggroRange) continue; CurrentCon = this->GetLevelCon(mob->GetLevel()); switch(CurrentCon) { From 0088d353d35abedbdd7a82869120ebe779ca22e0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:31:57 -0800 Subject: [PATCH 181/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index 3ea3ac542..29310b872 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -5150,7 +5150,7 @@ bool Client::CheckCanHireMerc(Mob* merchant, uint32 template_id) { } //check for merchant too far away - if(DistNoRoot(*merchant) > USE_NPC_RANGE2) { + if(ComparativeDistance(m_Position, merchant->GetPosition()) > USE_NPC_RANGE2) { SendMercResponsePackets(18); return false; } From f047ed232db2d24becc7087c5c923e9ddd89ae4d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:33:34 -0800 Subject: [PATCH 182/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/mob_ai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index f6310801d..00db178eb 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -67,7 +67,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) { dist2 = 0; //DistNoRoot(*this); //WTF was up with this... } else - dist2 = DistNoRoot(*tar); + dist2 = ComparativeDistance(m_Position, tar->GetPosition()); bool checked_los = false; //we do not check LOS until we are absolutely sure we need to, and we only do it once. From fccd767330b3350821b7829bbaa73803e63e9002 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:37:00 -0800 Subject: [PATCH 183/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/mob_ai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 00db178eb..8d518c95d 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -401,7 +401,7 @@ bool EntityList::AICheckCloseBeneficialSpells(NPC* caster, uint8 iChance, float if (t1 > iRange || t2 > iRange || t3 > iRange - || mob->DistNoRoot(*caster) > iRange2 + || ComparativeDistance(mob->GetPosition(), caster->GetPosition()) > iRange2 //this call should seem backwards: || !mob->CheckLosFN(caster) || mob->GetReverseFactionCon(caster) >= FACTION_KINDLY From 864e9ba8efed8afa2fee73afa9a0f43f0d3fcccd Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:48:44 -0800 Subject: [PATCH 184/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/mob_ai.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 8d518c95d..17e1b5de6 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -997,7 +997,7 @@ void Client::AI_Process() if(owner == nullptr) return; - float dist = DistNoRoot(*owner); + float dist = ComparativeDistance(m_Position, owner->GetPosition()); if (dist >= 100) { float speed = dist >= 225 ? GetRunspeed() : GetWalkspeed(); @@ -1492,7 +1492,7 @@ void Mob::AI_Process() { //if(owner->IsClient()) // printf("Pet start pos: (%f, %f, %f)\n", GetX(), GetY(), GetZ()); - float dist = DistNoRoot(*owner); + float dist = ComparativeDistance(m_Position, owner->GetPosition()); if (dist >= 400) { float speed = GetWalkspeed(); From 37e4829ac4e00c1193e379e320aed00e88cb0454 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 17 Jan 2015 23:55:16 -0800 Subject: [PATCH 185/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/mob_ai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 17e1b5de6..5f75fb81b 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1547,7 +1547,7 @@ void Mob::AI_Process() { if (!follow) SetFollowID(0); else { - float dist2 = DistNoRoot(*follow); + float dist2 = ComparativeDistance(m_Position, follow->GetPosition()); int followdist = GetFollowDistance(); if (dist2 >= followdist) // Default follow distance is 100 From 6535690a69dd0693cf4d3a8fd075cf605822c143 Mon Sep 17 00:00:00 2001 From: Kemmler Date: Sun, 18 Jan 2015 03:08:12 -0500 Subject: [PATCH 186/253] MS Visual Studio needs help finding std::min and std::max --- zone/position.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zone/position.cpp b/zone/position.cpp index ddbe429af..56e7da563 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -1,9 +1,12 @@ #include #include - #include "position.h" #include "../common/string_util.h" +#ifdef _MSC_VER + #include +#endif + xy_location::xy_location(float x, float y) : m_X(x), m_Y(y) { From a0d012a6d64226a58ec9323c16fc45e2e6c731ee Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 00:48:51 -0800 Subject: [PATCH 187/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/mob_ai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 5f75fb81b..66cf41b21 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1812,7 +1812,7 @@ void NPC::AI_DoMovement() { ClearFeignMemory(); moved=false; SetMoving(false); - if (GetTarget() == nullptr || DistNoRoot(*GetTarget()) >= 5*5 ) + if (GetTarget() == nullptr || ComparativeDistance(m_Position, GetTarget()->GetPosition()) >= 5*5 ) { SetHeading(m_GuardPoint.m_Heading); } else { From 9dcdd9354988c74c649419ba77fba70c2cb507e4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 00:51:25 -0800 Subject: [PATCH 188/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/raids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/raids.cpp b/zone/raids.cpp index b01d169fd..efd312bbf 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -489,7 +489,7 @@ void Raid::CastGroupSpell(Mob* caster, uint16 spellid, uint32 gid) else if(members[x].member != nullptr) { if(members[x].GroupNumber == gid){ - distance = caster->DistNoRoot(*members[x].member); + distance = ComparativeDistance(caster->GetPosition(), members[x].member->GetPosition()); if(distance <= range2){ caster->SpellOnTarget(spellid, members[x].member); #ifdef GROUP_BUFF_PETS From 263c9b6d3f8621e09dd581ee4333f7260e2476ee Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 00:53:24 -0800 Subject: [PATCH 189/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/raids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/raids.cpp b/zone/raids.cpp index efd312bbf..e0ee94e1f 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -537,7 +537,7 @@ void Raid::HealGroup(uint32 heal_amt, Mob* caster, uint32 gid, float range) if(members[gi].member){ if(members[gi].GroupNumber == gid) { - distance = caster->DistNoRoot(*members[gi].member); + distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition()); if(distance <= range2){ numMem += 1; } From 469b27890b93f526cbcd5d1a33dddb975ed277a2 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 00:57:34 -0800 Subject: [PATCH 190/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/raids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/raids.cpp b/zone/raids.cpp index e0ee94e1f..4f197861a 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -551,7 +551,7 @@ void Raid::HealGroup(uint32 heal_amt, Mob* caster, uint32 gid, float range) if(members[gi].member){ if(members[gi].GroupNumber == gid) { - distance = caster->DistNoRoot(*members[gi].member); + distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition()); if(distance <= range2){ members[gi].member->SetHP(members[gi].member->GetHP() + heal_amt); members[gi].member->SendHPUpdate(); From 9bd4007fd61950a29545b56e3b77d76b2eead70b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 00:58:53 -0800 Subject: [PATCH 191/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/raids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/raids.cpp b/zone/raids.cpp index 4f197861a..eabb1876d 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -581,7 +581,7 @@ void Raid::BalanceHP(int32 penalty, uint32 gid, float range, Mob* caster, int32 if(members[gi].member){ if(members[gi].GroupNumber == gid) { - distance = caster->DistNoRoot(*members[gi].member); + distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition()); if(distance <= range2){ dmgtaken_tmp = members[gi].member->GetMaxHP() - members[gi].member->GetHP(); From dd52259dcf2284eb9480f62cedae888e3b98ccbe Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:00:00 -0800 Subject: [PATCH 192/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/raids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/raids.cpp b/zone/raids.cpp index eabb1876d..df544520f 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -602,7 +602,7 @@ void Raid::BalanceHP(int32 penalty, uint32 gid, float range, Mob* caster, int32 if(members[gi].member){ if(members[gi].GroupNumber == gid) { - distance = caster->DistNoRoot(*members[gi].member); + distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition()); if(distance <= range2){ if((members[gi].member->GetMaxHP() - dmgtaken) < 1){//this way the ability will never kill someone members[gi].member->SetHP(1); //but it will come darn close From a6ba08c5984ea470129bc54d29ac52098ca479f2 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:01:44 -0800 Subject: [PATCH 193/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/raids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/raids.cpp b/zone/raids.cpp index df544520f..a4769e775 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -637,7 +637,7 @@ void Raid::BalanceMana(int32 penalty, uint32 gid, float range, Mob* caster, int3 if(members[gi].GroupNumber == gid) { if (members[gi].member->GetMaxMana() > 0) { - distance = caster->DistNoRoot(*members[gi].member); + distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition()); if(distance <= range2){ manataken_tmp = members[gi].member->GetMaxMana() - members[gi].member->GetMana(); From dd70ee13a3aeb7aa5754583da8752325c330ccf8 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:04:37 -0800 Subject: [PATCH 194/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/raids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/raids.cpp b/zone/raids.cpp index a4769e775..b81d1a3c6 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -660,7 +660,7 @@ void Raid::BalanceMana(int32 penalty, uint32 gid, float range, Mob* caster, int3 if(members[gi].member){ if(members[gi].GroupNumber == gid) { - distance = caster->DistNoRoot(*members[gi].member); + distance = ComparativeDistance(caster->GetPosition(), members[gi].member->GetPosition()); if(distance <= range2){ if((members[gi].member->GetMaxMana() - manataken) < 1){ members[gi].member->SetMana(1); From 3c1ee5970e9345e15460cecb9307bee18dd41923 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:07:35 -0800 Subject: [PATCH 195/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/raids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/raids.cpp b/zone/raids.cpp index b81d1a3c6..3bed5af2e 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -791,7 +791,7 @@ void Raid::GroupBardPulse(Mob* caster, uint16 spellid, uint32 gid){ else if(members[z].member != nullptr) { if(members[z].GroupNumber == gid){ - distance = caster->DistNoRoot(*members[z].member); + distance = ComparativeDistance(caster->GetPosition(), members[z].member->GetPosition()); if(distance <= range2) { members[z].member->BardPulse(spellid, caster); #ifdef GROUP_BUFF_PETS From 5926c993be87175ad4095b87cd96bec9fc29d9d7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:09:21 -0800 Subject: [PATCH 196/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/special_attacks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 5255ff1f6..3c7bf8875 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -769,7 +769,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { float range = RangeItem->Range + AmmoItem->Range + GetRangeDistTargetSizeMod(GetTarget()); mlog(COMBAT__RANGED, "Calculated bow range to be %.1f", range); range *= range; - float dist = DistNoRoot(*other); + float dist = ComparativeDistance(m_Position, other->GetPosition()); if(dist > range) { mlog(COMBAT__RANGED, "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. From 72bad478d6fb2656e50ad2da9489040b487ab246 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:12:15 -0800 Subject: [PATCH 197/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/special_attacks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 3c7bf8875..8c03d5dbc 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -1219,7 +1219,7 @@ void NPC::RangedAttack(Mob* other) min_range = static_cast(sa_min_range); max_range *= max_range; - if(DistNoRoot(*other) > max_range) + if(ComparativeDistance(m_Position, other->GetPosition()) > max_range) return; else if(DistNoRoot(*other) < (min_range * min_range)) return; From eac35f802aa111adcc4890450e034aeff99d681a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:17:17 -0800 Subject: [PATCH 198/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/special_attacks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 8c03d5dbc..0414ce493 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -1221,7 +1221,7 @@ void NPC::RangedAttack(Mob* other) max_range *= max_range; if(ComparativeDistance(m_Position, other->GetPosition()) > max_range) return; - else if(DistNoRoot(*other) < (min_range * min_range)) + else if(ComparativeDistance(m_Position, other->GetPosition()) < (min_range * min_range)) return; if(!other || !IsAttackAllowed(other) || From 309240de43a1cd69b72e3c0cd9cc7662ee6b38fc Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:18:20 -0800 Subject: [PATCH 199/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/special_attacks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 0414ce493..b3014c7d9 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -1408,7 +1408,7 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51 float range = item->Range + GetRangeDistTargetSizeMod(other); mlog(COMBAT__RANGED, "Calculated bow range to be %.1f", range); range *= range; - float dist = DistNoRoot(*other); + float dist = ComparativeDistance(m_Position, other->GetPosition()); if(dist > range) { mlog(COMBAT__RANGED, "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. From 53ad34b0604df7bbdbbb51f0cc1f3e46eece44b7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:19:45 -0800 Subject: [PATCH 200/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/spells.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/spells.cpp b/zone/spells.cpp index a794d58a4..df3b286b3 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -2002,7 +2002,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 } if(spell_target != nullptr && spell_target != this) { //casting a spell on somebody but ourself, make sure they are in range - float dist2 = DistNoRoot(*spell_target); + float dist2 = ComparativeDistance(m_Position, spell_target->GetPosition()); float range2 = range * range; float min_range2 = spells[spell_id].min_range * spells[spell_id].min_range; if(dist2 > range2) { From 94261700d96b0705f15854af59897aa2b05b686b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:21:19 -0800 Subject: [PATCH 201/253] Removed a usage of Mob::DistNoRoot and used ComparativeDistance instead --- zone/spells.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/spells.cpp b/zone/spells.cpp index df3b286b3..96a1f87dd 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -2344,7 +2344,7 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, uint16 slot) { range = GetActSpellRange(spell_id, spells[spell_id].range, true); if(spell_target != nullptr && spell_target != this) { //casting a spell on somebody but ourself, make sure they are in range - float dist2 = DistNoRoot(*spell_target); + float dist2 = ComparativeDistance(m_Position, spell_target->GetPosition()); float range2 = range * range; if(dist2 > range2) { //target is out of range. From 3ed365cd43ba1c318122c2ce64d8085e22ab0f65 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:22:59 -0800 Subject: [PATCH 202/253] Removed mob:DistNoRoot --- zone/mob.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 8b8a23747..91f1647b9 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2274,16 +2274,6 @@ bool Mob::CanThisClassBlock(void) const } } -float Mob::DistNoRoot(const Mob &other) const { - float xDiff = other.m_Position.m_X - m_Position.m_X; - float yDiff = other.m_Position.m_Y - m_Position.m_Y; - float zDiff = other.m_Position.m_Z - m_Position.m_Z; - - return ( (xDiff * xDiff) - + (yDiff * yDiff) - + (zDiff * zDiff) ); -} - float Mob::DistNoRootNoZ(float x, float y) const { float xDiff = x - m_Position.m_X; float yDiff = y - m_Position.m_Y; From 121328b188a05d8b82fc8b1041e1e77cf7c618b9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:27:47 -0800 Subject: [PATCH 203/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 7326a9e42..8b632f43d 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3354,7 +3354,7 @@ void Bot::AI_Process() { if(GetHasBeenSummoned()) { if(IsBotCaster() || IsBotArcher()) { if (AImovement_timer->Check()) { - if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (DistNoRootNoZ(m_PreSummonLocation.m_X, m_PreSummonLocation.m_Y) < 10)) { + if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (ComparativeDistanceNoZ(static_cast(m_Position), m_PreSummonLocation) < 10)) { if(GetTarget()) FaceTarget(GetTarget()); SetHasBeenSummoned(false); From baf53890b91f1be5a9aac12f96846ee40a3b9250 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:31:24 -0800 Subject: [PATCH 204/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 8bd986225..2436c28fe 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9182,7 +9182,7 @@ void Client::Handle_OP_LootRequest(const EQApplicationPacket *app) { SetLooting(ent->GetID()); //store the entity we are looting Corpse *ent_corpse = ent->CastToCorpse(); - if (DistNoRootNoZ(ent_corpse->GetX(), ent_corpse->GetY()) > 625) + if (ComparativeDistanceNoZ(m_Position, ent_corpse->GetPosition()) > 625) { Message(13, "Corpse too far away."); Corpse::SendLootReqErrorPacket(this); From d9b3d5972997457a6535ba39a72c3841135136f5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:33:54 -0800 Subject: [PATCH 205/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/mob_ai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 66cf41b21..d552a89ea 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1129,7 +1129,7 @@ void Mob::AI_Process() { float tether_range = static_cast(GetSpecialAbilityParam(TETHER, 0)); tether_range = tether_range > 0.0f ? tether_range * tether_range : pAggroRange * pAggroRange; - if(DistNoRootNoZ(npcSpawnPoint.m_X, npcSpawnPoint.m_Y) > tether_range) { + if(ComparativeDistanceNoZ(m_Position, npcSpawnPoint) > tether_range) { GMMove(npcSpawnPoint.m_X, npcSpawnPoint.m_Y, npcSpawnPoint.m_Z, npcSpawnPoint.m_Heading); } } else if(GetSpecialAbility(LEASH)) { From 8619a0b518ddb28e3b2af61d90341de3d42ff987 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:38:30 -0800 Subject: [PATCH 206/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/mob_ai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index d552a89ea..9123b2f05 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1136,7 +1136,7 @@ void Mob::AI_Process() { float leash_range = static_cast(GetSpecialAbilityParam(LEASH, 0)); leash_range = leash_range > 0.0f ? leash_range * leash_range : pAggroRange * pAggroRange; - if(DistNoRootNoZ(npcSpawnPoint.m_X, npcSpawnPoint.m_Y) > leash_range) { + if(ComparativeDistanceNoZ(m_Position, npcSpawnPoint) > leash_range) { GMMove(npcSpawnPoint.m_X, npcSpawnPoint.m_Y, npcSpawnPoint.m_Z, npcSpawnPoint.m_Heading); SetHP(GetMaxHP()); BuffFadeAll(); From 4431aa019742fa5d1910a7ed138ff91f75d1db36 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:39:17 -0800 Subject: [PATCH 207/253] Removed Mob::DistNoRootNoZ --- zone/mob.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 91f1647b9..57be8212b 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2274,13 +2274,6 @@ bool Mob::CanThisClassBlock(void) const } } -float Mob::DistNoRootNoZ(float x, float y) const { - float xDiff = x - m_Position.m_X; - float yDiff = y - m_Position.m_Y; - - return ( (xDiff * xDiff) + (yDiff * yDiff) ); -} - float Mob::DistNoRootNoZ(const Mob &other) const { float xDiff = other.m_Position.m_X - m_Position.m_X; float yDiff = other.m_Position.m_Y - m_Position.m_Y; From 3290ddaffa7678d2518b5f91b7e4fc278f1ecfb9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:43:33 -0800 Subject: [PATCH 208/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 8b632f43d..7a4d4d5ab 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3533,7 +3533,7 @@ void Bot::AI_Process() { return; } } - else if(!IsMoving() && GetClass() != ROGUE && (DistNoRootNoZ(*GetTarget()) < GetTarget()->GetSize())) { + else if(!IsMoving() && GetClass() != ROGUE && (ComparativeDistanceNoZ(m_Position, GetTarget()->GetPosition()) < GetTarget()->GetSize())) { // If we are not a rogue trying to backstab, let's try to adjust our melee range so we don't appear to be bunched up float newX = 0; float newY = 0; From 4ced8833732a258b3cf4f07553a993987f492a3e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:51:36 -0800 Subject: [PATCH 209/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 7a4d4d5ab..14a808d1a 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3865,7 +3865,7 @@ void Bot::PetAIProcess() { return; } } - else if(botPet->DistNoRootNoZ(*botPet->GetTarget()) < botPet->GetTarget()->GetSize()) { + else if(ComparativeDistanceNoZ(botPet->GetPosition(), botPet->GetTarget()->GetPosition()) < botPet->GetTarget()->GetSize()) { // Let's try to adjust our melee range so we don't appear to be bunched up bool isBehindMob = false; bool moveBehindMob = false; From 0f1be1ecbf7b000b7abe58d65bd2a4925cd9c47b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 01:54:54 -0800 Subject: [PATCH 210/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 14a808d1a..a1cf363d2 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -10387,7 +10387,7 @@ bool Bot::IsArcheryRange(Mob *target) { range *= range; - float targetDistance = DistNoRootNoZ(*target); + float targetDistance = ComparativeDistanceNoZ(m_Position, target->GetPosition()); float minRuleDistance = RuleI(Combat, MinRangedAttackDist) * RuleI(Combat, MinRangedAttackDist); From c6b306068796bdd183ee7fb580a941e9e619b6ce Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:01:20 -0800 Subject: [PATCH 211/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/bot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index a1cf363d2..6e6201ee3 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -10411,7 +10411,7 @@ bool Bot::IsBotCasterCombatRange(Mob *target) { // half the max so the bot doesn't always stop at max range to allow combat movement range *= .5; - float targetDistance = DistNoRootNoZ(*target); + float targetDistance = ComparativeDistanceNoZ(m_Position, target->GetPosition()); if(targetDistance > range) result = false; From 4abe2fc6ffc4d965ea876b4a0ea20705f8a58151 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:03:44 -0800 Subject: [PATCH 212/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/botspellsai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index 68da92cae..c6c5e920c 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -1755,7 +1755,7 @@ Mob* Bot::GetFirstIncomingMobToMez(Bot* botCaster, BotSpell botSpell) { for(std::list::iterator itr = npc_list.begin(); itr != npc_list.end(); ++itr) { NPC* npc = *itr; - if(npc->DistNoRootNoZ(*botCaster) <= botCaster->GetActSpellRange(botSpell.SpellId, spells[botSpell.SpellId].range)) { + if(ComparativeDistanceNoZ(npc->GetPosition(), botCaster->GetPosition()) <= botCaster->GetActSpellRange(botSpell.SpellId, spells[botSpell.SpellId].range)) { if(!npc->IsMezzed()) { if(botCaster->HasGroup()) { Group* g = botCaster->GetGroup(); From 952459a31324b38ebf1122e91fafd006d9489955 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:05:09 -0800 Subject: [PATCH 213/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client.cpp b/zone/client.cpp index cee43648e..f10fb2a5d 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -994,7 +994,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s CheckEmoteHail(GetTarget(), message); - if(DistNoRootNoZ(*GetTarget()) <= 200) { + if(ComparativeDistanceNoZ(m_Position, GetTarget()->GetPosition()) <= 200) { NPC *tar = GetTarget()->CastToNPC(); parse->EventNPC(EVENT_SAY, tar->CastToNPC(), this, message, language); From 7c7250ee5309374e4c72f7475f8fae95bc0185c0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:07:01 -0800 Subject: [PATCH 214/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client.cpp b/zone/client.cpp index f10fb2a5d..bf0f21645 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1006,7 +1006,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s } } else { - if (DistNoRootNoZ(*GetTarget()) <= 200) { + if (ComparativeDistanceNoZ(m_Position, GetTarget()->GetPosition()) <= 200) { parse->EventNPC(EVENT_AGGRO_SAY, GetTarget()->CastToNPC(), this, message, language); } } From 095f5d25874e01470fe2e4145edbac4fe9bfc9e3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:08:18 -0800 Subject: [PATCH 215/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client.cpp b/zone/client.cpp index bf0f21645..c6ef7eb7f 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -4553,7 +4553,7 @@ void Client::HandleLDoNOpen(NPC *target) return; } - if(DistNoRootNoZ(*target) > RuleI(Adventure, LDoNTrapDistanceUse)) + if(ComparativeDistanceNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { LogFile->write(EQEmuLog::Debug, "%s tried to open %s but %s was out of range", GetName(), target->GetName(), target->GetName()); From c340fc9c39165a627dfeb10993fe7a0975c18fb9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:10:42 -0800 Subject: [PATCH 216/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client.cpp b/zone/client.cpp index c6ef7eb7f..f640fa77b 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -6187,7 +6187,7 @@ void Client::DragCorpses() Mob *corpse = entity_list.GetMob(It->second); if (corpse && corpse->IsPlayerCorpse() && - (DistNoRootNoZ(*corpse) <= RuleR(Character, DragCorpseDistance))) + (ComparativeDistanceNoZ(m_Position, corpse->GetPosition()) <= RuleR(Character, DragCorpseDistance))) continue; if (!corpse || !corpse->IsPlayerCorpse() || From 261feabb7d776da52a4cb192251bc65a031cf120 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:14:59 -0800 Subject: [PATCH 217/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 2436c28fe..65134cbb1 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -8707,7 +8707,7 @@ void Client::Handle_OP_LDoNDisarmTraps(const EQApplicationPacket *app) { if (HasSkill(SkillDisarmTraps)) { - if (DistNoRootNoZ(*target) > RuleI(Adventure, LDoNTrapDistanceUse)) + if (ComparativeDistanceNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { Message(13, "%s is too far away.", target->GetCleanName()); return; From 46eab011f195e595b63c530721628464e56566d6 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:16:56 -0800 Subject: [PATCH 218/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 65134cbb1..63b0f028c 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -8740,7 +8740,7 @@ void Client::Handle_OP_LDoNPickLock(const EQApplicationPacket *app) { if (HasSkill(SkillPickLock)) { - if (DistNoRootNoZ(*target) > RuleI(Adventure, LDoNTrapDistanceUse)) + if (ComparativeDistanceNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { Message(13, "%s is too far away.", target->GetCleanName()); return; From 39e059e256663c9b5a79038cc102a2f12f4a4de0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:21:13 -0800 Subject: [PATCH 219/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 63b0f028c..54b935b46 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -8759,7 +8759,7 @@ void Client::Handle_OP_LDoNSenseTraps(const EQApplicationPacket *app) { if (HasSkill(SkillSenseTraps)) { - if (DistNoRootNoZ(*target) > RuleI(Adventure, LDoNTrapDistanceUse)) + if (ComparativeDistanceNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { Message(13, "%s is too far away.", target->GetCleanName()); return; From 9dc24735a498b3d818413cfed16ef0a338a9420e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:25:09 -0800 Subject: [PATCH 220/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 54b935b46..ebd0dbe80 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9923,7 +9923,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) } if ((mypet->GetPetType() == petAnimation && GetAA(aaAnimationEmpathy) >= 2) || mypet->GetPetType() != petAnimation) { - if (GetTarget() != this && mypet->DistNoRootNoZ(*GetTarget()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) { + if (GetTarget() != this && ComparativeDistanceNoZ(mypet->GetPosition(), GetTarget()->GetPosition()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) { if (mypet->IsHeld()) { if (!mypet->IsFocused()) { mypet->SetHeld(false); //break the hold and guard if we explicitly tell the pet to attack. From 3f83bc77717fb5624338bfeba9c8e87361a435f3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:41:11 -0800 Subject: [PATCH 221/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/client_packet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index ebd0dbe80..88fb64e6d 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9958,7 +9958,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) } if ((mypet->GetPetType() == petAnimation && GetAA(aaAnimationEmpathy) >= 2) || mypet->GetPetType() != petAnimation) { - if (GetTarget() != this && mypet->DistNoRootNoZ(*GetTarget()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) { + if (GetTarget() != this && ComparativeDistanceNoZ(mypet->GetPosition(), GetTarget()->GetPosition()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) { zone->AddAggroMob(); mypet->AddToHateList(GetTarget(), 1); Message_StringID(MT_PetResponse, PET_ATTACKING, mypet->GetCleanName(), GetTarget()->GetCleanName()); From e5ee13bde044b11ab85c654a425d7cfee31a66e0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:43:16 -0800 Subject: [PATCH 222/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/command.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/command.cpp b/zone/command.cpp index 3c42d00fb..63b649448 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -4908,7 +4908,7 @@ void command_manaburn(Client *c, const Seperator *sep) c->Message(0, "#Manaburn needs a target."); else { int cur_level=c->GetAA(MANA_BURN);//ManaBurn ID - if (c->DistNoRootNoZ(*target) > 200) + if (ComparativeDistance(c->GetPosition(), target->GetPosition()) > 200) c->Message(0,"You are too far away from your target."); else { if(cur_level == 1) { From 83413178c2d87cb58d7264d7ea68ce66e35887b4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:44:49 -0800 Subject: [PATCH 223/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/command.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/command.cpp b/zone/command.cpp index 63b649448..82daf4e12 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -10305,7 +10305,7 @@ void command_disarmtrap(Client *c, const Seperator *sep) { if(c->HasSkill(SkillDisarmTraps)) { - if(c->DistNoRootNoZ(*target) > RuleI(Adventure, LDoNTrapDistanceUse)) + if(ComparativeDistanceNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { c->Message(13, "%s is too far away.", target->GetCleanName()); return; From 9c3b66df934b77b119b2ac46b81ec6a4c94a3c6c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:46:30 -0800 Subject: [PATCH 224/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/command.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/command.cpp b/zone/command.cpp index 82daf4e12..6bfe124ba 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -10330,7 +10330,7 @@ void command_sensetrap(Client *c, const Seperator *sep) { if(c->HasSkill(SkillSenseTraps)) { - if(c->DistNoRootNoZ(*target) > RuleI(Adventure, LDoNTrapDistanceUse)) + if(ComparativeDistanceNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { c->Message(13, "%s is too far away.", target->GetCleanName()); return; From e728280c5838ca4cd3733fcd16ea2f646f62bf0d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:49:44 -0800 Subject: [PATCH 225/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/command.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/command.cpp b/zone/command.cpp index 6bfe124ba..fe479848f 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -10355,7 +10355,7 @@ void command_picklock(Client *c, const Seperator *sep) { if(c->HasSkill(SkillPickLock)) { - if(c->DistNoRootNoZ(*target) > RuleI(Adventure, LDoNTrapDistanceUse)) + if(ComparativeDistanceNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { c->Message(13, "%s is too far away.", target->GetCleanName()); return; From 013518cdb5d5c07d8814abfe1ef1f07546ec2acf Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 02:59:27 -0800 Subject: [PATCH 226/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/corpse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/corpse.cpp b/zone/corpse.cpp index e1c519e89..a09b8513b 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -1328,7 +1328,7 @@ bool Corpse::Summon(Client* client, bool spell, bool CheckDistance) { client->Message(13, "That corpse is locked by a GM."); return false; } - if (!CheckDistance || (DistNoRootNoZ(*client) <= dist2)) { + if (!CheckDistance || (ComparativeDistanceNoZ(m_Position, client->GetPosition()) <= dist2)) { GMMove(client->GetX(), client->GetY(), client->GetZ()); is_corpse_changed = true; } From 8e112aac03cf35e25c830494220a465c949a10ff Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:03:46 -0800 Subject: [PATCH 227/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/corpse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/corpse.cpp b/zone/corpse.cpp index a09b8513b..b860f02fe 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -1343,7 +1343,7 @@ bool Corpse::Summon(Client* client, bool spell, bool CheckDistance) { std::list::iterator itr; for(itr = client->consent_list.begin(); itr != client->consent_list.end(); ++itr) { if(strcmp(this->GetOwnerName(), itr->c_str()) == 0) { - if (!CheckDistance || (DistNoRootNoZ(*client) <= dist2)) { + if (!CheckDistance || (ComparativeDistanceNoZ(m_Position, client->GetPosition()) <= dist2)) { GMMove(client->GetX(), client->GetY(), client->GetZ()); is_corpse_changed = true; } From e58a022e25d94f1a5a88f7368799b25bb4aeb78b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:05:35 -0800 Subject: [PATCH 228/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/effects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/effects.cpp b/zone/effects.cpp index 1a988d500..c43b91168 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -674,7 +674,7 @@ void EntityList::AETaunt(Client* taunter, float range) zdiff *= -1; if (zdiff < 10 && taunter->IsAttackAllowed(them) - && taunter->DistNoRootNoZ(*them) <= range) { + && ComparativeDistanceNoZ(taunter->GetPosition(), them->GetPosition()) <= range) { if (taunter->CheckLosFN(them)) { taunter->Taunt(them, true); } From f33eb9f8f329bb25db744fa39ba6023245c324e0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:09:08 -0800 Subject: [PATCH 229/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 2b0551a26..6ec20832e 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1584,7 +1584,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; From f54c698ffe6b5782d389c4e2aa09e6e8d55ffc84 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:12:08 -0800 Subject: [PATCH 230/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/hate_list.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 572781d06..ad49b00fd 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -158,7 +158,7 @@ Mob* HateList::GetClosestEntOnHateList(Mob *hater) { auto iterator = list.begin(); while (iterator != list.end()) { - this_distance = (*iterator)->entity_on_hatelist->DistNoRootNoZ(*hater); + this_distance = ComparativeDistanceNoZ((*iterator)->entity_on_hatelist->GetPosition(), hater->GetPosition()); if ((*iterator)->entity_on_hatelist != nullptr && this_distance <= close_distance) { close_distance = this_distance; close_entity = (*iterator)->entity_on_hatelist; From 90e011ad997edba06e8065a653f925165974aaff Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:24:40 -0800 Subject: [PATCH 231/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index 29310b872..25d0aec76 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1318,7 +1318,7 @@ bool Merc::IsMercCasterCombatRange(Mob *target) { // half the max so the merc doesn't always stop at max range to allow combat movement range *= .5; - float targetDistance = DistNoRootNoZ(*target); + float targetDistance = ComparativeDistanceNoZ(m_Position, target->GetPosition()); if(targetDistance > range) result = false; From 69a6a6f3f83e3843f33daf33125e47b3a4461730 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:25:54 -0800 Subject: [PATCH 232/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index 25d0aec76..a19021082 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1513,7 +1513,7 @@ void Merc::AI_Process() { return; } } - else if(!IsMoving() && GetClass() != ROGUE && (DistNoRootNoZ(*GetTarget()) < GetTarget()->GetSize())) + else if(!IsMoving() && GetClass() != ROGUE && (ComparativeDistanceNoZ(m_Position, GetTarget()->GetPosition()) < GetTarget()->GetSize())) { // If we are not a rogue trying to backstab, let's try to adjust our melee range so we don't appear to be bunched up float newX = 0; From 99783fd871004f1dae945d2412ee88687ac75f64 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:31:07 -0800 Subject: [PATCH 233/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index a19021082..bb549f830 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -2435,7 +2435,7 @@ void Merc::CheckHateList() { if(MercOwner && MercOwner->GetTarget() && MercOwner->GetTarget()->IsNPC() && (MercOwner->GetTarget()->GetHateAmount(MercOwner) || MercOwner->CastToClient()->AutoAttackEnabled()) && IsAttackAllowed(MercOwner->GetTarget())) { float range = g->HasRole(MercOwner, RolePuller) ? RuleI(Mercs, AggroRadiusPuller) : RuleI(Mercs, AggroRadius); range = range * range; - if(MercOwner->GetTarget()->DistNoRootNoZ(*this) < range) { + if(ComparativeDistanceNoZ(m_Position, MercOwner->GetTarget()->GetPosition()) < range) { AddToHateList(MercOwner->GetTarget(), 1); } } From 517c0846578b5208a1e40e4160b1f6e5982ea172 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:32:28 -0800 Subject: [PATCH 234/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index bb549f830..ffc3075ff 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -2445,7 +2445,7 @@ void Merc::CheckHateList() { for(std::list::iterator itr = npc_list.begin(); itr != npc_list.end(); ++itr) { NPC* npc = *itr; - float dist = npc->DistNoRootNoZ(*this); + float dist = ComparativeDistanceNoZ(m_Position, npc->GetPosition()); int radius = RuleI(Mercs, AggroRadius); radius *= radius; if(dist <= radius) { From dc275b3b1e2225f62207c3dd975918a1a7a71ab8 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:35:20 -0800 Subject: [PATCH 235/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index ffc3075ff..9031f2322 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -2499,7 +2499,7 @@ bool Merc::CheckAENuke(Merc* caster, Mob* tar, uint16 spell_id, uint8 &numTarget for(std::list::iterator itr = npc_list.begin(); itr != npc_list.end(); ++itr) { NPC* npc = *itr; - if(npc->DistNoRootNoZ(*tar) <= spells[spell_id].aoerange * spells[spell_id].aoerange) { + if(ComparativeDistanceNoZ(npc->GetPosition(), tar->GetPosition()) <= spells[spell_id].aoerange * spells[spell_id].aoerange) { if(!npc->IsMezzed()) { numTargets++; } From 8a1e03ced46ff7a7e0909a1bfdc33f88e105526e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:37:26 -0800 Subject: [PATCH 236/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index 9031f2322..4776c353a 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -2457,7 +2457,7 @@ void Merc::CheckHateList() { if(!hate_list.IsEntOnHateList(npc)) { float range = g->HasRole(groupMember, RolePuller) ? RuleI(Mercs, AggroRadiusPuller) : RuleI(Mercs, AggroRadius); range *= range; - if(npc->DistNoRootNoZ(*this) < range) { + if(ComparativeDistanceNoZ(m_Position, npc->GetPosition()) < range) { hate_list.AddEntToHateList(npc, 1); } } From ae4e1ef0d00bbebc8f61f2ed6e74905f6ca97170 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:44:08 -0800 Subject: [PATCH 237/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/merc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index 4776c353a..700287ffe 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -4098,7 +4098,7 @@ bool Merc::CheckAETaunt() { for(std::list::iterator itr = npc_list.begin(); itr != npc_list.end(); ++itr) { NPC* npc = *itr; - float dist = npc->DistNoRootNoZ(*this); + float dist = ComparativeDistanceNoZ(m_Position, npc->GetPosition()); int range = GetActSpellRange(mercSpell.spellid, spells[mercSpell.spellid].range); range *= range; From 97d7d69623c83f7de30d18066cf2c9f443528e2b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:49:40 -0800 Subject: [PATCH 238/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/mob_ai.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 9123b2f05..3902ee072 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -622,7 +622,7 @@ void Client::AI_SpellCast() if(!targ) return; - float dist = DistNoRootNoZ(*targ); + float dist = ComparativeDistanceNoZ(m_Position, targ->GetPosition()); std::vector valid_spells; std::vector slots; From 2ccac250045430e474aea8215ac76b4fa39eafc5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:52:17 -0800 Subject: [PATCH 239/253] Removed a usage of Mob::DistNoRootNoZ and used ComparativeDistanceNoZ instead --- zone/perl_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index df0a48e69..46b3b761a 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -5963,7 +5963,7 @@ XS(XS_Client_SilentMessage) Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); if(THIS->GetTarget() != NULL){ if(THIS->GetTarget()->IsNPC()){ - if (THIS->DistNoRootNoZ(*THIS->GetTarget()) <= 200) { + if (ComparativeDistanceNoZ(THIS->GetPosition(), THIS->GetTarget()->GetPosition()) <= 200) { if(THIS->GetTarget()->CastToNPC()->IsMoving() && !THIS->GetTarget()->CastToNPC()->IsOnHatelist(THIS->GetTarget())) THIS->GetTarget()->CastToNPC()->PauseWandering(RuleI(NPC, SayPauseTimeInSec)); THIS->ChannelMessageReceived(8, 0, 100, SvPV_nolen(ST(1))); From 0aefc0453db4a3db271dc8d2d66b00ba6ce25fa6 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 03:54:49 -0800 Subject: [PATCH 240/253] Removed Mob::DistNoRootNoZ --- zone/mob.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 57be8212b..238859062 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2274,13 +2274,6 @@ bool Mob::CanThisClassBlock(void) const } } -float Mob::DistNoRootNoZ(const Mob &other) const { - float xDiff = other.m_Position.m_X - m_Position.m_X; - float yDiff = other.m_Position.m_Y - m_Position.m_Y; - - return ( (xDiff * xDiff) + (yDiff * yDiff) ); -} - float Mob::GetReciprocalHeading(Mob* target) { float Result = 0; From 7374313fd9d26d16408a3bbd1a22e0b3e15ea40b Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 18 Jan 2015 14:40:50 -0500 Subject: [PATCH 241/253] Fix overflow error in lua_create_npc --- zone/lua_general.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index b0127137f..3182ac967 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -1356,7 +1356,7 @@ void lua_create_npc(luabind::adl::object table, float x, float y, float z, float LuaCreateNPCParseString(special_abilities, 512, ""); LuaCreateNPCParse(d_melee_texture1, uint16, 0); LuaCreateNPCParse(d_melee_texture2, uint16, 0); - LuaCreateNPCParseString(ammo_idfile, 32, ""); + LuaCreateNPCParseString(ammo_idfile, 30, ""); LuaCreateNPCParse(prim_melee_type, uint8, 0); LuaCreateNPCParse(sec_melee_type, uint8, 0); LuaCreateNPCParse(ranged_type, uint8, 0); From cc802f2e74ece6f6cbc5ef52bdc4d60ed364e25b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 12:22:37 -0800 Subject: [PATCH 242/253] Added 'GetReciprocalHeading' to position.cpp/h --- zone/position.cpp | 30 ++++++++++++++++++++++++++++++ zone/position.h | 3 +++ 2 files changed, 33 insertions(+) diff --git a/zone/position.cpp b/zone/position.cpp index 63c5b034f..38b92c77e 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -222,3 +222,33 @@ bool IsWithinAxisAlignedBox(const xy_location &position, const xy_location &mini return xcheck && ycheck; } + +/** +* Gives the heading directly 180 degrees from the +* current heading. +* Takes the EQfloat from the xyz_heading and returns +* an EQFloat. +*/ +float GetReciprocalHeading(const xyz_heading& point1) { + return GetReciprocalHeading(point1.m_Heading); +} + +/** +* Gives the heading directly 180 degrees from the +* current heading. +* Takes an EQfloat and returns an EQFloat. +*/ +float GetReciprocalHeading(const float heading) { + float result = 0; + + // Convert to radians + float h = (heading / 256.0f) * 6.283184f; + + // Calculate the reciprocal heading in radians + result = h + 3.141592f; + + // Convert back to eq heading from radians + result = (result / 6.283184f) * 256.0f; + + return result; +} \ No newline at end of file diff --git a/zone/position.h b/zone/position.h index 30f8fcb1c..f422a5247 100644 --- a/zone/position.h +++ b/zone/position.h @@ -99,4 +99,7 @@ float Distance(const xyz_heading& point1, const xyz_heading& point2); float DistanceNoZ(const xyz_heading& point1, const xyz_heading& point2); float ComparativeDistanceNoZ(const xyz_heading& point1, const xyz_heading& point2); +float GetReciprocalHeading(const xyz_heading& point1); +float GetReciprocalHeading(const float heading); + #endif From 53862713f9e3cbef55391412006ad769a9f38d15 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 18 Jan 2015 12:38:27 -0800 Subject: [PATCH 243/253] Switched to position based GetReciprocalHeading instead of Mob::GetReciprocalHeading --- zone/mob.cpp | 6 +++--- zone/mob.h | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index 238859062..b9fe82ea1 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2273,7 +2273,7 @@ bool Mob::CanThisClassBlock(void) const return(CastToClient()->HasSkill(SkillBlock)); } } - +/* float Mob::GetReciprocalHeading(Mob* target) { float Result = 0; @@ -2290,7 +2290,7 @@ float Mob::GetReciprocalHeading(Mob* target) { return Result; } - +*/ bool Mob::PlotPositionAroundTarget(Mob* target, float &x_dest, float &y_dest, float &z_dest, bool lookForAftArc) { bool Result = false; @@ -2298,7 +2298,7 @@ bool Mob::PlotPositionAroundTarget(Mob* target, float &x_dest, float &y_dest, fl float look_heading = 0; if(lookForAftArc) - look_heading = GetReciprocalHeading(target); + look_heading = GetReciprocalHeading(target->GetPosition()); else look_heading = target->GetHeading(); diff --git a/zone/mob.h b/zone/mob.h index c78eee65c..09c9bf56f 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -511,10 +511,6 @@ public: void ShowStats(Client* client); void ShowBuffs(Client* client); void ShowBuffList(Client* client); - float DistNoRoot(const Mob &) const; - float DistNoRootNoZ(float x, float y) const; - float DistNoRootNoZ(const Mob &) const; - static float GetReciprocalHeading(Mob* target); bool PlotPositionAroundTarget(Mob* target, float &x_dest, float &y_dest, float &z_dest, bool lookForAftArc = true); From f4224b296ad8196878d3ecef43a5eae5a4e3c4a5 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 18 Jan 2015 18:29:37 -0500 Subject: [PATCH 244/253] We don't need to cast these anymore --- zone/embparser.cpp | 2 +- zone/lua_general.cpp | 4 ++-- zone/lua_parser.cpp | 34 ++++++++++++++++---------------- zone/lua_parser_events.cpp | 2 +- zone/quest_parser_collection.cpp | 8 ++++---- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/zone/embparser.cpp b/zone/embparser.cpp index c39426953..12fd3effb 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -1143,7 +1143,7 @@ void PerlembParser::ExportEventVariables(std::string &package_name, QuestEventID ItemInst *inst = EQEmu::any_cast(extra_pointers->at(i)); std::string var_name = "item"; - var_name += std::to_string(static_cast(i + 1)); + var_name += std::to_string(i + 1); if(inst) { ExportVar(package_name.c_str(), var_name.c_str(), inst->GetItem()->ID); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 3182ac967..034895172 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -200,7 +200,7 @@ void unregister_player_event(int evt) { void register_item_event(std::string name, int evt, int item_id, luabind::adl::object func) { std::string package_name = "item_"; - package_name += std::to_string(static_cast(item_id)); + package_name += std::to_string(item_id); if(luabind::type(func) == LUA_TFUNCTION) { register_event(package_name, name, evt, func); @@ -214,7 +214,7 @@ void register_item_event(int evt, int item_id, luabind::adl::object func) { void unregister_item_event(std::string name, int evt, int item_id) { std::string package_name = "item_"; - package_name += std::to_string(static_cast(item_id)); + package_name += std::to_string(item_id); unregister_event(package_name, name, evt); } diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index 1b1bfb8e8..2051b31c7 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -235,7 +235,7 @@ int LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, return 0; } - std::string package_name = "npc_" + std::to_string(static_cast(npc->GetNPCTypeID())); + std::string package_name = "npc_" + std::to_string(npc->GetNPCTypeID()); return _EventNPC(package_name, evt, npc, init, data, extra_data, extra_pointers); } @@ -425,7 +425,7 @@ int LuaParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, Mob * } std::string package_name = "item_"; - package_name += std::to_string(static_cast(item->GetID())); + package_name += std::to_string(item->GetID()); return _EventItem(package_name, evt, client, item, mob, data, extra_data, extra_pointers); } @@ -499,12 +499,12 @@ int LuaParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spe return 0; } - std::string package_name = "spell_" + std::to_string(static_cast(spell_id)); + std::string package_name = "spell_" + std::to_string(spell_id); if(!SpellHasQuestSub(spell_id, evt)) { return 0; } - + return _EventSpell(package_name, evt, npc, client, spell_id, extra_data, extra_pointers); } @@ -646,7 +646,7 @@ bool LuaParser::HasQuestSub(uint32 npc_id, QuestEventID evt) { return false; } - std::string package_name = "npc_" + std::to_string(static_cast(npc_id)); + std::string package_name = "npc_" + std::to_string(npc_id); const char *subname = LuaEvents[evt]; return HasFunction(subname, package_name); @@ -688,7 +688,7 @@ bool LuaParser::SpellHasQuestSub(uint32 spell_id, QuestEventID evt) { return false; } - std::string package_name = "spell_" + std::to_string(static_cast(spell_id)); + std::string package_name = "spell_" + std::to_string(spell_id); const char *subname = LuaEvents[evt]; return HasFunction(subname, package_name); @@ -704,7 +704,7 @@ bool LuaParser::ItemHasQuestSub(ItemInst *itm, QuestEventID evt) { } std::string package_name = "item_"; - package_name += std::to_string(static_cast(itm->GetID())); + package_name += std::to_string(itm->GetID()); const char *subname = LuaEvents[evt]; return HasFunction(subname, package_name); @@ -723,7 +723,7 @@ bool LuaParser::EncounterHasQuestSub(std::string encounter_name, QuestEventID ev } void LuaParser::LoadNPCScript(std::string filename, int npc_id) { - std::string package_name = "npc_" + std::to_string(static_cast(npc_id)); + std::string package_name = "npc_" + std::to_string(npc_id); LoadScript(filename, package_name); } @@ -744,13 +744,13 @@ void LuaParser::LoadItemScript(std::string filename, ItemInst *item) { if (item == nullptr) return; std::string package_name = "item_"; - package_name += std::to_string(static_cast(item->GetID())); + package_name += std::to_string(item->GetID()); LoadScript(filename, package_name); } void LuaParser::LoadSpellScript(std::string filename, uint32 spell_id) { - std::string package_name = "spell_" + std::to_string(static_cast(spell_id)); + std::string package_name = "spell_" + std::to_string(spell_id); LoadScript(filename, package_name); } @@ -1011,8 +1011,8 @@ int LuaParser::DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::stri if(!npc) return 0; - std::string package_name = "npc_" + std::to_string(static_cast(npc->GetNPCTypeID())); - int ret = 0; + std::string package_name = "npc_" + std::to_string(npc->GetNPCTypeID()); + int ret = 0; auto iter = lua_encounter_events_registered.find(package_name); if(iter != lua_encounter_events_registered.end()) { @@ -1085,11 +1085,11 @@ int LuaParser::DispatchEventItem(QuestEventID evt, Client *client, ItemInst *ite if(!item) return 0; - + std::string package_name = "item_"; - package_name += std::to_string(static_cast(item->GetID())); - int ret = 0; - + package_name += std::to_string(item->GetID()); + int ret = 0; + auto iter = lua_encounter_events_registered.find(package_name); if(iter != lua_encounter_events_registered.end()) { auto riter = iter->second.begin(); @@ -1129,7 +1129,7 @@ int LuaParser::DispatchEventSpell(QuestEventID evt, NPC* npc, Client *client, ui return 0; } - std::string package_name = "spell_" + std::to_string(static_cast(spell_id)); + std::string package_name = "spell_" + std::to_string(spell_id); int ret = 0; auto iter = lua_encounter_events_registered.find(package_name); diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index 89f08a81f..dbcf86d74 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -56,7 +56,7 @@ void handle_npc_event_trade(QuestInterface *parse, lua_State* L, NPC* npc, Mob * if(extra_pointers) { size_t sz = extra_pointers->size(); for(size_t i = 0; i < sz; ++i) { - std::string prefix = "item" + std::to_string(static_cast(i + 1)); + std::string prefix = "item" + std::to_string(i + 1); ItemInst *inst = EQEmu::any_cast(extra_pointers->at(i)); Lua_ItemInst l_inst = inst; diff --git a/zone/quest_parser_collection.cpp b/zone/quest_parser_collection.cpp index d3bde0d5b..42af5efe0 100644 --- a/zone/quest_parser_collection.cpp +++ b/zone/quest_parser_collection.cpp @@ -206,11 +206,11 @@ bool QuestParserCollection::ItemHasQuestSub(ItemInst *itm, QuestEventID evt) { std::string item_script; if(itm->GetItem()->ScriptFileID != 0) { item_script = "script_"; - item_script += std::to_string(static_cast(itm->GetItem()->ScriptFileID)); + item_script += std::to_string(itm->GetItem()->ScriptFileID); } else if(strlen(itm->GetItem()->CharmFile) > 0) { item_script = itm->GetItem()->CharmFile; } else { - item_script = std::to_string(static_cast(itm->GetID())); + item_script = std::to_string(itm->GetID()); } uint32 item_id = itm->GetID(); @@ -358,11 +358,11 @@ int QuestParserCollection::EventItem(QuestEventID evt, Client *client, ItemInst std::string item_script; if(item->GetItem()->ScriptFileID != 0) { item_script = "script_"; - item_script += std::to_string(static_cast(item->GetItem()->ScriptFileID)); + item_script += std::to_string(item->GetItem()->ScriptFileID); } else if(strlen(item->GetItem()->CharmFile) > 0) { item_script = item->GetItem()->CharmFile; } else { - item_script = std::to_string(static_cast(item->GetID())); + item_script = std::to_string(item->GetID()); } uint32 item_id = item->GetID(); From 5465d76d20f0310d5e59e3a6b94331d72e2a264d Mon Sep 17 00:00:00 2001 From: JJ Date: Sun, 18 Jan 2015 19:48:32 -0500 Subject: [PATCH 245/253] VS would like us to return values. --- zone/position.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/position.cpp b/zone/position.cpp index a7b32cb62..afa2b45cf 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -152,7 +152,7 @@ float ComparativeDistance(const xyz_location& point1, const xyz_location& point2 * Produces the non square root'ed distance between the two points. */ float ComparativeDistance(const xyz_heading& point1, const xyz_heading& point2) { - ComparativeDistance(static_cast(point1), static_cast(point2)); + return ComparativeDistance(static_cast(point1), static_cast(point2)); } /** @@ -166,7 +166,7 @@ float Distance(const xyz_location& point1, const xyz_location& point2) { * Produces the distance between the two points. */ float Distance(const xyz_heading& point1, const xyz_heading& point2) { - Distance(static_cast(point1), static_cast(point2)); + return Distance(static_cast(point1), static_cast(point2)); } /** From 96820c4a310637c86341db4379ac055dbdb6ca84 Mon Sep 17 00:00:00 2001 From: Trevius Date: Sun, 18 Jan 2015 23:04:21 -0600 Subject: [PATCH 246/253] Some work on RoF Guild Banks (still not functional). --- zone/client.cpp | 4 ++-- zone/client.h | 2 +- zone/client_packet.cpp | 27 +++++++++++++++++++++------ zone/merc.cpp | 4 ++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index f640fa77b..dbf9508d4 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -5741,14 +5741,14 @@ void Client::GuildBankAck() FastQueuePacket(&outapp); } -void Client::GuildBankDepositAck(bool Fail) +void Client::GuildBankDepositAck(bool Fail, int8 action) { EQApplicationPacket *outapp = new EQApplicationPacket(OP_GuildBank, sizeof(GuildBankDepositAck_Struct)); GuildBankDepositAck_Struct *gbdas = (GuildBankDepositAck_Struct*) outapp->pBuffer; - gbdas->Action = GuildBankDeposit; + gbdas->Action = action; gbdas->Fail = Fail ? 1 : 0; diff --git a/zone/client.h b/zone/client.h index 8dd343c80..c89dc017c 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1097,7 +1097,7 @@ public: QGlobalCache *GetQGlobals() { return qGlobals; } QGlobalCache *CreateQGlobals() { qGlobals = new QGlobalCache(); return qGlobals; } void GuildBankAck(); - void GuildBankDepositAck(bool Fail); + void GuildBankDepositAck(bool Fail, int8 action); inline bool IsGuildBanker() { return GuildBanker; } void ClearGuildBank(); void SendGroupCreatePacket(); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 88fb64e6d..2ba7c1b82 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -6843,13 +6843,28 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) char *Buffer = (char *)app->pBuffer; uint32 Action = VARSTRUCT_DECODE_TYPE(uint32, Buffer); + uint32 sentAction = Action; + + if (GetClientVersion() >= EQClientRoF) + { + Action += 1; + /* + // Need to find all of the action types for RoF and switch case here + switch(Action) + { + case 4: + Action = 5; + break; + } + */ + } if (!IsInAGuild()) { Message(13, "You must be in a Guild to use the Guild Bank."); if (Action == GuildBankDeposit) - GuildBankDepositAck(true); + GuildBankDepositAck(true, sentAction); else GuildBankAck(); @@ -6876,7 +6891,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) { Message_StringID(13, GUILD_BANK_FULL); - GuildBankDepositAck(true); + GuildBankDepositAck(true, sentAction); return; } @@ -6925,7 +6940,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) { Message_StringID(13, GUILD_BANK_FULL); - GuildBankDepositAck(true); + GuildBankDepositAck(true, sentAction); return; } @@ -6938,7 +6953,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) { Message(13, "No Item on the cursor."); - GuildBankDepositAck(true); + GuildBankDepositAck(true, sentAction); return; } @@ -6969,14 +6984,14 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) if (!Allowed) { Message_StringID(13, GUILD_BANK_CANNOT_DEPOSIT); - GuildBankDepositAck(true); + GuildBankDepositAck(true, sentAction); return; } if (GuildBanks->AddItem(GuildID(), GuildBankDepositArea, CursorItem->ID, CursorItemInst->GetCharges(), GetName(), GuildBankBankerOnly, "")) { - GuildBankDepositAck(false); + GuildBankDepositAck(false, sentAction); DeleteItemInInventory(MainCursor, 0, false); } diff --git a/zone/merc.cpp b/zone/merc.cpp index 700287ffe..2f17d7ca3 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1336,7 +1336,7 @@ void Merc::AI_Process() { if(IsCasting()) return; - // A bot wont start its AI if not grouped + // A merc wont start its AI if not grouped if(!HasGroup()) { return; } @@ -5474,7 +5474,7 @@ bool Client::MercOnlyOrNoGroup() { } if (GetMerc()) { - if (GetMerc()->HasGroup() && GetMerc()->GetGroup() == GetGroup()) + if (GetMerc()->GetGroup() == GetGroup()) { if (GetGroup()->GroupCount() < 3) { From 52eb287082218e272ec4c79918fdac6a4da9235c Mon Sep 17 00:00:00 2001 From: JJ Date: Mon, 19 Jan 2015 11:00:05 -0500 Subject: [PATCH 247/253] Update to 6535690a69dd0693cf4d3a8fd075cf605822c143 to make explicit #include rather than implicit. --- zone/position.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/zone/position.cpp b/zone/position.cpp index afa2b45cf..e6996797f 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -2,10 +2,7 @@ #include #include "position.h" #include "../common/string_util.h" - -#ifdef _MSC_VER - #include -#endif +#include xy_location::xy_location(float x, float y) : m_X(x), From e70e443950b943652ff93bb92723b45e0325d65e Mon Sep 17 00:00:00 2001 From: Uleat Date: Mon, 19 Jan 2015 23:32:57 -0500 Subject: [PATCH 248/253] Implemented 'enum class ClientVersion' -- added 'RoF2' to lua client version enumeration --- changelog.txt | 3 + common/clientversions.h | 87 ++++----- common/eq_dictionary.cpp | 366 ++++++++--------------------------- common/eq_dictionary.h | 55 +++--- common/eq_stream_intf.h | 2 +- common/eq_stream_proxy.cpp | 4 +- common/eq_stream_proxy.h | 2 +- common/item.h | 8 +- common/patches/rof.cpp | 4 +- common/patches/rof.h | 2 +- common/patches/rof2.cpp | 4 +- common/patches/rof2.h | 2 +- common/patches/sod.cpp | 4 +- common/patches/sod.h | 2 +- common/patches/sof.cpp | 4 +- common/patches/sof.h | 2 +- common/patches/titanium.cpp | 4 +- common/patches/titanium.h | 2 +- common/patches/underfoot.cpp | 4 +- common/patches/underfoot.h | 2 +- common/struct_strategy.h | 2 +- loginserver/client.cpp | 2 +- loginserver/client.h | 10 +- world/client.cpp | 3 +- zone/bonuses.cpp | 6 +- zone/bot.cpp | 10 +- zone/client.cpp | 26 +-- zone/client.h | 4 +- zone/client_mods.cpp | 10 +- zone/client_packet.cpp | 50 +++-- zone/client_process.cpp | 6 +- zone/command.cpp | 2 +- zone/corpse.cpp | 6 +- zone/entity.cpp | 2 +- zone/groups.cpp | 16 +- zone/guild.cpp | 8 +- zone/guild_mgr.cpp | 2 +- zone/inventory.cpp | 10 +- zone/lua_client.cpp | 2 +- zone/lua_general.cpp | 15 +- zone/merc.cpp | 42 ++-- zone/object.cpp | 2 +- zone/perl_client.cpp | 2 +- zone/raids.cpp | 4 +- zone/spell_effects.cpp | 2 +- zone/spells.cpp | 10 +- zone/tasks.cpp | 4 +- zone/trading.cpp | 4 +- zone/worldserver.cpp | 2 +- zone/zonedb.cpp | 2 +- zone/zoning.cpp | 2 +- 51 files changed, 311 insertions(+), 520 deletions(-) diff --git a/changelog.txt b/changelog.txt index 79b156c0b..6cdfa59ee 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 01/19/2015 == +Uleat: Changed 'enum EQClientVersion' to 'enum class ClientVersion.' Other light modifications were made to accomodate this namespace. Added 'RoF2' to the lua client version enumeration. + == 01/15/2015 == Uleat: Attempted fix for elusive inventory bug: - Removed 'iter_queue' typedef and converted lcast to explicit or auto defines diff --git a/common/clientversions.h b/common/clientversions.h index ee70d481c..7ec13644e 100644 --- a/common/clientversions.h +++ b/common/clientversions.h @@ -17,59 +17,58 @@ static const uint32 BIT_RoFAndLater = 0xFFFFFFE0; static const uint32 BIT_RoF2AndLater = 0xFFFFFFC0; static const uint32 BIT_AllClients = 0xFFFFFFFF; -typedef enum +enum class ClientVersion { - EQClientUnknown = 0, - EQClient62, // Build: 'Aug 4 2005 15:40:59' - EQClientTitanium, // Build: 'Oct 31 2005 10:33:37' - EQClientSoF, // Build: 'Sep 7 2007 09:11:49' - EQClientSoD, // Build: 'Dec 19 2008 15:22:49' - EQClientUnderfoot, // Build: 'Jun 8 2010 16:44:32' - EQClientRoF, // Build: 'Dec 10 2012 17:35:44' - EQClientRoF2, // Build: 'May 10 2013 23:30:08' + Unknown = 0, + Client62, // Build: 'Aug 4 2005 15:40:59' + Tit, // Build: 'Oct 31 2005 10:33:37' + SoF, // Build: 'Sep 7 2007 09:11:49' + SoD, // Build: 'Dec 19 2008 15:22:49' + Und, // Build: 'Jun 8 2010 16:44:32' + RoF, // Build: 'Dec 10 2012 17:35:44' + RoF2, // Build: 'May 10 2013 23:30:08' - _EQClientCount, // place new clients before this point (preferably, in release/attribute order) + MobNPC, + MobMerc, + MobBot, + MobPet, +}; - // Values below are not implemented, as yet... +#define CLIENT_VERSION_COUNT 12 +#define LAST_PC_CLIENT ClientVersion::RoF2 +#define LAST_NPC_CLIENT ClientVersion::MobPet - EmuNPC = _EQClientCount, - EmuMerc, - EmuBot, - EmuPet, - _EmuClientCount // array size for EQLimits -} EQClientVersion; - -static const char* EQClientVersionName(EQClientVersion version) +static const char* ClientVersionName(ClientVersion version) { switch (version) { - case EQClientUnknown: - return "EQClientUnknown"; - case EQClient62: - return "EQClient62"; - case EQClientTitanium: - return "EQClientTitanium"; - case EQClientSoF: - return "EQClientSoF"; - case EQClientSoD: - return "EQClientSoD"; - case EQClientUnderfoot: - return "EQClientUnderfoot"; - case EQClientRoF: - return "EQClientRoF"; - case EQClientRoF2: - return "EQClientRoF2"; - case EmuNPC: - return "EmuNPC"; - case EmuMerc: - return "EmuMerc"; - case EmuBot: - return "EmuBot"; - case EmuPet: - return "EmuPet"; + case ClientVersion::Unknown: + return "ClientVersion::Unknown"; + case ClientVersion::Client62: + return "ClientVersion::Client62"; + case ClientVersion::Tit: + return "ClientVersion::Tit"; + case ClientVersion::SoF: + return "ClientVersion::SoF"; + case ClientVersion::SoD: + return "ClientVersion::SoD"; + case ClientVersion::Und: + return "ClientVersion::Und"; + case ClientVersion::RoF: + return "ClientVersion::RoF"; + case ClientVersion::RoF2: + return "ClientVersion::RoF2"; + case ClientVersion::MobNPC: + return "ClientVersion::MobNPC"; + case ClientVersion::MobMerc: + return "ClientVersion::MobMerc"; + case ClientVersion::MobBot: + return "ClientVersion::MobBot"; + case ClientVersion::MobPet: + return "ClientVersion::MobPet"; default: - return "ERROR: Invalid EQClientVersion"; + return " Invalid ClientVersion"; }; } diff --git a/common/eq_dictionary.cpp b/common/eq_dictionary.cpp index 46c8f4ff1..986f17848 100644 --- a/common/eq_dictionary.cpp +++ b/common/eq_dictionary.cpp @@ -25,8 +25,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // class EmuConstants // -uint16 EmuConstants::InventoryMapSize(int16 map) { - switch (map) { +uint16 EmuConstants::InventoryMapSize(int16 indexMap) { + switch (indexMap) { case MapPossessions: return MAP_POSSESSIONS_SIZE; case MapBank: @@ -91,8 +91,8 @@ std::string EmuConstants::InventoryLocationName(Location_Struct location) { } */ -std::string EmuConstants::InventoryMapName(int16 map) { - switch (map) { +std::string EmuConstants::InventoryMapName(int16 indexMap) { + switch (indexMap) { case INVALID_INDEX: return "Invalid Map"; case MapPossessions: @@ -150,8 +150,8 @@ std::string EmuConstants::InventoryMapName(int16 map) { } } -std::string EmuConstants::InventoryMainName(int16 main) { - switch (main) { +std::string EmuConstants::InventoryMainName(int16 indexMain) { + switch (indexMain) { case INVALID_INDEX: return "Invalid Main"; case MainCharm: @@ -229,293 +229,83 @@ std::string EmuConstants::InventoryMainName(int16 main) { } } -std::string EmuConstants::InventorySubName(int16 sub) { - if (sub == INVALID_INDEX) +std::string EmuConstants::InventorySubName(int16 indexSub) { + if (indexSub == INVALID_INDEX) return "Invalid Sub"; - if ((uint16)sub >= ITEM_CONTAINER_SIZE) + if ((uint16)indexSub >= ITEM_CONTAINER_SIZE) return "Unknown Sub"; std::string ret_str; - ret_str = StringFormat("Container %i", (sub + 1)); // zero-based index..but, count starts at one + ret_str = StringFormat("Container %i", (indexSub + 1)); // zero-based index..but, count starts at one return ret_str; } -std::string EmuConstants::InventoryAugName(int16 aug) { - if (aug == INVALID_INDEX) +std::string EmuConstants::InventoryAugName(int16 indexAug) { + if (indexAug == INVALID_INDEX) return "Invalid Aug"; - if ((uint16)aug >= ITEM_COMMON_SIZE) + if ((uint16)indexAug >= ITEM_COMMON_SIZE) return "Unknown Aug"; std::string ret_str; - ret_str = StringFormat("Augment %i", (aug + 1)); // zero-based index..but, count starts at one + ret_str = StringFormat("Augment %i", (indexAug + 1)); // zero-based index..but, count starts at one return ret_str; } -// legacy-related functions -// -// these should work for the first-stage coversions..but, once the new system is up and going..conversions will be incompatible -// without limiting server functions and other aspects, such as augment control, bag size, etc. A complete remapping will be -// required when bag sizes over 10 and direct manipulation of augments are implemented, due to the massive increase in range usage. -// -// (current personal/cursor bag range {251..340}, or 90 slots ... conversion translated range would be {10000..12804}, or 2805 slots... -// these would have to be hard-coded into all perl code to allow access to full range of the new system - actual limits would be -// less, based on bag size..but, the range must be full and consistent to avoid translation issues -- similar changes to other ranges -// (240 versus 6120 slots for bank bags, for example...)) -/* -int EmuConstants::ServerToPerlSlot(int server_slot) { // set r/s - switch (server_slot) { - case legacy::SLOT_CURSOR_END: - return legacy::SLOT_CURSOR_END; - case INVALID_INDEX: - return legacy::SLOT_INVALID; - case MainPowerSource: - return legacy::SLOT_POWER_SOURCE; - case MainAmmo: - return legacy::SLOT_AMMO; - case MainCursor: - return legacy::SLOT_CURSOR; - case legacy::SLOT_TRADESKILL: - return legacy::SLOT_TRADESKILL; - case legacy::SLOT_AUGMENT: - return legacy::SLOT_AUGMENT; - default: - int perl_slot = legacy::SLOT_INVALID; - - // activate the internal checks as needed - if (server_slot >= EmuConstants::EQUIPMENT_BEGIN && server_slot <= MainWaist) { - perl_slot = server_slot; - } - else if (server_slot >= EmuConstants::GENERAL_BEGIN && server_slot <= EmuConstants::GENERAL_END) { - perl_slot = server_slot;// + legacy::SLOT_PERSONAL_BEGIN - EmuConstants::GENERAL_BEGIN; - //if (perl_slot < legacy::SLOT_PERSONAL_BEGIN || perl_slot > legacy::SLOT_PERSONAL_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::GENERAL_BAGS_BEGIN && server_slot <= EmuConstants::GENERAL_BAGS_END) { - perl_slot = server_slot;// + legacy::SLOT_PERSONAL_BAGS_BEGIN - EmuConstants::GENERAL_BAGS_BEGIN; - //if (perl_slot < legacy::SLOT_PERSONAL_BAGS_BEGIN || perl_slot > legacy::SLOT_PERSONAL_BAGS_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::CURSOR_BAG_BEGIN && server_slot <= EmuConstants::CURSOR_BAG_END) { - perl_slot = server_slot;// + legacy::SLOT_CURSOR_BAG_BEGIN - EmuConstants::CURSOR_BAG_BEGIN; - //if (perl_slot < legacy::SLOT_CURSOR_BAG_BEGIN || perl_slot > legacy::SLOT_CURSOR_BAG_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::TRIBUTE_BEGIN && server_slot <= EmuConstants::TRIBUTE_END) { - perl_slot = server_slot;// + legacy::SLOT_TRIBUTE_BEGIN - EmuConstants::TRADE_BEGIN; - //if (perl_slot < legacy::SLOT_TRIBUTE_BEGIN || perl_slot > legacy::SLOT_TRIBUTE_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::BANK_BEGIN && server_slot <= EmuConstants::BANK_END) { - perl_slot = server_slot;// + legacy::SLOT_BANK_BEGIN - EmuConstants::BANK_BEGIN; - //if (perl_slot < legacy::SLOT_BANK_BEGIN || perl_slot > legacy::SLOT_BANK_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::BANK_BAGS_BEGIN && server_slot <= EmuConstants::BANK_BAGS_END) { - perl_slot = server_slot;// + legacy::SLOT_BANK_BAGS_BEGIN - EmuConstants::BANK_BAGS_BEGIN; - //if (perl_slot < legacy::SLOT_BANK_BAGS_BEGIN || perl_slot > legacy::SLOT_BANK_BAGS_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::SHARED_BANK_BEGIN && server_slot <= EmuConstants::SHARED_BANK_END) { - perl_slot = server_slot;// + legacy::SLOT_SHARED_BANK_BEGIN - EmuConstants::SHARED_BANK_BEGIN; - //if (perl_slot < legacy::SLOT_SHARED_BANK_BEGIN || perl_slot > legacy::SLOT_SHARED_BANK_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::SHARED_BANK_BAGS_BEGIN && server_slot <= EmuConstants::SHARED_BANK_BAGS_END) { - perl_slot = server_slot;// + legacy::SLOT_SHARED_BANK_BAGS_BEGIN - EmuConstants::SHARED_BANK_BAGS_BEGIN; - //if (perl_slot < legacy::SLOT_SHARED_BANK_BAGS_BEGIN || perl_slot > legacy::SLOT_SHARED_BANK_BAGS_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::TRADE_BEGIN && server_slot <= EmuConstants::TRADE_END) { - perl_slot = server_slot;// + legacy::SLOT_TRADE_BEGIN - EmuConstants::TRADE_BEGIN; - //if (perl_slot < legacy::SLOT_TRADE_BEGIN || perl_slot > legacy::SLOT_TRADE_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::TRADE_BAGS_BEGIN && server_slot <= EmuConstants::TRADE_BAGS_END) { - perl_slot = server_slot;// + legacy::SLOT_TRADE_BAGS_BEGIN - EmuConstants::TRADE_BAGS_BEGIN; - //if (perl_slot < legacy::SLOT_TRADE_BAGS_BEGIN || perl_slot > legacy::SLOT_TRADE_BAGS_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= EmuConstants::WORLD_BEGIN && server_slot <= EmuConstants::WORLD_END) { - perl_slot = server_slot;// + legacy::SLOT_WORLD_BEGIN - EmuConstants::WORLD_BEGIN; - //if (perl_slot < legacy::SLOT_WORLD_BEGIN || perl_slot > legacy::SLOT_WORLD_END) - // perl_slot = legacy::SLOT_INVALID; - } - else if (server_slot >= 8000 && server_slot <= 8999) { // this range may be limited to 36 in the future (client size) - perl_slot = server_slot; - } - - return perl_slot; - } -} -*/ -/* -int EmuConstants::PerlToServerSlot(int perl_slot) { // set r/s - switch (perl_slot) { - case legacy::SLOT_CURSOR_END: - return legacy::SLOT_CURSOR_END; - case legacy::SLOT_INVALID: - return INVALID_INDEX; - case legacy::SLOT_POWER_SOURCE: - return MainPowerSource; - case legacy::SLOT_AMMO: - return MainAmmo; - case legacy::SLOT_CURSOR: - return MainCursor; - case legacy::SLOT_TRADESKILL: - return legacy::SLOT_TRADESKILL; - case legacy::SLOT_AUGMENT: - return legacy::SLOT_AUGMENT; - default: - int server_slot = INVALID_INDEX; - - // activate the internal checks as needed - if (perl_slot >= legacy::SLOT_EQUIPMENT_BEGIN && perl_slot <= legacy::SLOT_WAIST) { - server_slot = perl_slot; - } - else if (perl_slot >= legacy::SLOT_PERSONAL_BEGIN && perl_slot <= legacy::SLOT_PERSONAL_END) { - server_slot = perl_slot;// + EmuConstants::GENERAL_BEGIN - legacy::SLOT_PERSONAL_BEGIN; - //if (server_slot < EmuConstants::GENERAL_BEGIN || server_slot > EmuConstants::GENERAL_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_PERSONAL_BAGS_BEGIN && perl_slot <= legacy::SLOT_PERSONAL_BAGS_END) { - server_slot = perl_slot;// + EmuConstants::GENERAL_BAGS_BEGIN - legacy::SLOT_PERSONAL_BAGS_BEGIN; - //if (server_slot < EmuConstants::GENERAL_BAGS_BEGIN || server_slot > EmuConstants::GENERAL_BAGS_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_CURSOR_BAG_BEGIN && perl_slot <= legacy::SLOT_CURSOR_BAG_END) { - server_slot = perl_slot;// + EmuConstants::CURSOR_BAG_BEGIN - legacy::SLOT_CURSOR_BAG_BEGIN; - //if (server_slot < EmuConstants::CURSOR_BAG_BEGIN || server_slot > EmuConstants::CURSOR_BAG_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_TRIBUTE_BEGIN && perl_slot <= legacy::SLOT_TRIBUTE_END) { - server_slot = perl_slot;// + EmuConstants::TRIBUTE_BEGIN - legacy::SLOT_TRIBUTE_BEGIN; - //if (server_slot < EmuConstants::TRIBUTE_BEGIN || server_slot > EmuConstants::TRIBUTE_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_BANK_BEGIN && perl_slot <= legacy::SLOT_BANK_END) { - server_slot = perl_slot;// + EmuConstants::BANK_BEGIN - legacy::SLOT_BANK_BEGIN; - //if (server_slot < EmuConstants::BANK_BEGIN || server_slot > EmuConstants::BANK_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_BANK_BAGS_BEGIN && perl_slot <= legacy::SLOT_BANK_BAGS_END) { - server_slot = perl_slot;// + EmuConstants::BANK_BAGS_BEGIN - legacy::SLOT_BANK_BAGS_BEGIN; - //if (server_slot < EmuConstants::BANK_BAGS_BEGIN || server_slot > EmuConstants::BANK_BAGS_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_SHARED_BANK_BEGIN && perl_slot <= legacy::SLOT_SHARED_BANK_END) { - server_slot = perl_slot;// + EmuConstants::SHARED_BANK_BEGIN - legacy::SLOT_SHARED_BANK_BEGIN; - //if (server_slot < EmuConstants::SHARED_BANK_BEGIN || server_slot > EmuConstants::SHARED_BANK_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_SHARED_BANK_BAGS_BEGIN && perl_slot <= legacy::SLOT_SHARED_BANK_BAGS_END) { - server_slot = perl_slot;// + EmuConstants::SHARED_BANK_BAGS_BEGIN - legacy::SLOT_SHARED_BANK_BAGS_END; - //if (server_slot < EmuConstants::SHARED_BANK_BAGS_BEGIN || server_slot > EmuConstants::SHARED_BANK_BAGS_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_TRADE_BEGIN && perl_slot <= legacy::SLOT_TRADE_END) { - server_slot = perl_slot;// + EmuConstants::TRADE_BEGIN - legacy::SLOT_TRADE_BEGIN; - //if (server_slot < EmuConstants::TRADE_BEGIN || server_slot > EmuConstants::TRADE_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_TRADE_BAGS_BEGIN && perl_slot <= legacy::SLOT_TRADE_BAGS_END) { - server_slot = perl_slot;// + EmuConstants::TRADE_BAGS_BEGIN - legacy::SLOT_TRADE_BAGS_BEGIN; - //if (server_slot < EmuConstants::TRADE_BAGS_BEGIN || server_slot > EmuConstants::TRADE_BAGS_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= legacy::SLOT_WORLD_BEGIN && perl_slot <= legacy::SLOT_WORLD_END) { - server_slot = perl_slot;// + EmuConstants::WORLD_BEGIN - legacy::SLOT_WORLD_BEGIN; - //if (server_slot < EmuConstants::WORLD_BEGIN || server_slot > EmuConstants::WORLD_END) - // server_slot = INVALID_INDEX; - } - else if (perl_slot >= 8000 && perl_slot <= 8999) { // this range may be limited to 36 in the future (client size) - server_slot = perl_slot; - } - - return server_slot; - } -} -*/ // // class EQLimits // // client validation -bool EQLimits::IsValidClientVersion(uint32 version) { - if (version < _EQClientCount) +bool EQLimits::IsValidPCClientVersion(ClientVersion clientVersion) { + if (clientVersion > ClientVersion::Unknown && clientVersion <= LAST_PC_CLIENT) return true; return false; } -uint32 EQLimits::ValidateClientVersion(uint32 version) { - if (version < _EQClientCount) - return version; +ClientVersion EQLimits::ValidatePCClientVersion(ClientVersion clientVersion) { + if (clientVersion > ClientVersion::Unknown && clientVersion <= LAST_PC_CLIENT) + return clientVersion; - return EQClientUnknown; -} - -EQClientVersion EQLimits::ValidateClientVersion(EQClientVersion version) { - if (version >= EQClientUnknown) - if (version < _EQClientCount) - return version; - - return EQClientUnknown; + return ClientVersion::Unknown; } // npc validation -bool EQLimits::IsValidNPCVersion(uint32 version) { - if (version >= _EQClientCount) - if (version < _EmuClientCount) - return true; - - return false; -} - -uint32 EQLimits::ValidateNPCVersion(uint32 version) { - if (version >= _EQClientCount) - if (version < _EmuClientCount) - return version; - - return EQClientUnknown; -} - -EQClientVersion EQLimits::ValidateNPCVersion(EQClientVersion version) { - if (version >= _EQClientCount) - if (version < _EmuClientCount) - return version; - - return EQClientUnknown; -} - -// mob validation -bool EQLimits::IsValidMobVersion(uint32 version) { - if (version < _EmuClientCount) +bool EQLimits::IsValidNPCClientVersion(ClientVersion clientVersion) { + if (clientVersion > LAST_PC_CLIENT && clientVersion <= LAST_NPC_CLIENT) return true; return false; } -uint32 EQLimits::ValidateMobVersion(uint32 version) { - if (version < _EmuClientCount) - return version; +ClientVersion EQLimits::ValidateNPCClientVersion(ClientVersion clientVersion) { + if (clientVersion > LAST_PC_CLIENT && clientVersion <= LAST_NPC_CLIENT) + return clientVersion; - return EQClientUnknown; + return ClientVersion::Unknown; } -EQClientVersion EQLimits::ValidateMobVersion(EQClientVersion version) { - if (version >= EQClientUnknown) - if (version < _EmuClientCount) - return version; +// mob validation +bool EQLimits::IsValidMobClientVersion(ClientVersion clientVersion) { + if (clientVersion > ClientVersion::Unknown && clientVersion <= LAST_NPC_CLIENT) + return true; - return EQClientUnknown; + return false; +} + +ClientVersion EQLimits::ValidateMobClientVersion(ClientVersion clientVersion) { + if (clientVersion > ClientVersion::Unknown && clientVersion <= LAST_NPC_CLIENT) + return clientVersion; + + return ClientVersion::Unknown; } // inventory -uint16 EQLimits::InventoryMapSize(int16 map, uint32 version) { +uint16 EQLimits::InventoryMapSize(int16 indexMap, ClientVersion clientVersion) { // not all maps will have an instantiated container..some are references for queue generators (i.e., bazaar, mail, etc...) // a zero '0' indicates a needed value..otherwise, change to '_NOTUSED' for a null value so indices requiring research can be identified // ALL of these values need to be verified before pushing to live @@ -527,7 +317,7 @@ uint16 EQLimits::InventoryMapSize(int16 map, uint32 version) { // // when setting NPC-based values, try to adhere to an EmuConstants:: or NOT_USED value to avoid unnecessary issues - static const uint16 local[_MapCount][_EmuClientCount] = { + static const uint16 local[_MapCount][CLIENT_VERSION_COUNT] = { // server and database are sync'd to current MapPossessions's client as set in 'using namespace RoF::slots;' and // 'EmuConstants::MAP_POSSESSIONS_SIZE' - use/update EquipmentBitmask(), GeneralBitmask() and CursorBitmask() // for partial range validation checks and 'EmuConstants::MAP_POSSESSIONS_SIZE' for full range iterations @@ -908,19 +698,19 @@ uint16 EQLimits::InventoryMapSize(int16 map, uint32 version) { } }; - if ((uint16)map < _MapCount) - return local[map][ValidateMobVersion(version)]; + if ((uint16)indexMap < _MapCount) + return local[indexMap][static_cast(ValidateMobClientVersion(clientVersion))]; return NOT_USED; } -uint64 EQLimits::PossessionsBitmask(uint32 version) { +uint64 EQLimits::PossessionsBitmask(ClientVersion clientVersion) { // these are for the new inventory system (RoF)..not the current (Ti) one... // 0x0000000000200000 is SlotPowerSource (SoF+) // 0x0000000080000000 is SlotGeneral9 (RoF+) // 0x0000000100000000 is SlotGeneral10 (RoF+) - static const uint64 local[_EmuClientCount] = { + static const uint64 local[CLIENT_VERSION_COUNT] = { /*Unknown*/ NOT_USED, /*62*/ 0x000000027FDFFFFF, /*Titanium*/ 0x000000027FDFFFFF, @@ -937,11 +727,11 @@ uint64 EQLimits::PossessionsBitmask(uint32 version) { }; return NOT_USED; - //return local[ValidateMobVersion(version)]; + //return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -uint64 EQLimits::EquipmentBitmask(uint32 version) { - static const uint64 local[_EmuClientCount] = { +uint64 EQLimits::EquipmentBitmask(ClientVersion clientVersion) { + static const uint64 local[CLIENT_VERSION_COUNT] = { /*Unknown*/ NOT_USED, /*62*/ 0x00000000005FFFFF, /*Titanium*/ 0x00000000005FFFFF, @@ -958,11 +748,11 @@ uint64 EQLimits::EquipmentBitmask(uint32 version) { }; return NOT_USED; - //return local[ValidateMobVersion(version)]; + //return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -uint64 EQLimits::GeneralBitmask(uint32 version) { - static const uint64 local[_EmuClientCount] = { +uint64 EQLimits::GeneralBitmask(ClientVersion clientVersion) { + static const uint64 local[CLIENT_VERSION_COUNT] = { /*Unknown*/ NOT_USED, /*62*/ 0x000000007F800000, /*Titanium*/ 0x000000007F800000, @@ -979,11 +769,11 @@ uint64 EQLimits::GeneralBitmask(uint32 version) { }; return NOT_USED; - //return local[ValidateMobVersion(version)]; + //return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -uint64 EQLimits::CursorBitmask(uint32 version) { - static const uint64 local[_EmuClientCount] = { +uint64 EQLimits::CursorBitmask(ClientVersion clientVersion) { + static const uint64 local[CLIENT_VERSION_COUNT] = { /*Unknown*/ NOT_USED, /*62*/ 0x0000000200000000, /*Titanium*/ 0x0000000200000000, @@ -1000,11 +790,11 @@ uint64 EQLimits::CursorBitmask(uint32 version) { }; return NOT_USED; - //return local[ValidateMobVersion(version)]; + //return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -bool EQLimits::AllowsEmptyBagInBag(uint32 version) { - static const bool local[_EmuClientCount] = { +bool EQLimits::AllowsEmptyBagInBag(ClientVersion clientVersion) { + static const bool local[CLIENT_VERSION_COUNT] = { /*Unknown*/ false, /*62*/ false, /*Titanium*/ Titanium::limits::ALLOWS_EMPTY_BAG_IN_BAG, @@ -1021,11 +811,11 @@ bool EQLimits::AllowsEmptyBagInBag(uint32 version) { }; return false; // not implemented - //return local[ValidateMobVersion(version)]; + //return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -bool EQLimits::AllowsClickCastFromBag(uint32 version) { - static const bool local[_EmuClientCount] = { +bool EQLimits::AllowsClickCastFromBag(ClientVersion clientVersion) { + static const bool local[CLIENT_VERSION_COUNT] = { /*Unknown*/ false, /*62*/ false, /*Titanium*/ Titanium::limits::ALLOWS_CLICK_CAST_FROM_BAG, @@ -1041,12 +831,12 @@ bool EQLimits::AllowsClickCastFromBag(uint32 version) { /*Pet*/ false }; - return local[ValidateMobVersion(version)]; + return local[static_cast(ValidateMobClientVersion(clientVersion))]; } // items -uint16 EQLimits::ItemCommonSize(uint32 version) { - static const uint16 local[_EmuClientCount] = { +uint16 EQLimits::ItemCommonSize(ClientVersion clientVersion) { + static const uint16 local[CLIENT_VERSION_COUNT] = { /*Unknown*/ NOT_USED, /*62*/ EmuConstants::ITEM_COMMON_SIZE, /*Titanium*/ EmuConstants::ITEM_COMMON_SIZE, @@ -1062,11 +852,11 @@ uint16 EQLimits::ItemCommonSize(uint32 version) { /*Pet*/ EmuConstants::ITEM_COMMON_SIZE }; - return local[ValidateMobVersion(version)]; + return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -uint16 EQLimits::ItemContainerSize(uint32 version) { - static const uint16 local[_EmuClientCount] = { +uint16 EQLimits::ItemContainerSize(ClientVersion clientVersion) { + static const uint16 local[CLIENT_VERSION_COUNT] = { /*Unknown*/ NOT_USED, /*62*/ EmuConstants::ITEM_CONTAINER_SIZE, /*Titanium*/ EmuConstants::ITEM_CONTAINER_SIZE, @@ -1082,11 +872,11 @@ uint16 EQLimits::ItemContainerSize(uint32 version) { /*Pet*/ EmuConstants::ITEM_CONTAINER_SIZE }; - return local[ValidateMobVersion(version)]; + return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -bool EQLimits::CoinHasWeight(uint32 version) { - static const bool local[_EmuClientCount] = { +bool EQLimits::CoinHasWeight(ClientVersion clientVersion) { + static const bool local[CLIENT_VERSION_COUNT] = { /*Unknown*/ true, /*62*/ true, /*Titanium*/ Titanium::limits::COIN_HAS_WEIGHT, @@ -1102,11 +892,11 @@ bool EQLimits::CoinHasWeight(uint32 version) { /*Pet*/ true }; - return local[ValidateMobVersion(version)]; + return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -uint32 EQLimits::BandoliersCount(uint32 version) { - static const uint32 local[_EmuClientCount] = { +uint32 EQLimits::BandoliersCount(ClientVersion clientVersion) { + static const uint32 local[CLIENT_VERSION_COUNT] = { /*Unknown*/ NOT_USED, /*62*/ EmuConstants::BANDOLIERS_COUNT, /*Titanium*/ EmuConstants::BANDOLIERS_COUNT, @@ -1122,11 +912,11 @@ uint32 EQLimits::BandoliersCount(uint32 version) { /*Pet*/ NOT_USED }; - return local[ValidateMobVersion(version)]; + return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -uint32 EQLimits::BandolierSize(uint32 version) { - static const uint32 local[_EmuClientCount] = { +uint32 EQLimits::BandolierSize(ClientVersion clientVersion) { + static const uint32 local[CLIENT_VERSION_COUNT] = { /*Unknown*/ NOT_USED, /*62*/ EmuConstants::BANDOLIER_SIZE, /*Titanium*/ EmuConstants::BANDOLIER_SIZE, @@ -1142,11 +932,11 @@ uint32 EQLimits::BandolierSize(uint32 version) { /*Pet*/ NOT_USED }; - return local[ValidateMobVersion(version)]; + return local[static_cast(ValidateMobClientVersion(clientVersion))]; } -uint32 EQLimits::PotionBeltSize(uint32 version) { - static const uint32 local[_EmuClientCount] = { +uint32 EQLimits::PotionBeltSize(ClientVersion clientVersion) { + static const uint32 local[CLIENT_VERSION_COUNT] = { /*Unknown*/ NOT_USED, /*62*/ EmuConstants::POTION_BELT_SIZE, /*Titanium*/ EmuConstants::POTION_BELT_SIZE, @@ -1162,5 +952,5 @@ uint32 EQLimits::PotionBeltSize(uint32 version) { /*Pet*/ NOT_USED }; - return local[ValidateMobVersion(version)]; + return local[static_cast(ValidateMobClientVersion(clientVersion))]; } diff --git a/common/eq_dictionary.h b/common/eq_dictionary.h index 3438f133b..a61eb7bfd 100644 --- a/common/eq_dictionary.h +++ b/common/eq_dictionary.h @@ -46,15 +46,15 @@ class EmuConstants { // an immutable value is required to initialize arrays, etc... use this class as a repository for those public: // database - static const EQClientVersion CHARACTER_CREATION_CLIENT = EQClientRoF; // adjust according to starting item placement and target client + static const ClientVersion CHARACTER_CREATION_CLIENT = ClientVersion::RoF2; // adjust according to starting item placement and target client // inventory - static uint16 InventoryMapSize(int16 map); + static uint16 InventoryMapSize(int16 indexMap); //static std::string InventoryLocationName(Location_Struct location); - static std::string InventoryMapName(int16 map); - static std::string InventoryMainName(int16 main); - static std::string InventorySubName(int16 sub); - static std::string InventoryAugName(int16 aug); + static std::string InventoryMapName(int16 indexMap); + static std::string InventoryMainName(int16 indexMain); + static std::string InventorySubName(int16 indexSub); + static std::string InventoryAugName(int16 indexAug); // these are currently hard-coded for existing inventory system..do not use in place of special client version handlers until ready static const uint16 MAP_POSSESSIONS_SIZE = _MainCount; @@ -163,44 +163,41 @@ class EQLimits { public: // client version validation (checks to avoid crashing zone server when accessing reference arrays) // use this inside of class Client (limits to actual clients) - static bool IsValidClientVersion(uint32 version); - static uint32 ValidateClientVersion(uint32 version); - static EQClientVersion ValidateClientVersion(EQClientVersion version); + static bool IsValidPCClientVersion(ClientVersion clientVersion); + static ClientVersion ValidatePCClientVersion(ClientVersion clientVersion); // basically..any non-client classes - do not when setting a valid client - static bool IsValidNPCVersion(uint32 version); - static uint32 ValidateNPCVersion(uint32 version); - static EQClientVersion ValidateNPCVersion(EQClientVersion version); + static bool IsValidNPCClientVersion(ClientVersion clientVersion); + static ClientVersion ValidateNPCClientVersion(ClientVersion clientVersion); // these are 'universal' - do not when setting a valid client - static bool IsValidMobVersion(uint32 version); - static uint32 ValidateMobVersion(uint32 version); - static EQClientVersion ValidateMobVersion(EQClientVersion version); + static bool IsValidMobClientVersion(ClientVersion clientVersion); + static ClientVersion ValidateMobClientVersion(ClientVersion clientVersion); // inventory - static uint16 InventoryMapSize(int16 map, uint32 version); - static uint64 PossessionsBitmask(uint32 version); - static uint64 EquipmentBitmask(uint32 version); - static uint64 GeneralBitmask(uint32 version); - static uint64 CursorBitmask(uint32 version); + static uint16 InventoryMapSize(int16 indexMap, ClientVersion clientVersion); + static uint64 PossessionsBitmask(ClientVersion clientVersion); + static uint64 EquipmentBitmask(ClientVersion clientVersion); + static uint64 GeneralBitmask(ClientVersion clientVersion); + static uint64 CursorBitmask(ClientVersion clientVersion); - static bool AllowsEmptyBagInBag(uint32 version); - static bool AllowsClickCastFromBag(uint32 version); + static bool AllowsEmptyBagInBag(ClientVersion clientVersion); + static bool AllowsClickCastFromBag(ClientVersion clientVersion); // items - static uint16 ItemCommonSize(uint32 version); - static uint16 ItemContainerSize(uint32 version); + static uint16 ItemCommonSize(ClientVersion clientVersion); + static uint16 ItemContainerSize(ClientVersion clientVersion); // player profile - static bool CoinHasWeight(uint32 version); + static bool CoinHasWeight(ClientVersion clientVersion); - static uint32 BandoliersCount(uint32 version); - static uint32 BandolierSize(uint32 version); + static uint32 BandoliersCount(ClientVersion clientVersion); + static uint32 BandolierSize(ClientVersion clientVersion); - static uint32 PotionBeltSize(uint32 version); + static uint32 PotionBeltSize(ClientVersion clientVersion); }; -#endif /* EQ_LIMITS_H */ +#endif /* EQ_DICTIONARY_H */ /* Working Notes: diff --git a/common/eq_stream_intf.h b/common/eq_stream_intf.h index 9373f2262..68b8ffc96 100644 --- a/common/eq_stream_intf.h +++ b/common/eq_stream_intf.h @@ -35,7 +35,7 @@ public: virtual const uint32 GetBytesRecieved() const { return 0; } virtual const uint32 GetBytesSentPerSecond() const { return 0; } virtual const uint32 GetBytesRecvPerSecond() const { return 0; } - virtual const EQClientVersion ClientVersion() const { return EQClientUnknown; } + virtual const ClientVersion GetClientVersion() const { return ClientVersion::Unknown; } }; #endif /*EQSTREAMINTF_H_*/ diff --git a/common/eq_stream_proxy.cpp b/common/eq_stream_proxy.cpp index 20fc4ea06..802afe7f2 100644 --- a/common/eq_stream_proxy.cpp +++ b/common/eq_stream_proxy.cpp @@ -22,9 +22,9 @@ std::string EQStreamProxy::Describe() const { return(m_structs->Describe()); } -const EQClientVersion EQStreamProxy::ClientVersion() const +const ClientVersion EQStreamProxy::GetClientVersion() const { - return m_structs->ClientVersion(); + return m_structs->GetClientVersion(); } void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) { diff --git a/common/eq_stream_proxy.h b/common/eq_stream_proxy.h index 34ea3a9fc..f82dd790f 100644 --- a/common/eq_stream_proxy.h +++ b/common/eq_stream_proxy.h @@ -27,7 +27,7 @@ public: virtual void RemoveData(); virtual bool CheckState(EQStreamState state); virtual std::string Describe() const; - virtual const EQClientVersion ClientVersion() const; + virtual const ClientVersion GetClientVersion() const; virtual const uint32 GetBytesSent() const; virtual const uint32 GetBytesRecieved() const; diff --git a/common/item.h b/common/item.h index 888d47d2b..975650e46 100644 --- a/common/item.h +++ b/common/item.h @@ -117,11 +117,11 @@ public: // Public Methods /////////////////////////////// - Inventory() { m_version = EQClientUnknown; m_versionset = false; } + Inventory() { m_version = ClientVersion::Unknown; m_versionset = false; } ~Inventory(); // Inventory v2 creep - bool SetInventoryVersion(EQClientVersion version) { + bool SetInventoryVersion(ClientVersion version) { if (!m_versionset) { m_version = version; return (m_versionset = true); @@ -131,7 +131,7 @@ public: } } - EQClientVersion GetInventoryVersion() { return m_version; } + ClientVersion GetInventoryVersion() { return m_version; } static void CleanDirty(); static void MarkDirty(ItemInst *inst); @@ -252,7 +252,7 @@ protected: private: // Active inventory version - EQClientVersion m_version; + ClientVersion m_version; bool m_versionset; }; diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 3ec0565bb..e6dfad3c3 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -114,9 +114,9 @@ namespace RoF return(r); } - const EQClientVersion Strategy::ClientVersion() const + const ClientVersion Strategy::GetClientVersion() const { - return EQClientRoF; + return ClientVersion::RoF; } #include "ss_define.h" diff --git a/common/patches/rof.h b/common/patches/rof.h index 220341970..328e5f7f1 100644 --- a/common/patches/rof.h +++ b/common/patches/rof.h @@ -23,7 +23,7 @@ namespace RoF { protected: virtual std::string Describe() const; - virtual const EQClientVersion ClientVersion() const; + virtual const ClientVersion GetClientVersion() const; //magic macro to declare our opcode processors #include "ss_declare.h" diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index c586fe260..59761c2b9 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -114,9 +114,9 @@ namespace RoF2 return(r); } - const EQClientVersion Strategy::ClientVersion() const + const ClientVersion Strategy::GetClientVersion() const { - return EQClientRoF2; + return ClientVersion::RoF2; } #include "ss_define.h" diff --git a/common/patches/rof2.h b/common/patches/rof2.h index b39849048..888fb3308 100644 --- a/common/patches/rof2.h +++ b/common/patches/rof2.h @@ -23,7 +23,7 @@ namespace RoF2 { protected: virtual std::string Describe() const; - virtual const EQClientVersion ClientVersion() const; + virtual const ClientVersion GetClientVersion() const; //magic macro to declare our opcode processors #include "ss_declare.h" diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index 09e219672..050701d3a 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -112,9 +112,9 @@ namespace SoD return(r); } - const EQClientVersion Strategy::ClientVersion() const + const ClientVersion Strategy::GetClientVersion() const { - return EQClientSoD; + return ClientVersion::SoD; } #include "ss_define.h" diff --git a/common/patches/sod.h b/common/patches/sod.h index 0377573c2..9935cbf2f 100644 --- a/common/patches/sod.h +++ b/common/patches/sod.h @@ -23,7 +23,7 @@ namespace SoD { protected: virtual std::string Describe() const; - virtual const EQClientVersion ClientVersion() const; + virtual const ClientVersion GetClientVersion() const; //magic macro to declare our opcode processors #include "ss_declare.h" diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index 07885944a..1aa0a05bb 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -112,9 +112,9 @@ namespace SoF return(r); } - const EQClientVersion Strategy::ClientVersion() const + const ClientVersion Strategy::GetClientVersion() const { - return EQClientSoF; + return ClientVersion::SoF; } #include "ss_define.h" diff --git a/common/patches/sof.h b/common/patches/sof.h index fc68ba334..15b9aa90c 100644 --- a/common/patches/sof.h +++ b/common/patches/sof.h @@ -23,7 +23,7 @@ namespace SoF { protected: virtual std::string Describe() const; - virtual const EQClientVersion ClientVersion() const; + virtual const ClientVersion GetClientVersion() const; //magic macro to declare our opcode processors #include "ss_declare.h" diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index 9aa8afad8..31579e91b 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -110,9 +110,9 @@ namespace Titanium return(r); } - const EQClientVersion Strategy::ClientVersion() const + const ClientVersion Strategy::GetClientVersion() const { - return EQClientTitanium; + return ClientVersion::Tit; } #include "ss_define.h" diff --git a/common/patches/titanium.h b/common/patches/titanium.h index 421ef319a..de8131545 100644 --- a/common/patches/titanium.h +++ b/common/patches/titanium.h @@ -23,7 +23,7 @@ namespace Titanium { protected: virtual std::string Describe() const; - virtual const EQClientVersion ClientVersion() const; + virtual const ClientVersion GetClientVersion() const; //magic macro to declare our opcode processors #include "ss_declare.h" diff --git a/common/patches/underfoot.cpp b/common/patches/underfoot.cpp index ba04ea9a7..33ea71653 100644 --- a/common/patches/underfoot.cpp +++ b/common/patches/underfoot.cpp @@ -112,9 +112,9 @@ namespace Underfoot return(r); } - const EQClientVersion Strategy::ClientVersion() const + const ClientVersion Strategy::GetClientVersion() const { - return EQClientUnderfoot; + return ClientVersion::Und; } #include "ss_define.h" diff --git a/common/patches/underfoot.h b/common/patches/underfoot.h index b14d4a420..4bf00b0e8 100644 --- a/common/patches/underfoot.h +++ b/common/patches/underfoot.h @@ -23,7 +23,7 @@ namespace Underfoot { protected: virtual std::string Describe() const; - virtual const EQClientVersion ClientVersion() const; + virtual const ClientVersion GetClientVersion() const; //magic macro to declare our opcode processors #include "ss_declare.h" diff --git a/common/struct_strategy.h b/common/struct_strategy.h index 224c1e31d..a6219a214 100644 --- a/common/struct_strategy.h +++ b/common/struct_strategy.h @@ -24,7 +24,7 @@ public: void Decode(EQApplicationPacket *p) const; virtual std::string Describe() const = 0; - virtual const EQClientVersion ClientVersion() const = 0; + virtual const ClientVersion GetClientVersion() const = 0; protected: //some common coders: diff --git a/loginserver/client.cpp b/loginserver/client.cpp index bc0a86fa8..bd1f282a5 100644 --- a/loginserver/client.cpp +++ b/loginserver/client.cpp @@ -24,7 +24,7 @@ extern ErrorLog *server_log; extern LoginServer server; -Client::Client(EQStream *c, ClientVersion v) +Client::Client(EQStream *c, LSClientVersion v) { connection = c; version = v; diff --git a/loginserver/client.h b/loginserver/client.h index c1b44dc6f..784b0ba4f 100644 --- a/loginserver/client.h +++ b/loginserver/client.h @@ -30,13 +30,13 @@ using namespace std; -enum ClientVersion +enum LSClientVersion { cv_titanium, cv_sod }; -enum ClientStatus +enum LSClientStatus { cs_not_sent_session_ready, cs_waiting_for_login, @@ -59,7 +59,7 @@ public: /** * Constructor, sets our connection to c and version to v */ - Client(EQStream *c, ClientVersion v); + Client(EQStream *c, LSClientVersion v); /** * Destructor. @@ -134,8 +134,8 @@ public: EQEmu::Random random; private: EQStream *connection; - ClientVersion version; - ClientStatus status; + LSClientVersion version; + LSClientStatus status; string account_name; unsigned int account_id; diff --git a/world/client.cpp b/world/client.cpp index 1ceca8284..e8f83f06b 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -89,7 +89,8 @@ Client::Client(EQStreamInterface* ieqs) ClientVersionBit = 0; numclients++; - ClientVersionBit = 1 << (eqs->ClientVersion() - 1); + if (eqs->GetClientVersion() != ClientVersion::Unknown) + ClientVersionBit = 1 << (static_cast(eqs->GetClientVersion()) - 1); } Client::~Client() { diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index a47c1f38b..5c62c5860 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -155,7 +155,7 @@ void Client::CalcItemBonuses(StatBonuses* newbon) { } //Power Source Slot - if (GetClientVersion() >= EQClientSoF) + if (GetClientVersion() >= ClientVersion::SoF) { const ItemInst* inst = m_inv[MainPowerSource]; if(inst) @@ -3086,7 +3086,7 @@ void Client::CalcItemScale() { changed = true; //Power Source Slot - if (GetClientVersion() >= EQClientSoF) + if (GetClientVersion() >= ClientVersion::SoF) { if(CalcItemScale(MainPowerSource, MainPowerSource)) changed = true; @@ -3180,7 +3180,7 @@ void Client::DoItemEnterZone() { changed = true; //Power Source Slot - if (GetClientVersion() >= EQClientSoF) + if (GetClientVersion() >= ClientVersion::SoF) { if(DoItemEnterZone(MainPowerSource, MainPowerSource)) changed = true; diff --git a/zone/bot.cpp b/zone/bot.cpp index 6e6201ee3..b6b464b07 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1375,7 +1375,7 @@ int32 Bot::GenerateBaseHitPoints() uint32 Post255; uint32 NormalSTA = GetSTA(); - if(GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= EQClientSoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) + if(GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= ClientVersion::SoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) { float SoDPost255; @@ -9332,7 +9332,7 @@ int32 Bot::GenerateBaseManaPoints() { case 'I': WisInt = INT; - if(GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= EQClientSoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) { + if(GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= ClientVersion::SoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) { if(WisInt > 100) { ConvertedWisInt = (((WisInt - 100) * 5 / 2) + 100); if(WisInt > 201) { @@ -9375,7 +9375,7 @@ int32 Bot::GenerateBaseManaPoints() case 'W': WisInt = WIS; - if(GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= EQClientSoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) { + if(GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= ClientVersion::SoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) { if(WisInt > 100) { ConvertedWisInt = (((WisInt - 100) * 5 / 2) + 100); if(WisInt > 201) { @@ -9614,7 +9614,7 @@ int32 Bot::GetMaxStat() { if (level < 61) { base = 255; } - else if (GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= EQClientSoF) { + else if (GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= ClientVersion::SoF) { base = 255 + 5 * (level - 60); } else if (level < 71) { @@ -10234,7 +10234,7 @@ int32 Bot::CalcBaseEndurance() int32 sta_end = 0; int Stats = 0; - if(GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= EQClientSoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) { + if(GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= ClientVersion::SoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) { int HeroicStats = 0; Stats = ((GetSTR() + GetSTA() + GetDEX() + GetAGI()) / 4); diff --git a/zone/client.cpp b/zone/client.cpp index dbf9508d4..cda1669e0 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -246,7 +246,7 @@ Client::Client(EQStreamInterface* ieqs) GlobalChatLimiterTimer = new Timer(RuleI(Chat, IntervalDurationMS)); AttemptedMessages = 0; TotalKarma = 0; - ClientVersion = EQClientUnknown; + ClientVersion = ClientVersion::Unknown; ClientVersionBit = 0; AggroCount = 0; RestRegenHP = 0; @@ -1440,7 +1440,7 @@ void Client::UpdateWho(uint8 remove) { else if (m_pp.anon >= 2) scl->anon = 2; - scl->ClientVersion = GetClientVersion(); + scl->ClientVersion = static_cast(GetClientVersion()); scl->tellsoff = tellsoff; scl->guild_id = guild_id; scl->LFG = LFG; @@ -1698,7 +1698,7 @@ void Client::SendManaUpdatePacket() { if (!Connected() || IsCasting()) return; - if (GetClientVersion() >= EQClientSoD) { + if (GetClientVersion() >= ClientVersion::SoD) { SendManaUpdate(); SendEnduranceUpdate(); } @@ -1734,7 +1734,7 @@ void Client::SendManaUpdatePacket() { for(int i = 0; i < MAX_GROUP_MEMBERS; ++i) - if(g->members[i] && g->members[i]->IsClient() && (g->members[i] != this) && (g->members[i]->CastToClient()->GetClientVersion() >= EQClientSoD)) + if(g->members[i] && g->members[i]->IsClient() && (g->members[i] != this) && (g->members[i]->CastToClient()->GetClientVersion() >= ClientVersion::SoD)) { g->members[i]->CastToClient()->QueuePacket(outapp); g->members[i]->CastToClient()->QueuePacket(outapp2); @@ -1914,7 +1914,7 @@ void Client::ReadBook(BookRequest_Struct *book) { BookText_Struct *out = (BookText_Struct *) outapp->pBuffer; out->window = book->window; - if(GetClientVersion() >= EQClientSoF) + if(GetClientVersion() >= ClientVersion::SoF) { const ItemInst *inst = m_inv[book->invslot]; if(inst) @@ -4065,7 +4065,7 @@ bool Client::GroupFollow(Client* inviter) { group->UpdateGroupAAs(); //Invite the inviter into the group first.....dont ask - if (inviter->GetClientVersion() < EQClientSoD) + if (inviter->GetClientVersion() < ClientVersion::SoD) { EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct)); GroupJoin_Struct* outgj = (GroupJoin_Struct*)outapp->pBuffer; @@ -4111,13 +4111,13 @@ bool Client::GroupFollow(Client* inviter) { return false; } - if (GetClientVersion() >= EQClientSoD) + if (GetClientVersion() >= ClientVersion::SoD) { SendGroupJoinAcknowledge(); } // Temporary hack for SoD, as things seem to work quite differently - if (inviter->IsClient() && inviter->GetClientVersion() >= EQClientSoD) + if (inviter->IsClient() && inviter->GetClientVersion() >= ClientVersion::SoD) { database.RefreshGroupFromDB(inviter); } @@ -4351,7 +4351,7 @@ void Client::IncrementAggroCount() { if (AggroCount == 1) SavedRaidRestTimer = rest_timer.GetRemainingTime(); - if(GetClientVersion() >= EQClientSoF) { + if(GetClientVersion() >= ClientVersion::SoF) { EQApplicationPacket *outapp = new EQApplicationPacket(OP_RestState, 1); char *Buffer = (char *)outapp->pBuffer; @@ -4396,7 +4396,7 @@ void Client::DecrementAggroCount() { rest_timer.Start(time_until_rest); - if(GetClientVersion() >= EQClientSoF) { + if(GetClientVersion() >= ClientVersion::SoF) { EQApplicationPacket *outapp = new EQApplicationPacket(OP_RestState, 5); char *Buffer = (char *)outapp->pBuffer; @@ -6805,7 +6805,7 @@ void Client::SendStatsWindow(Client* client, bool use_window) if(use_window) { if(final_stats.size() < 4096) { - uint32 Buttons = (client->GetClientVersion() < EQClientSoD) ? 0 : 1; + uint32 Buttons = (client->GetClientVersion() < ClientVersion::SoD) ? 0 : 1; client->SendWindow(0, POPUPID_UPDATE_SHOWSTATSWINDOW, Buttons, "Cancel", "Update", 0, 1, this, "", "%s", final_stats.c_str()); goto Extra_Info; } @@ -6841,7 +6841,7 @@ void Client::SendStatsWindow(Client* client, bool use_window) } void Client::SendAltCurrencies() { - if(GetClientVersion() >= EQClientSoF) { + if(GetClientVersion() >= ClientVersion::SoF) { uint32 count = zone->AlternateCurrencies.size(); if(count == 0) { return; @@ -7332,7 +7332,7 @@ void Client::SendMercPersonalInfo() if(mercData) { - if (GetClientVersion() >= EQClientRoF) + if (GetClientVersion() >= ClientVersion::RoF) { if (mercCount > 0) { diff --git a/zone/client.h b/zone/client.h index c89dc017c..8f596d52a 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1019,7 +1019,7 @@ public: inline int ActiveTasksInSet(int TaskSet) { return (taskstate ? taskstate->ActiveTasksInSet(TaskSet) :0); } inline int CompletedTasksInSet(int TaskSet) { return (taskstate ? taskstate->CompletedTasksInSet(TaskSet) :0); } - inline const EQClientVersion GetClientVersion() const { return ClientVersion; } + inline const ClientVersion GetClientVersion() const { return ClientVersion; } inline const uint32 GetClientVersionBit() const { return ClientVersionBit; } /** Adventure Stuff **/ @@ -1506,7 +1506,7 @@ private: Timer *GlobalChatLimiterTimer; //60 seconds uint32 AttemptedMessages; - EQClientVersion ClientVersion; + ClientVersion ClientVersion; uint32 ClientVersionBit; int XPRate; diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 1a05052ad..bc639b371 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -43,7 +43,7 @@ int32 Client::GetMaxStat() const { if (level < 61) { base = 255; } - else if (GetClientVersion() >= EQClientSoF) { + else if (GetClientVersion() >= ClientVersion::SoF) { base = 255 + 5 * (level - 60); } else if (level < 71) { @@ -367,7 +367,7 @@ uint32 Mob::GetClassLevelFactor(){ int32 Client::CalcBaseHP() { - if(GetClientVersion() >= EQClientSoF && RuleB(Character, SoDClientUseSoDHPManaEnd)) { + if(GetClientVersion() >= ClientVersion::SoF && RuleB(Character, SoDClientUseSoDHPManaEnd)) { int stats = GetSTA(); if(stats > 255) { stats = (stats - 255) / 2; @@ -973,7 +973,7 @@ int32 Client::CalcBaseMana() case 'I': WisInt = GetINT(); - if (GetClientVersion() >= EQClientSoF && RuleB(Character, SoDClientUseSoDHPManaEnd)) { + if (GetClientVersion() >= ClientVersion::SoF && RuleB(Character, SoDClientUseSoDHPManaEnd)) { if (WisInt > 100) { ConvertedWisInt = (((WisInt - 100) * 5 / 2) + 100); @@ -1008,7 +1008,7 @@ int32 Client::CalcBaseMana() case 'W': WisInt = GetWIS(); - if (GetClientVersion() >= EQClientSoF && RuleB(Character, SoDClientUseSoDHPManaEnd)) { + if (GetClientVersion() >= ClientVersion::SoF && RuleB(Character, SoDClientUseSoDHPManaEnd)) { if (WisInt > 100) { ConvertedWisInt = (((WisInt - 100) * 5 / 2) + 100); @@ -1925,7 +1925,7 @@ int32 Client::CalcBaseEndurance() { int32 base_end = 0; - if(GetClientVersion() >= EQClientSoF && RuleB(Character, SoDClientUseSoDHPManaEnd)) { + if(GetClientVersion() >= ClientVersion::SoF && RuleB(Character, SoDClientUseSoDHPManaEnd)) { double heroic_stats = (GetHeroicSTR() + GetHeroicSTA() + GetHeroicDEX() + GetHeroicAGI()) / 4.0f; double stats = (GetSTR() + GetSTA() + GetDEX() + GetAGI()) / 4.0f; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 2ba7c1b82..f09e9ecf4 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -509,7 +509,7 @@ void Client::CompleteConnect() if (IsInAGuild()){ uint8 rank = GuildRank(); - if (GetClientVersion() >= EQClientRoF) + if (GetClientVersion() >= ClientVersion::RoF) { switch (rank) { case 0: { rank = 5; break; } // GUILD_MEMBER 0 @@ -823,7 +823,7 @@ void Client::CompleteConnect() if (zone->GetZoneID() == RuleI(World, GuildBankZoneID) && GuildBanks) GuildBanks->SendGuildBank(this); - if (GetClientVersion() >= EQClientSoD) + if (GetClientVersion() >= ClientVersion::SoD) entity_list.SendFindableNPCList(this); if (IsInAGuild()) { @@ -1035,7 +1035,7 @@ void Client::Handle_Connect_OP_ReqClientSpawn(const EQApplicationPacket *app) outapp = new EQApplicationPacket(OP_SendExpZonein, 0); FastQueuePacket(&outapp); - if (GetClientVersion() >= EQClientRoF) + if (GetClientVersion() >= ClientVersion::RoF) { outapp = new EQApplicationPacket(OP_ClientReady, 0); FastQueuePacket(&outapp); @@ -1309,14 +1309,12 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) conn_state = ReceivedZoneEntry; - ClientVersion = Connection()->ClientVersion(); - if (ClientVersion != EQClientUnknown) - ClientVersionBit = 1 << (ClientVersion - 1); - else - ClientVersionBit = 0; + ClientVersion = Connection()->GetClientVersion(); + if (ClientVersion != ClientVersion::Unknown) + ClientVersionBit = 1 << (static_cast(ClientVersion) - 1); bool siv = m_inv.SetInventoryVersion(ClientVersion); - LogFile->write(EQEmuLog::Debug, "%s inventory version to %s(%i)", (siv ? "Succeeded in setting" : "Failed to set"), EQClientVersionName(ClientVersion), ClientVersion); + LogFile->write(EQEmuLog::Debug, "%s inventory version to %s(%i)", (siv ? "Succeeded in setting" : "Failed to set"), ClientVersionName(ClientVersion), ClientVersion); /* Antighost code tmp var is so the search doesnt find this object @@ -1499,7 +1497,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) m_pp.guild_id = GuildID(); uint8 rank = guild_mgr.GetDisplayedRank(GuildID(), GuildRank(), CharacterID()); // FIXME: RoF guild rank - if (GetClientVersion() >= EQClientRoF) { + if (GetClientVersion() >= ClientVersion::RoF) { switch (rank) { case 0: rank = 5; @@ -1850,7 +1848,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) /* Task Packets */ LoadClientTaskState(); - if (GetClientVersion() >= EQClientRoF) { + if (GetClientVersion() >= ClientVersion::RoF) { outapp = new EQApplicationPacket(OP_ReqNewZone, 0); Handle_Connect_OP_ReqNewZone(outapp); safe_delete(outapp); @@ -3079,7 +3077,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) // Delegate to tradeskill object to perform combine AugmentItem_Struct* in_augment = (AugmentItem_Struct*)app->pBuffer; bool deleteItems = false; - if (GetClientVersion() >= EQClientRoF) + if (GetClientVersion() >= ClientVersion::RoF) { ItemInst *itemOneToPush = nullptr, *itemTwoToPush = nullptr; @@ -5162,7 +5160,7 @@ void Client::Handle_OP_DeleteItem(const EQApplicationPacket *app) int16 AlcoholTolerance = GetSkill(SkillAlcoholTolerance); int16 IntoxicationIncrease; - if (GetClientVersion() < EQClientSoD) + if (GetClientVersion() < ClientVersion::SoD) IntoxicationIncrease = (200 - AlcoholTolerance) * 30 / 200 + 10; else IntoxicationIncrease = (270 - AlcoholTolerance) * 0.111111108 + 10; @@ -5479,7 +5477,7 @@ void Client::Handle_OP_EndLootRequest(const EQApplicationPacket *app) Entity* entity = entity_list.GetID(*((uint16*)app->pBuffer)); if (entity == 0) { Message(13, "Error: OP_EndLootRequest: Corpse not found (ent = 0)"); - if (GetClientVersion() >= EQClientSoD) + if (GetClientVersion() >= ClientVersion::SoD) Corpse::SendEndLootErrorPacket(this); else Corpse::SendLootReqErrorPacket(this); @@ -6845,7 +6843,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) uint32 Action = VARSTRUCT_DECODE_TYPE(uint32, Buffer); uint32 sentAction = Action; - if (GetClientVersion() >= EQClientRoF) + if (GetClientVersion() >= ClientVersion::RoF) { Action += 1; /* @@ -7412,7 +7410,7 @@ void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app) GuildInviteAccept_Struct* gj = (GuildInviteAccept_Struct*)app->pBuffer; - if (GetClientVersion() >= EQClientRoF) + if (GetClientVersion() >= ClientVersion::RoF) { if (gj->response > 9) { @@ -7472,7 +7470,7 @@ void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app) uint32 guildrank = gj->response; - if (GetClientVersion() >= EQClientRoF) + if (GetClientVersion() >= ClientVersion::RoF) { if (gj->response == 8) { @@ -8081,7 +8079,7 @@ void Client::Handle_OP_InspectRequest(const EQApplicationPacket *app) Mob* tmp = entity_list.GetMob(ins->TargetID); if (tmp != 0 && tmp->IsClient()) { - if (tmp->CastToClient()->GetClientVersion() < EQClientSoF) { tmp->CastToClient()->QueuePacket(app); } // Send request to target + if (tmp->CastToClient()->GetClientVersion() < ClientVersion::SoF) { tmp->CastToClient()->QueuePacket(app); } // Send request to target // Inspecting an SoF or later client will make the server handle the request else { ProcessInspectRequest(tmp->CastToClient(), this); } } @@ -8601,7 +8599,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) } else { - if (GetClientVersion() >= EQClientSoD && !inst->IsEquipable(GetBaseRace(), GetClass())) + if (GetClientVersion() >= ClientVersion::SoD && !inst->IsEquipable(GetBaseRace(), GetClass())) { if (item->ItemType != ItemTypeFood && item->ItemType != ItemTypeDrink && item->ItemType != ItemTypeAlcohol) { @@ -9436,14 +9434,14 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) return; } - mercTypeCount = tar->GetNumMercTypes(GetClientVersion()); - mercCount = tar->GetNumMercs(GetClientVersion()); + mercTypeCount = tar->GetNumMercTypes(static_cast(GetClientVersion())); + mercCount = tar->GetNumMercs(static_cast(GetClientVersion())); if (mercCount > MAX_MERC) return; - std::list mercTypeList = tar->GetMercTypesList(GetClientVersion()); - std::list mercDataList = tar->GetMercsList(GetClientVersion()); + std::list mercTypeList = tar->GetMercTypesList(static_cast(GetClientVersion())); + std::list mercDataList = tar->GetMercsList(static_cast(GetClientVersion())); int i = 0; int StanceCount = 0; @@ -11343,7 +11341,7 @@ void Client::Handle_OP_ReadBook(const EQApplicationPacket *app) } BookRequest_Struct* book = (BookRequest_Struct*)app->pBuffer; ReadBook(book); - if (GetClientVersion() >= EQClientSoF) + if (GetClientVersion() >= ClientVersion::SoF) { EQApplicationPacket EndOfBook(OP_FinishWindow, 0); QueuePacket(&EndOfBook); @@ -12660,7 +12658,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) { if (!HasSkill(SkillHide) && GetSkill(SkillHide) == 0) { - if (GetClientVersion() < EQClientSoF) + if (GetClientVersion() < ClientVersion::SoF) { char *hack_str = nullptr; MakeAnyLenString(&hack_str, "Player sent OP_SpawnAppearance with AT_Invis: %i", sa->parameter); @@ -13497,7 +13495,7 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) this->Trader_StartTrader(); - if (GetClientVersion() >= EQClientRoF) + if (GetClientVersion() >= ClientVersion::RoF) { EQApplicationPacket* outapp = new EQApplicationPacket(OP_Trader, sizeof(TraderStatus_Struct)); TraderStatus_Struct* tss = (TraderStatus_Struct*)outapp->pBuffer; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index fc94fd415..03714d5e5 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -124,7 +124,7 @@ bool Client::Process() { HandleRespawnFromHover(0); } - if(IsTracking() && (GetClientVersion() >= EQClientSoD) && TrackingTimer.Check()) + if(IsTracking() && (GetClientVersion() >= ClientVersion::SoD) && TrackingTimer.Check()) DoTracking(); if(hpupdate_timer.Check()) @@ -871,7 +871,7 @@ void Client::BulkSendInventoryItems() { } // Power Source - if(GetClientVersion() >= EQClientSoF) { + if(GetClientVersion() >= ClientVersion::SoF) { const ItemInst* inst = m_inv[MainPowerSource]; if(inst) { std::string packet = inst->Serialize(MainPowerSource); @@ -1792,7 +1792,7 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app) } } - if(GetClientVersion() >= EQClientSoF) { + if(GetClientVersion() >= ClientVersion::SoF) { // The following packet decreases the skill points left in the Training Window and // produces the 'You have increased your skill / learned the basics of' message. // diff --git a/zone/command.cpp b/zone/command.cpp index fe479848f..8d9b55b4c 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -2632,7 +2632,7 @@ void command_peekinv(Client *c, const Seperator *sep) indexMain, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_main == nullptr) ? 0 : inst_main->GetCharges())); } - if ((scopeWhere & peekWorn) && (targetClient->GetClientVersion() >= EQClientSoF)) { + if ((scopeWhere & peekWorn) && (targetClient->GetClientVersion() >= ClientVersion::SoF)) { inst_main = targetClient->GetInv().GetItem(MainPowerSource); item_data = (inst_main == nullptr) ? nullptr : inst_main->GetItem(); linker.SetItemInst(inst_main); diff --git a/zone/corpse.cpp b/zone/corpse.cpp index b860f02fe..12e1e4ba8 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -298,7 +298,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( // cash // Let's not move the cash when 'RespawnFromHover = true' && 'client->GetClientVersion() < EQClientSoF' since the client doesn't. // (change to first client that supports 'death hover' mode, if not SoF.) - if (!RuleB(Character, RespawnFromHover) || client->GetClientVersion() < EQClientSoF) { + if (!RuleB(Character, RespawnFromHover) || client->GetClientVersion() < ClientVersion::SoF) { SetCash(pp->copper, pp->silver, pp->gold, pp->platinum); pp->copper = 0; pp->silver = 0; @@ -317,7 +317,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( std::list removed_list; //bool cursor = false; for(i = MAIN_BEGIN; i < EmuConstants::MAP_POSSESSIONS_SIZE; i++) { - if(i == MainAmmo && client->GetClientVersion() >= EQClientSoF) { + if(i == MainAmmo && client->GetClientVersion() >= ClientVersion::SoF) { item = client->GetInv().GetItem(MainPowerSource); if((item && (!client->IsBecomeNPC())) || (item && client->IsBecomeNPC() && !item->GetItem()->NoRent)) { std::list slot_list = MoveItemToCorpse(client, item, MainPowerSource); @@ -1041,7 +1041,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a // This is required for the 'Loot All' feature to work for SoD clients. I expect it is to tell the client that the // server has now sent all the items on the corpse. - if(client->GetClientVersion() >= EQClientSoD) { SendLootReqErrorPacket(client, 6); } + if(client->GetClientVersion() >= ClientVersion::SoD) { SendLootReqErrorPacket(client, 6); } } void Corpse::LootItem(Client* client, const EQApplicationPacket* app) { diff --git a/zone/entity.cpp b/zone/entity.cpp index 6ec20832e..5b426f776 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -4378,7 +4378,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; diff --git a/zone/groups.cpp b/zone/groups.cpp index 1b26d47b4..27ff3b758 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -393,7 +393,7 @@ void Group::SendHPPacketsTo(Mob *member) { members[i]->CreateHPPacket(&hpapp); member->CastToClient()->QueuePacket(&hpapp, false); - if(member->CastToClient()->GetClientVersion() >= EQClientSoD) + if(member->CastToClient()->GetClientVersion() >= ClientVersion::SoD) { outapp.SetOpcode(OP_MobManaUpdate); MobManaUpdate_Struct *mmus = (MobManaUpdate_Struct *)outapp.pBuffer; @@ -424,7 +424,7 @@ void Group::SendHPPacketsFrom(Mob *member) if(members[i] && members[i] != member && members[i]->IsClient()) { members[i]->CastToClient()->QueuePacket(&hp_app); - if(members[i]->CastToClient()->GetClientVersion() >= EQClientSoD) + if(members[i]->CastToClient()->GetClientVersion() >= ClientVersion::SoD) { outapp.SetOpcode(OP_MobManaUpdate); MobManaUpdate_Struct *mmus = (MobManaUpdate_Struct *)outapp.pBuffer; @@ -564,7 +564,7 @@ bool Group::DelMemberOOZ(const char *Name) { if(GroupCount() < 3) { UnDelegateMarkNPC(NPCMarkerName.c_str()); - if(GetLeader() && GetLeader()->IsClient() && GetLeader()->CastToClient()->GetClientVersion() < EQClientSoD) { + if(GetLeader() && GetLeader()->IsClient() && GetLeader()->CastToClient()->GetClientVersion() < ClientVersion::SoD) { UnDelegateMainAssist(MainAssistName.c_str()); } ClearAllNPCMarks(); @@ -722,7 +722,7 @@ bool Group::DelMember(Mob* oldmember, bool ignoresender) if(GroupCount() < 3) { UnDelegateMarkNPC(NPCMarkerName.c_str()); - if(GetLeader() && GetLeader()->IsClient() && GetLeader()->CastToClient()->GetClientVersion() < EQClientSoD) { + if(GetLeader() && GetLeader()->IsClient() && GetLeader()->CastToClient()->GetClientVersion() < ClientVersion::SoD) { UnDelegateMainAssist(MainAssistName.c_str()); } ClearAllNPCMarks(); @@ -1567,7 +1567,7 @@ void Group::NotifyMainTank(Client *c, uint8 toggle) if(!MainTankName.size()) return; - if(c->GetClientVersion() < EQClientSoD) + if(c->GetClientVersion() < ClientVersion::SoD) { if(toggle) c->Message(0, "%s is now Main Tank.", MainTankName.c_str()); @@ -1607,7 +1607,7 @@ void Group::NotifyMainAssist(Client *c, uint8 toggle) if(!MainAssistName.size()) return; - if(c->GetClientVersion() < EQClientSoD) + if(c->GetClientVersion() < ClientVersion::SoD) { EQApplicationPacket *outapp = new EQApplicationPacket(OP_DelegateAbility, sizeof(DelegateAbility_Struct)); @@ -1662,7 +1662,7 @@ void Group::NotifyPuller(Client *c, uint8 toggle) if(!PullerName.size()) return; - if(c->GetClientVersion() < EQClientSoD) + if(c->GetClientVersion() < ClientVersion::SoD) { if(toggle) c->Message(0, "%s is now Puller.", PullerName.c_str()); @@ -2228,7 +2228,7 @@ void Group::ChangeLeader(Mob* newleader) for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) { if (members[i] && members[i]->IsClient()) { - if(members[i]->CastToClient()->GetClientVersion() >= EQClientSoD) + if(members[i]->CastToClient()->GetClientVersion() >= ClientVersion::SoD) members[i]->CastToClient()->SendGroupLeaderChangePacket(newleader->GetName()); members[i]->CastToClient()->QueuePacket(outapp); diff --git a/zone/guild.cpp b/zone/guild.cpp index 39785f3dd..05713f66f 100644 --- a/zone/guild.cpp +++ b/zone/guild.cpp @@ -64,7 +64,7 @@ void Client::SendGuildMOTD(bool GetGuildMOTDReply) { void Client::SendGuildURL() { - if(GetClientVersion() < EQClientSoF) + if(GetClientVersion() < ClientVersion::SoF) return; if(IsInAGuild()) @@ -85,7 +85,7 @@ void Client::SendGuildURL() void Client::SendGuildChannel() { - if(GetClientVersion() < EQClientSoF) + if(GetClientVersion() < ClientVersion::SoF) return; if(IsInAGuild()) @@ -107,7 +107,7 @@ void Client::SendGuildChannel() void Client::SendGuildRanks() { - if(GetClientVersion() < EQClientRoF) + if(GetClientVersion() < ClientVersion::RoF) return; int permissions = 30 + 1; //Static number of permissions in all EQ clients as of May 2014 @@ -150,7 +150,7 @@ void Client::SendGuildSpawnAppearance() { uint8 rank = guild_mgr.GetDisplayedRank(GuildID(), GuildRank(), CharacterID()); mlog(GUILDS__OUT_PACKETS, "Sending spawn appearance for guild %d at rank %d", GuildID(), rank); SendAppearancePacket(AT_GuildID, GuildID()); - if(GetClientVersion() >= EQClientRoF) + if(GetClientVersion() >= ClientVersion::RoF) { switch (rank) { case 0: { rank = 5; break; } // GUILD_MEMBER 0 diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index 5d42846e4..5f75ec801 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -322,7 +322,7 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { else if(c != nullptr && s->guild_id != GUILD_NONE) { //char is in zone, and has changed into a new guild, send MOTD. c->SendGuildMOTD(); - if(c->GetClientVersion() >= EQClientRoF) + if(c->GetClientVersion() >= ClientVersion::RoF) { c->SendGuildRanks(); } diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 20781b749..ff64a53bd 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -55,7 +55,7 @@ uint32 Client::NukeItem(uint32 itemnum, uint8 where_to_check) { x++; } - if (GetClientVersion() >= EQClientSoF) + if (GetClientVersion() >= ClientVersion::SoF) DeleteItemInInventory(MainPowerSource, 0, true); else DeleteItemInInventory(MainPowerSource, 0, false); // Prevents Titanium crash @@ -683,7 +683,7 @@ void Client::SendCursorBuffer() { // Temporary work-around for the RoF+ Client Buffer // Instead of dealing with client moving items in cursor buffer, // we can just send the next item in the cursor buffer to the cursor. - if (GetClientVersion() >= EQClientRoF) + if (GetClientVersion() >= ClientVersion::RoF) { if (!GetInv().CursorEmpty()) { @@ -937,7 +937,7 @@ bool Client::AutoPutLootInInventory(ItemInst& inst, bool try_worn, bool try_curs for (int16 i = EmuConstants::EQUIPMENT_BEGIN; i < MainPowerSource; i++) { // originally (i < 22) if (i == EmuConstants::GENERAL_BEGIN) { // added power source check for SoF+ clients - if (this->GetClientVersion() >= EQClientSoF) + if (this->GetClientVersion() >= ClientVersion::SoF) i = MainPowerSource; else break; @@ -2083,7 +2083,7 @@ void Client::RemoveNoRent(bool client_update) auto inst = m_inv[MainPowerSource]; if (inst && !inst->GetItem()->NoRent) { mlog(INVENTORY__SLOTS, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, MainPowerSource); - DeleteItemInInventory(MainPowerSource, 0, (GetClientVersion() >= EQClientSoF) ? client_update : false); // Ti slot non-existent + DeleteItemInInventory(MainPowerSource, 0, (GetClientVersion() >= ClientVersion::SoF) ? client_update : false); // Ti slot non-existent } } @@ -2301,7 +2301,7 @@ void Client::MoveSlotNotAllowed(bool client_update) bool is_arrow = (inst->GetItem()->ItemType == ItemTypeArrow) ? true : false; int16 free_slot_id = m_inv.FindFreeSlot(inst->IsType(ItemClassContainer), true, inst->GetItem()->Size, is_arrow); mlog(INVENTORY__ERROR, "Slot Assignment Error: Moving %s from slot %i to %i", inst->GetItem()->Name, MainPowerSource, free_slot_id); - PutItemInInventory(free_slot_id, *inst, (GetClientVersion() >= EQClientSoF) ? client_update : false); + PutItemInInventory(free_slot_id, *inst, (GetClientVersion() >= ClientVersion::SoF) ? client_update : false); database.SaveInventory(character_id, nullptr, MainPowerSource); safe_delete(inst); } diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index 5678bd24a..d931f0e36 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -834,7 +834,7 @@ void Lua_Client::SetAATitle(const char *title) { int Lua_Client::GetClientVersion() { Lua_Safe_Call_Int(); - return self->GetClientVersion(); + return static_cast(self->GetClientVersion()); } uint32 Lua_Client::GetClientVersionBit() { diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 034895172..b8c88422f 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -1758,12 +1758,15 @@ luabind::scope lua_register_client_version() { return luabind::class_("ClientVersion") .enum_("constants") [ - luabind::value("Unknown", static_cast(EQClientUnknown)), - luabind::value("Titanium", static_cast(EQClientTitanium)), - luabind::value("SoF", static_cast(EQClientSoF)), - luabind::value("SoD", static_cast(EQClientSoD)), - luabind::value("Underfoot", static_cast(EQClientUnderfoot)), - luabind::value("RoF", static_cast(EQClientRoF)) + luabind::value("Unknown", static_cast(ClientVersion::Unknown)), + luabind::value("Titanium", static_cast(ClientVersion::Tit)), // deprecated + luabind::value("Tit", static_cast(ClientVersion::Tit)), + luabind::value("SoF", static_cast(ClientVersion::SoF)), + luabind::value("SoD", static_cast(ClientVersion::SoD)), + luabind::value("Underfoot", static_cast(ClientVersion::Und)), // deprecated + luabind::value("Und", static_cast(ClientVersion::Und)), + luabind::value("RoF", static_cast(ClientVersion::RoF)), + luabind::value("RoF2", static_cast(ClientVersion::RoF2)) ]; } diff --git a/zone/merc.cpp b/zone/merc.cpp index 2f17d7ca3..187a23370 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -41,7 +41,7 @@ Merc::Merc(const NPCType* d, float x, float y, float z, float heading) _baseFR = d->FR; _basePR = d->PR; _baseCorrup = d->Corrup; - _OwnerClientVersion = EQClientTitanium; + _OwnerClientVersion = static_cast(ClientVersion::Tit); RestRegenHP = 0; RestRegenMana = 0; RestRegenEndurance = 0; @@ -1008,7 +1008,7 @@ int32 Merc::CalcBaseEndurance() int32 sta_end = 0; int Stats = 0; - if(GetClientVersion() >= EQClientSoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) { + if(GetClientVersion() >= static_cast(ClientVersion::SoD) && RuleB(Character, SoDClientUseSoDHPManaEnd)) { int HeroicStats = 0; Stats = ((GetSTR() + GetSTA() + GetDEX() + GetAGI()) / 4); @@ -4956,109 +4956,109 @@ void Client::SendMercResponsePackets(uint32 ResponseType) SendMercMerchantResponsePacket(6); break; case 7: //You must dismiss your suspended mercenary before purchasing a new one! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(7); else //You have the maximum number of mercenaries. You must dismiss one before purchasing a new one! SendMercMerchantResponsePacket(6); break; case 8: //You can not purchase a mercenary because your group is full! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(8); else SendMercMerchantResponsePacket(7); break; case 9: //You can not purchase a mercenary because you are in combat! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) //Mercenary failed to spawn! SendMercMerchantResponsePacket(3); else SendMercMerchantResponsePacket(8); break; case 10: //You have recently dismissed a mercenary and must wait a few more seconds before you can purchase a new one! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) //Mercenary failed to spawn! SendMercMerchantResponsePacket(3); else SendMercMerchantResponsePacket(9); break; case 11: //An error occurred created your mercenary! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(9); else SendMercMerchantResponsePacket(10); break; case 12: //Upkeep Charge Message - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(10); else SendMercMerchantResponsePacket(11); break; case 13: // ??? - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(11); else SendMercMerchantResponsePacket(12); break; case 14: //You ran out of funds to pay for your mercenary! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(12); else SendMercMerchantResponsePacket(13); break; case 15: // ??? - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(13); else SendMercMerchantResponsePacket(14); break; case 16: //Your mercenary is about to be suspended due to insufficient funds! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(14); else SendMercMerchantResponsePacket(15); break; case 17: //There is no mercenary liaison nearby! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(15); else SendMercMerchantResponsePacket(16); break; case 18: //You are too far from the liaison! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(16); else SendMercMerchantResponsePacket(17); break; case 19: //You do not meet the requirements for that mercenary! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) SendMercMerchantResponsePacket(17); else SendMercMerchantResponsePacket(18); break; case 20: //You are unable to interact with the liaison! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) //You are too far from the liaison! SendMercMerchantResponsePacket(16); else SendMercMerchantResponsePacket(19); break; case 21: //You do not have a high enough membership level to purchase this mercenary! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) //You do not meet the requirements for that mercenary! SendMercMerchantResponsePacket(17); else SendMercMerchantResponsePacket(20); break; case 22: //Your purchase has failed because this mercenary requires a Gold membership! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) //You do not meet the requirements for that mercenary! SendMercMerchantResponsePacket(17); else SendMercMerchantResponsePacket(21); break; case 23: //Your purchase has failed because this mercenary requires at least a Silver membership! - if (GetClientVersion() < EQClientRoF) + if (GetClientVersion() < ClientVersion::RoF) //You do not meet the requirements for that mercenary! SendMercMerchantResponsePacket(17); else @@ -5211,7 +5211,7 @@ bool Client::CheckCanSpawnMerc(uint32 template_id) { } // Check client version - if(GetClientVersion() < mercTemplate->ClientVersion) + if(static_cast(GetClientVersion()) < mercTemplate->ClientVersion) { SendMercResponsePackets(3); return false; @@ -5904,7 +5904,7 @@ void Client::UpdateMercLevel() { void Client::SendMercMerchantResponsePacket(int32 response_type) { // This response packet brings up the Mercenary Manager window - if(GetClientVersion() >= EQClientSoD) + if(GetClientVersion() >= ClientVersion::SoD) { EQApplicationPacket *outapp = new EQApplicationPacket(OP_MercenaryHire, sizeof(MercenaryMerchantResponse_Struct)); MercenaryMerchantResponse_Struct* mmr = (MercenaryMerchantResponse_Struct*)outapp->pBuffer; diff --git a/zone/object.cpp b/zone/object.cpp index c8bde8f1f..215707037 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -118,7 +118,7 @@ Object::Object(Client* client, const ItemInst* inst) m_data.heading = client->GetHeading(); m_data.x = client->GetX(); m_data.y = client->GetY(); - if (client->GetClientVersion() >= EQClientRoF2) + if (client->GetClientVersion() >= ClientVersion::RoF2) { // RoF2 places items at player's Z, which is 0.625 of their height. m_data.z = client->GetZ() - (client->GetSize() * 0.625f); diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 46b3b761a..537c62399 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -3899,7 +3899,7 @@ XS(XS_Client_GetClientVersion) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - RETVAL = THIS->GetClientVersion(); + RETVAL = static_cast(THIS->GetClientVersion()); XSprePUSH; PUSHu((UV)RETVAL); } XSRETURN(1); diff --git a/zone/raids.cpp b/zone/raids.cpp index 3bed5af2e..2a5c94bdd 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -1529,7 +1529,7 @@ void Raid::SendHPPacketsTo(Client *c) { members[x].member->CreateHPPacket(&hpapp); c->QueuePacket(&hpapp, false); - if(c->GetClientVersion() >= EQClientSoD) + if(c->GetClientVersion() >= ClientVersion::SoD) { outapp.SetOpcode(OP_MobManaUpdate); MobManaUpdate_Struct *mmus = (MobManaUpdate_Struct *)outapp.pBuffer; @@ -1565,7 +1565,7 @@ void Raid::SendHPPacketsFrom(Mob *m) if(!m->IsClient() || ((members[x].member != m->CastToClient()) && (members[x].GroupNumber == gid))) { members[x].member->QueuePacket(&hpapp, false); - if(members[x].member->GetClientVersion() >= EQClientSoD) + if(members[x].member->GetClientVersion() >= ClientVersion::SoD) { outapp.SetOpcode(OP_MobManaUpdate); MobManaUpdate_Struct *mmus = (MobManaUpdate_Struct *)outapp.pBuffer; diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 507c361dd..bab750edf 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -3408,7 +3408,7 @@ void Mob::BuffProcess() { CastToClient()->SendBuffDurationPacket(buffs[buffs_i]); // Hack to get UF to play nicer, RoF seems fine without it - if (CastToClient()->GetClientVersion() == EQClientUnderfoot && buffs[buffs_i].numhits > 0) + if (CastToClient()->GetClientVersion() == ClientVersion::Und && buffs[buffs_i].numhits > 0) CastToClient()->SendBuffNumHitPacket(buffs[buffs_i], buffs_i); buffs[buffs_i].UpdateClient = false; } diff --git a/zone/spells.cpp b/zone/spells.cpp index 96a1f87dd..ac111a006 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -255,7 +255,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, uint16 slot, bitmask = bitmask << (CastToClient()->GetClass() - 1); if( itm && itm->GetItem()->Classes != 65535 ) { if ((itm->GetItem()->Click.Type == ET_EquipClick) && !(itm->GetItem()->Classes & bitmask)) { - if (CastToClient()->GetClientVersion() < EQClientSoF) { + if (CastToClient()->GetClientVersion() < ClientVersion::SoF) { // They are casting a spell from an item that requires equipping but shouldn't let them equip it LogFile->write(EQEmuLog::Error, "HACKER: %s (account: %s) attempted to click an equip-only effect on item %s (id: %d) which they shouldn't be able to equip!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID); @@ -267,14 +267,14 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, uint16 slot, return(false); } if ((itm->GetItem()->Click.Type == ET_ClickEffect2) && !(itm->GetItem()->Classes & bitmask)) { - if (CastToClient()->GetClientVersion() < EQClientSoF) { + if (CastToClient()->GetClientVersion() < ClientVersion::SoF) { // They are casting a spell from an item that they don't meet the race/class requirements to cast LogFile->write(EQEmuLog::Error, "HACKER: %s (account: %s) attempted to click a race/class restricted effect on item %s (id: %d) which they shouldn't be able to click!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID); database.SetHackerFlag(CastToClient()->AccountName(), CastToClient()->GetCleanName(), "Clicking race/class restricted item with an invalid class"); } else { - if (CastToClient()->GetClientVersion() >= EQClientRoF) + if (CastToClient()->GetClientVersion() >= ClientVersion::RoF) { // Line 181 in eqstr_us.txt was changed in RoF+ Message(15, "Your race, class, or deity cannot use this item."); @@ -288,7 +288,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, uint16 slot, } } if( itm && (itm->GetItem()->Click.Type == ET_EquipClick) && !(item_slot <= MainAmmo || item_slot == MainPowerSource) ){ - if (CastToClient()->GetClientVersion() < EQClientSoF) { + if (CastToClient()->GetClientVersion() < ClientVersion::SoF) { // They are attempting to cast a must equip clicky without having it equipped LogFile->write(EQEmuLog::Error, "HACKER: %s (account: %s) attempted to click an equip-only effect on item %s (id: %d) without equiping it!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID); database.SetHackerFlag(CastToClient()->AccountName(), CastToClient()->GetCleanName(), "Clicking equip-only item without equiping it"); @@ -5251,7 +5251,7 @@ void Client::SendBuffDurationPacket(Buffs_Struct &buff) void Client::SendBuffNumHitPacket(Buffs_Struct &buff, int slot) { // UF+ use this packet - if (GetClientVersion() < EQClientUnderfoot) + if (GetClientVersion() < ClientVersion::Und) return; EQApplicationPacket *outapp; outapp = new EQApplicationPacket(OP_BuffCreate, sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct)); diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 431a7554c..452773970 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -975,7 +975,7 @@ void TaskManager::TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, i void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *TaskList) { - if (c->GetClientVersion() >= EQClientRoF) + if (c->GetClientVersion() >= ClientVersion::RoF) { SendTaskSelectorNew(c, mob, TaskCount, TaskList); return; @@ -2516,7 +2516,7 @@ void TaskManager::SendTaskActivityShort(Client *c, int TaskID, int ActivityID, i void TaskManager::SendTaskActivityLong(Client *c, int TaskID, int ActivityID, int ClientTaskIndex, bool Optional, bool TaskComplete) { - if (c->GetClientVersion() >= EQClientRoF) + if (c->GetClientVersion() >= ClientVersion::RoF) { SendTaskActivityNew(c, TaskID, ActivityID, ClientTaskIndex, Optional, TaskComplete); return; diff --git a/zone/trading.cpp b/zone/trading.cpp index d8c67588f..a31d45f89 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -2665,7 +2665,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { VARSTRUCT_ENCODE_TYPE(uint32, Buf, Quantity); VARSTRUCT_ENCODE_TYPE(uint32, Buf, Quantity * Price); - if(GetClientVersion() >= EQClientSoD) + if(GetClientVersion() >= ClientVersion::SoD) { VARSTRUCT_ENCODE_TYPE(uint32, Buf, 0); // Think this is the upper 32 bits of a 64 bit price } @@ -2690,7 +2690,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { VARSTRUCT_ENCODE_TYPE(uint32, Buf, Quantity); VARSTRUCT_ENCODE_TYPE(uint32, Buf, Quantity * Price); - if(Buyer->GetClientVersion() >= EQClientSoD) + if(Buyer->GetClientVersion() >= ClientVersion::SoD) { VARSTRUCT_ENCODE_TYPE(uint32, Buf, 0); // Think this is the upper 32 bits of a 64 bit price } diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index d76fec5c0..834f56a0c 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -874,7 +874,7 @@ void WorldServer::Process() { database.SetGroupLeaderName(group->GetID(), Inviter->GetName()); group->UpdateGroupAAs(); - if(Inviter->CastToClient()->GetClientVersion() < EQClientSoD) + if(Inviter->CastToClient()->GetClientVersion() < ClientVersion::SoD) { EQApplicationPacket* outapp=new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct)); GroupJoin_Struct* outgj=(GroupJoin_Struct*)outapp->pBuffer; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 0007b9e74..b9c66b11f 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -2631,7 +2631,7 @@ void ZoneDatabase::RefreshGroupFromDB(Client *client){ client->QueuePacket(outapp); safe_delete(outapp); - if(client->GetClientVersion() >= EQClientSoD) { + if(client->GetClientVersion() >= ClientVersion::SoD) { group->NotifyMainTank(client, 1); group->NotifyPuller(client, 1); } diff --git a/zone/zoning.cpp b/zone/zoning.cpp index f50c6b798..b5d6d5d25 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -555,7 +555,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z if (entity == 0) { Message(13, "Error: OP_EndLootRequest: Corpse not found (ent = 0)"); - if (GetClientVersion() >= EQClientSoD) + if (GetClientVersion() >= ClientVersion::SoD) Corpse::SendEndLootErrorPacket(this); else Corpse::SendLootReqErrorPacket(this); From 5c56929a23303c0c63844ad8eda1b55b61c73a1d Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Tue, 20 Jan 2015 00:04:22 -0500 Subject: [PATCH 249/253] Fix compile error with GCC --- zone/client.cpp | 2 +- zone/client.h | 5 +++-- zone/client_mods.cpp | 2 +- zone/client_packet.cpp | 10 +++++----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index cda1669e0..b7d52e82d 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -246,7 +246,7 @@ Client::Client(EQStreamInterface* ieqs) GlobalChatLimiterTimer = new Timer(RuleI(Chat, IntervalDurationMS)); AttemptedMessages = 0; TotalKarma = 0; - ClientVersion = ClientVersion::Unknown; + m_ClientVersion = ClientVersion::Unknown; ClientVersionBit = 0; AggroCount = 0; RestRegenHP = 0; diff --git a/zone/client.h b/zone/client.h index 8f596d52a..cc9eb7f77 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1019,8 +1019,9 @@ public: inline int ActiveTasksInSet(int TaskSet) { return (taskstate ? taskstate->ActiveTasksInSet(TaskSet) :0); } inline int CompletedTasksInSet(int TaskSet) { return (taskstate ? taskstate->CompletedTasksInSet(TaskSet) :0); } - inline const ClientVersion GetClientVersion() const { return ClientVersion; } + inline const ClientVersion GetClientVersion() const { return m_ClientVersion; } inline const uint32 GetClientVersionBit() const { return ClientVersionBit; } + inline void SetClientVersion(ClientVersion in) { m_ClientVersion = in; } /** Adventure Stuff **/ void SendAdventureError(const char *error); @@ -1506,7 +1507,7 @@ private: Timer *GlobalChatLimiterTimer; //60 seconds uint32 AttemptedMessages; - ClientVersion ClientVersion; + ClientVersion m_ClientVersion; uint32 ClientVersionBit; int XPRate; diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index bc639b371..1d64cd2c0 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -1172,7 +1172,7 @@ uint32 Client::CalcCurrentWeight() { */ // SoD+ client has no weight for coin - if (EQLimits::CoinHasWeight(ClientVersion)) + if (EQLimits::CoinHasWeight(GetClientVersion())) Total += (m_pp.platinum + m_pp.gold + m_pp.silver + m_pp.copper) / 4; float Packrat = (float)spellbonuses.Packrat + (float)aabonuses.Packrat + (float)itembonuses.Packrat; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index f09e9ecf4..46c00bf3f 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1309,12 +1309,12 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) conn_state = ReceivedZoneEntry; - ClientVersion = Connection()->GetClientVersion(); - if (ClientVersion != ClientVersion::Unknown) - ClientVersionBit = 1 << (static_cast(ClientVersion) - 1); + SetClientVersion(Connection()->GetClientVersion()); + if (m_ClientVersion != ClientVersion::Unknown) + ClientVersionBit = 1 << (static_cast(m_ClientVersion) - 1); - bool siv = m_inv.SetInventoryVersion(ClientVersion); - LogFile->write(EQEmuLog::Debug, "%s inventory version to %s(%i)", (siv ? "Succeeded in setting" : "Failed to set"), ClientVersionName(ClientVersion), ClientVersion); + bool siv = m_inv.SetInventoryVersion(m_ClientVersion); + LogFile->write(EQEmuLog::Debug, "%s inventory version to %s(%i)", (siv ? "Succeeded in setting" : "Failed to set"), ClientVersionName(m_ClientVersion), m_ClientVersion); /* Antighost code tmp var is so the search doesnt find this object From 4b0f5064f6e51871bfeb6ff2276956b04dbf0587 Mon Sep 17 00:00:00 2001 From: Uleat Date: Tue, 20 Jan 2015 01:19:08 -0500 Subject: [PATCH 250/253] Fix for Inventory::_HasItemByUse(bucket) using the parent container when searching for bag container items --- changelog.txt | 5 ++++- common/item.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 6cdfa59ee..4f9aea4d3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,10 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 01/20/2015 == +Uleat: Fix for Inventory::_HasItemByUse(bucket) using the parent container when searching for bag container items. + == 01/19/2015 == -Uleat: Changed 'enum EQClientVersion' to 'enum class ClientVersion.' Other light modifications were made to accomodate this namespace. Added 'RoF2' to the lua client version enumeration. +Uleat: Changed 'enum EQClientVersion' to 'enum class ClientVersion.' Other light modifications were made to accommodate this namespace. Added 'RoF2' to the lua client version enumeration. == 01/15/2015 == Uleat: Attempted fix for elusive inventory bug: diff --git a/common/item.cpp b/common/item.cpp index 533a0817b..ce1690aaf 100644 --- a/common/item.cpp +++ b/common/item.cpp @@ -1259,7 +1259,7 @@ int16 Inventory::_HasItemByUse(std::map& bucket, uint8 use, ui if (!inst->IsType(ItemClassContainer)) { continue; } - for (auto bag_iter = bucket.begin(); bag_iter != bucket.end(); ++bag_iter) { + for (auto bag_iter = inst->_begin(); bag_iter != inst->_end(); ++bag_iter) { auto bag_inst = bag_iter->second; if (bag_inst == nullptr) { continue; } From ee108b5b74f9811b144ad4e0edec401a3042e650 Mon Sep 17 00:00:00 2001 From: JJ Date: Tue, 20 Jan 2015 15:33:26 -0500 Subject: [PATCH 251/253] Skill gain logging fix. (iluvseq) --- zone/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index b7d52e82d..a1bea2a96 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -2232,10 +2232,10 @@ bool Client::CheckIncreaseSkill(SkillUseTypes skillid, Mob *against_who, int cha if(zone->random.Real(0, 99) < Chance) { SetSkill(skillid, GetRawSkill(skillid) + 1); - _log(SKILLS__GAIN, "Skill %d at value %d successfully gain with %.4f%%chance (mod %d)", skillid, skillval, Chance, chancemodi); + _log(SKILLS__GAIN, "Skill %d at value %d successfully gain with %d%%chance (mod %d)", skillid, skillval, Chance, chancemodi); return true; } else { - _log(SKILLS__GAIN, "Skill %d at value %d failed to gain with %.4f%%chance (mod %d)", skillid, skillval, Chance, chancemodi); + _log(SKILLS__GAIN, "Skill %d at value %d failed to gain with %d%%chance (mod %d)", skillid, skillval, Chance, chancemodi); } } else { _log(SKILLS__GAIN, "Skill %d at value %d cannot increase due to maxmum %d", skillid, skillval, maxskill); From a84f480ffc32f811f7a7d94373e846f7ab6f4d25 Mon Sep 17 00:00:00 2001 From: JJ Date: Tue, 20 Jan 2015 15:51:00 -0500 Subject: [PATCH 252/253] ... and lang. --- zone/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index a1bea2a96..f6b96aa46 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -2259,10 +2259,10 @@ void Client::CheckLanguageSkillIncrease(uint8 langid, uint8 TeacherSkill) { if(zone->random.Real(0,100) < Chance) { // if they make the roll IncreaseLanguageSkill(langid); // increase the language skill by 1 - _log(SKILLS__GAIN, "Language %d at value %d successfully gain with %.4f%%chance", langid, LangSkill, Chance); + _log(SKILLS__GAIN, "Language %d at value %d successfully gain with %d%%chance", langid, LangSkill, Chance); } else - _log(SKILLS__GAIN, "Language %d at value %d failed to gain with %.4f%%chance", langid, LangSkill, Chance); + _log(SKILLS__GAIN, "Language %d at value %d failed to gain with %d%%chance", langid, LangSkill, Chance); } } From ad711b0b5aba01927c5e01242b72b2a3f250def8 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Tue, 20 Jan 2015 17:35:39 -0500 Subject: [PATCH 253/253] Fix for compile issue with vs2012 --- zone/aa.cpp | 16 ++++++++-------- zone/client.cpp | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/zone/aa.cpp b/zone/aa.cpp index 0f94b8c72..b1c561c9e 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -547,9 +547,9 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u summon_count = MAX_SWARM_PETS; static const xy_location swarmPetLocations[MAX_SWARM_PETS] = { - {5, 5}, {-5, 5}, {5, -5}, {-5, -5}, - {10, 10}, {-10, 10}, {10, -10}, {-10, -10}, - {8, 8}, {-8, 8}, {8, -8}, {-8, -8} + xy_location(5, 5), xy_location(-5, 5), xy_location(5, -5), xy_location(-5, -5), + xy_location(10, 10), xy_location(-10, 10), xy_location(10, -10), xy_location(-10, -10), + xy_location(8, 8), xy_location(-8, 8), xy_location(8, -8), xy_location(-8, -8) }; while(summon_count > 0) { @@ -643,11 +643,11 @@ void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_overrid if(summon_count > MAX_SWARM_PETS) summon_count = MAX_SWARM_PETS; - static const xy_location swarmPetLocations[MAX_SWARM_PETS] = { - {5, 5}, {-5, 5}, {5, -5}, {-5, -5}, - {10, 10}, {-10, 10}, {10, -10}, {-10, -10}, - {8, 8}, {-8, 8}, {8, -8}, {-8, -8} - }; + static const xy_location swarmPetLocations[MAX_SWARM_PETS] = { + xy_location(5, 5), xy_location(-5, 5), xy_location(5, -5), xy_location(-5, -5), + xy_location(10, 10), xy_location(-10, 10), xy_location(10, -10), xy_location(-10, -10), + xy_location(8, 8), xy_location(-8, 8), xy_location(8, -8), xy_location(-8, -8) + };; while(summon_count > 0) { int pet_duration = pet.duration; diff --git a/zone/client.cpp b/zone/client.cpp index f6b96aa46..feb47dc6f 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -6275,9 +6275,9 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid summon_count = MAX_SWARM_PETS; static const xy_location swarmPetLocations[MAX_SWARM_PETS] = { - {5, 5}, {-5, 5}, {5, -5}, {-5, -5}, - {10, 10}, {-10, 10}, {10, -10}, {-10, -10}, - {8, 8}, {-8, 8}, {8, -8}, {-8, -8} + xy_location(5, 5), xy_location(-5, 5), xy_location(5, -5), xy_location(-5, -5), + xy_location(10, 10), xy_location(-10, 10), xy_location(10, -10), xy_location(-10, -10), + xy_location(8, 8), xy_location(-8, 8), xy_location(8, -8), xy_location(-8, -8) }; while(summon_count > 0) {