From 2529a7700eac258be1ba63df94170ab488c3149b Mon Sep 17 00:00:00 2001 From: KimLS Date: Sat, 22 Jun 2013 01:32:41 -0700 Subject: [PATCH] Fix for luabind not compiling (jumbers), bunch of api upgrades for lua, changed where spells and items load quests from, removed some old code. etc etc. --- common/Item.cpp | 393 ++++++++++------------- common/Item.h | 96 +++--- common/features.h | 9 +- common/shareddb.cpp | 7 +- luabind/luabind/detail/call_function.hpp | 5 +- luabind/luabind/detail/call_member.hpp | 4 +- luabind/luabind/wrapper_base.hpp | 4 +- zone/CMakeLists.txt | 2 - zone/QuestParserCollection.cpp | 104 +++++- zone/bonuses.cpp | 40 ++- zone/client.cpp | 12 +- zone/client.h | 9 +- zone/client_packet.cpp | 4 - zone/client_process.cpp | 4 - zone/entity.cpp | 145 --------- zone/lua_client.cpp | 8 +- zone/lua_client.h | 3 +- zone/lua_corpse.h | 2 +- zone/lua_door.h | 2 +- zone/lua_entity.h | 2 +- zone/lua_entity_list.h | 2 +- zone/lua_group.h | 2 +- zone/lua_hate_list.h | 2 +- zone/lua_inventory.h | 2 +- zone/lua_item.h | 2 +- zone/lua_iteminst.cpp | 53 +-- zone/lua_iteminst.h | 5 +- zone/lua_mob.h | 3 +- zone/lua_npc.h | 2 +- zone/lua_object.h | 2 +- zone/lua_parser.cpp | 4 +- zone/lua_parser_events.cpp | 22 +- zone/lua_parser_events.h | 4 +- zone/lua_raid.h | 2 +- zone/lua_spell.h | 2 +- zone/mob.cpp | 14 - zone/perl_questitem.cpp | 2 +- zone/spells.cpp | 9 - zone/tradeskills.cpp | 15 +- zone/updatemgr.cpp | 187 ----------- zone/updatemgr.h | 89 ----- zone/zoning.cpp | 5 - 42 files changed, 426 insertions(+), 859 deletions(-) delete mode 100644 zone/updatemgr.cpp delete mode 100644 zone/updatemgr.h diff --git a/common/Item.cpp b/common/Item.cpp index 62e4d3d91..0d03bc5c7 100644 --- a/common/Item.cpp +++ b/common/Item.cpp @@ -65,6 +65,13 @@ ItemInst::ItemInst(const Item_Struct* item, int16 charges) { m_color = 0; m_merchantcount = 1; m_SerialNumber = GetNextItemInstSerialNumber(); + + m_exp = 0; + m_evolveLvl = 0; + m_activated = false; + m_scaledItem = nullptr; + m_evolveInfo = nullptr; + m_scaling = false; } ItemInst::ItemInst(SharedDatabase *db, uint32 item_id, int16 charges) { @@ -80,6 +87,13 @@ ItemInst::ItemInst(SharedDatabase *db, uint32 item_id, int16 charges) { m_color = 0; m_merchantcount = 1; m_SerialNumber = GetNextItemInstSerialNumber(); + + m_exp = 0; + m_evolveLvl = 0; + m_activated = false; + m_scaledItem = nullptr; + m_evolveInfo = nullptr; + m_scaling = false; } ItemInstQueue::~ItemInstQueue() { @@ -171,12 +185,29 @@ ItemInst::ItemInst(const ItemInst& copy) m_SerialNumber = copy.m_SerialNumber; m_custom_data = copy.m_custom_data; m_timers = copy.m_timers; + + m_exp = copy.m_exp; + m_evolveLvl = copy.m_evolveLvl; + m_activated = copy.m_activated; + if (copy.m_scaledItem) + m_scaledItem = new Item_Struct(*copy.m_scaledItem); + else + m_scaledItem = nullptr; + + if(copy.m_evolveInfo) + m_evolveInfo = new EvolveInfo(*copy.m_evolveInfo); + else + m_evolveInfo = nullptr; + + m_scaling = copy.m_scaling; } // Clean up container contents ItemInst::~ItemInst() { Clear(); + safe_delete(m_scaledItem); + safe_delete(m_evolveInfo); } // Clone a type of ItemInst object @@ -649,6 +680,136 @@ void ItemInst::ClearTimers() { m_timers.clear(); } +const Item_Struct* ItemInst::GetItem() const { + if(!m_scaledItem) + return m_item; + else + return m_scaledItem; +} + +const Item_Struct* ItemInst::GetUnscaledItem() const { + return m_item; +} + +void ItemInst::Initialize(SharedDatabase *db) { + // if there's no actual item, don't do anything + if(!m_item) + return; + + // initialize scaling items + if (m_item->CharmFileID != 0) { + m_scaling = true; + ScaleItem(); + } + + // initialize evolving items + else if ((db) && m_item->LoreGroup >= 1000 && m_item->LoreGroup != -1) { + // not complete yet + } +} + +void ItemInst::ScaleItem() { + if(m_scaledItem) { + memcpy(m_scaledItem, m_item, sizeof(Item_Struct)); + } else { + m_scaledItem = new Item_Struct(*m_item); + } + + float Mult = (float)(GetExp())/10000; // scaling is determined by exp, with 10,000 being full stats + + m_scaledItem->AStr = (int8)((float)m_item->AStr*Mult); + m_scaledItem->ASta = (int8)((float)m_item->ASta*Mult); + m_scaledItem->AAgi = (int8)((float)m_item->AAgi*Mult); + m_scaledItem->ADex = (int8)((float)m_item->ADex*Mult); + m_scaledItem->AInt = (int8)((float)m_item->AInt*Mult); + m_scaledItem->AWis = (int8)((float)m_item->AWis*Mult); + m_scaledItem->ACha = (int8)((float)m_item->ACha*Mult); + + m_scaledItem->MR = (int8)((float)m_item->MR*Mult); + m_scaledItem->PR = (int8)((float)m_item->PR*Mult); + m_scaledItem->DR = (int8)((float)m_item->DR*Mult); + m_scaledItem->CR = (int8)((float)m_item->CR*Mult); + m_scaledItem->FR = (int8)((float)m_item->FR*Mult); + + m_scaledItem->HP = (int32)((float)m_item->HP*Mult); + m_scaledItem->Mana = (int32)((float)m_item->Mana*Mult); + m_scaledItem->AC = (int32)((float)m_item->AC*Mult); + + m_scaledItem->SkillModValue = (int32)((float)m_item->SkillModValue*Mult); + m_scaledItem->BaneDmgAmt = (int8)((float)m_item->BaneDmgAmt*Mult); + m_scaledItem->BardValue = (int32)((float)m_item->BardValue*Mult); + m_scaledItem->ElemDmgAmt = (uint8)((float)m_item->ElemDmgAmt*Mult); + m_scaledItem->Damage = (uint32)((float)m_item->Damage*Mult); + + m_scaledItem->CombatEffects = (int8)((float)m_item->CombatEffects*Mult); + m_scaledItem->Shielding = (int8)((float)m_item->Shielding*Mult); + m_scaledItem->StunResist = (int8)((float)m_item->StunResist*Mult); + m_scaledItem->StrikeThrough = (int8)((float)m_item->StrikeThrough*Mult); + m_scaledItem->ExtraDmgAmt = (uint32)((float)m_item->ExtraDmgAmt*Mult); + m_scaledItem->SpellShield = (int8)((float)m_item->SpellShield*Mult); + m_scaledItem->Avoidance = (int8)((float)m_item->Avoidance*Mult); + m_scaledItem->Accuracy = (int8)((float)m_item->Accuracy*Mult); + + m_scaledItem->FactionAmt1 = (int32)((float)m_item->FactionAmt1*Mult); + m_scaledItem->FactionAmt2 = (int32)((float)m_item->FactionAmt2*Mult); + m_scaledItem->FactionAmt3 = (int32)((float)m_item->FactionAmt3*Mult); + m_scaledItem->FactionAmt4 = (int32)((float)m_item->FactionAmt4*Mult); + + m_scaledItem->Endur = (uint32)((float)m_item->Endur*Mult); + m_scaledItem->DotShielding = (uint32)((float)m_item->DotShielding*Mult); + m_scaledItem->Attack = (uint32)((float)m_item->Attack*Mult); + m_scaledItem->Regen = (uint32)((float)m_item->Regen*Mult); + m_scaledItem->ManaRegen = (uint32)((float)m_item->ManaRegen*Mult); + m_scaledItem->EnduranceRegen = (uint32)((float)m_item->EnduranceRegen*Mult); + m_scaledItem->Haste = (uint32)((float)m_item->Haste*Mult); + m_scaledItem->DamageShield = (uint32)((float)m_item->DamageShield*Mult); + + m_scaledItem->Purity = (uint32)((float)m_item->Purity*Mult); + m_scaledItem->BackstabDmg = (uint32)((float)m_item->BackstabDmg*Mult); + m_scaledItem->DSMitigation = (uint32)((float)m_item->DSMitigation*Mult); + m_scaledItem->HeroicStr = (int32)((float)m_item->HeroicStr*Mult); + m_scaledItem->HeroicInt = (int32)((float)m_item->HeroicInt*Mult); + m_scaledItem->HeroicWis = (int32)((float)m_item->HeroicWis*Mult); + m_scaledItem->HeroicAgi = (int32)((float)m_item->HeroicAgi*Mult); + m_scaledItem->HeroicDex = (int32)((float)m_item->HeroicDex*Mult); + m_scaledItem->HeroicSta = (int32)((float)m_item->HeroicSta*Mult); + m_scaledItem->HeroicCha = (int32)((float)m_item->HeroicCha*Mult); + m_scaledItem->HeroicMR = (int32)((float)m_item->HeroicMR*Mult); + m_scaledItem->HeroicFR = (int32)((float)m_item->HeroicFR*Mult); + m_scaledItem->HeroicCR = (int32)((float)m_item->HeroicCR*Mult); + m_scaledItem->HeroicDR = (int32)((float)m_item->HeroicDR*Mult); + m_scaledItem->HeroicPR = (int32)((float)m_item->HeroicPR*Mult); + m_scaledItem->HeroicSVCorrup = (int32)((float)m_item->HeroicSVCorrup*Mult); + m_scaledItem->HealAmt = (int32)((float)m_item->HealAmt*Mult); + m_scaledItem->SpellDmg = (int32)((float)m_item->SpellDmg*Mult); + m_scaledItem->Clairvoyance = (uint32)((float)m_item->Clairvoyance*Mult); + + m_scaledItem->CharmFileID = 0; // this stops the client from trying to scale the item itself. +} + +bool ItemInst::EvolveOnAllKills() const { + return (m_evolveInfo && m_evolveInfo->AllKills); +} + +int8 ItemInst::GetMaxEvolveLvl() const { + if(m_evolveInfo) + return m_evolveInfo->MaxLvl; + else + return 0; +} + +uint32 ItemInst::GetKillsNeeded(uint8 currentlevel) { + uint32 kills = -1; // default to -1 (max uint32 value) because this value is usually divided by, so we don't want to ever return zero. + if (m_evolveInfo) + if (currentlevel != m_evolveInfo->MaxLvl) + kills = m_evolveInfo->LvlKills[currentlevel-1]; + + if (kills == 0) + kills = -1; + + return kills; +} + // Retrieve item at specified position within bag ItemInst* Inventory::GetItem(int16 slot_id, uint8 bagidx) const { @@ -1119,14 +1280,10 @@ int Inventory::GetSlotByItemInst(ItemInst *inst) { return i; } - auto iter = m_cursor.begin(); - while(iter != m_cursor.end()) { - if((*iter) == inst) { - return SLOT_CURSOR; - } - ++iter; + if(m_cursor.peek_front() == inst) { + return SLOT_CURSOR; } - + return -1; } @@ -1714,225 +1871,6 @@ bool Inventory::CanItemFitInContainer(const Item_Struct *ItemToTry, const Item_S return true; } -// Methods for EvoItemInst, the extended ItemInst for evolving/scaling items -// Copy constructors -EvoItemInst::EvoItemInst(const EvoItemInst ©) { - m_use_type=copy.m_use_type; - m_item=copy.m_item; - m_charges=copy.m_charges; - m_price=copy.m_price; - m_color=copy.m_color; - m_merchantslot=copy.m_merchantslot; - m_currentslot=copy.m_currentslot; - m_instnodrop=copy.m_instnodrop; - m_merchantcount=copy.m_merchantcount; - // Copy container contents - iter_contents it; - for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) { - ItemInst* inst_old = it->second; - ItemInst* inst_new = nullptr; - - if (inst_old) { - inst_new = inst_old->Clone(); - } - - if (inst_new != nullptr) { - m_contents[it->first] = inst_new; - } - } - std::map::const_iterator iter; - for (iter = copy.m_custom_data.begin(); iter != copy.m_custom_data.end(); iter++) { - m_custom_data[iter->first] = iter->second; - } - m_SerialNumber = copy.m_SerialNumber; - m_exp = copy.m_exp; - m_evolveLvl = copy.m_evolveLvl; - m_activated = copy.m_activated; - m_evolveInfo = nullptr; - if (copy.m_scaledItem) - m_scaledItem = new Item_Struct(*copy.m_scaledItem); - else - m_scaledItem = nullptr; - - m_timers = copy.m_timers; -} - -EvoItemInst::EvoItemInst(const ItemInst &basecopy) { - EvoItemInst* copy = (EvoItemInst*)&basecopy; - - m_use_type=copy->m_use_type; - m_item=copy->m_item; - m_charges=copy->m_charges; - m_price=copy->m_price; - m_color=copy->m_color; - m_merchantslot=copy->m_merchantslot; - m_currentslot=copy->m_currentslot; - m_instnodrop=copy->m_instnodrop; - m_merchantcount=copy->m_merchantcount; - // Copy container contents - iter_contents it; - for (it=copy->m_contents.begin(); it!=copy->m_contents.end(); it++) { - ItemInst* inst_old = it->second; - ItemInst* inst_new = nullptr; - - if (inst_old) { - inst_new = inst_old->Clone(); - } - - if (inst_new != nullptr) { - m_contents[it->first] = inst_new; - } - } - - std::map::const_iterator iter; - for (iter = copy->m_custom_data.begin(); iter != copy->m_custom_data.end(); iter++) { - m_custom_data[iter->first] = iter->second; - } - m_SerialNumber = copy->m_SerialNumber; - m_exp = 0; - m_evolveLvl = 0; - m_activated = false; - m_evolveInfo = nullptr; - m_scaledItem = nullptr; - m_timers = copy->m_timers; -} - -EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) { - m_use_type = ItemUseNormal; - m_item = item; - m_charges = charges; - m_price = 0; - m_instnodrop = false; - m_merchantslot = 0; - if(m_item &&m_item->ItemClass == ItemClassCommon) - m_color = m_item->Color; - else - m_color = 0; - m_merchantcount = 1; - m_SerialNumber = GetNextItemInstSerialNumber(); - m_exp = 0; - m_evolveLvl = 0; - m_activated = false; - m_evolveInfo = nullptr; - m_scaledItem = nullptr; -} - -EvoItemInst::~EvoItemInst() { - safe_delete(m_scaledItem); -} - -EvoItemInst* EvoItemInst::Clone() const { - return new EvoItemInst(*this); -} - -const Item_Struct* EvoItemInst::GetItem() const { - if(!m_scaledItem) - return m_item; - else - return m_scaledItem; -} - -const Item_Struct* EvoItemInst::GetUnscaledItem() const { - return m_item; -} - -void EvoItemInst::Initialize(SharedDatabase *db) { - // if there's no actual item, don't do anything - if(!m_item) return; - - // initialize scaling items - if (m_item->CharmFileID != 0) { - m_evolveLvl = -1; - this->ScaleItem(); - } - - // initialize evolving items - else if ((db) && m_item->LoreGroup >= 1000 && m_item->LoreGroup != -1) { - // not complete yet - } -} - -void EvoItemInst::ScaleItem() { - // free memory from any previously scaled item data - safe_delete(m_scaledItem); - - m_scaledItem = new Item_Struct(*m_item); - float Mult = (float)(GetExp())/10000; // scaling is determined by exp, with 10,000 being full stats - - m_scaledItem->AStr = (int8)((float)m_item->AStr*Mult); - m_scaledItem->ASta = (int8)((float)m_item->ASta*Mult); - m_scaledItem->AAgi = (int8)((float)m_item->AAgi*Mult); - m_scaledItem->ADex = (int8)((float)m_item->ADex*Mult); - m_scaledItem->AInt = (int8)((float)m_item->AInt*Mult); - m_scaledItem->AWis = (int8)((float)m_item->AWis*Mult); - m_scaledItem->ACha = (int8)((float)m_item->ACha*Mult); - - m_scaledItem->MR = (int8)((float)m_item->MR*Mult); - m_scaledItem->PR = (int8)((float)m_item->PR*Mult); - m_scaledItem->DR = (int8)((float)m_item->DR*Mult); - m_scaledItem->CR = (int8)((float)m_item->CR*Mult); - m_scaledItem->FR = (int8)((float)m_item->FR*Mult); - - m_scaledItem->HP = (int32)((float)m_item->HP*Mult); - m_scaledItem->Mana = (int32)((float)m_item->Mana*Mult); - m_scaledItem->AC = (int32)((float)m_item->AC*Mult); - - m_scaledItem->SkillModValue = (int32)((float)m_item->SkillModValue*Mult); - m_scaledItem->BaneDmgAmt = (int8)((float)m_item->BaneDmgAmt*Mult); - m_scaledItem->BardValue = (int32)((float)m_item->BardValue*Mult); - m_scaledItem->ElemDmgAmt = (uint8)((float)m_item->ElemDmgAmt*Mult); - m_scaledItem->Damage = (uint32)((float)m_item->Damage*Mult); - - m_scaledItem->CombatEffects = (int8)((float)m_item->CombatEffects*Mult); - m_scaledItem->Shielding = (int8)((float)m_item->Shielding*Mult); - m_scaledItem->StunResist = (int8)((float)m_item->StunResist*Mult); - m_scaledItem->StrikeThrough = (int8)((float)m_item->StrikeThrough*Mult); - m_scaledItem->ExtraDmgAmt = (uint32)((float)m_item->ExtraDmgAmt*Mult); - m_scaledItem->SpellShield = (int8)((float)m_item->SpellShield*Mult); - m_scaledItem->Avoidance = (int8)((float)m_item->Avoidance*Mult); - m_scaledItem->Accuracy = (int8)((float)m_item->Accuracy*Mult); - - m_scaledItem->FactionAmt1 = (int32)((float)m_item->FactionAmt1*Mult); - m_scaledItem->FactionAmt2 = (int32)((float)m_item->FactionAmt2*Mult); - m_scaledItem->FactionAmt3 = (int32)((float)m_item->FactionAmt3*Mult); - m_scaledItem->FactionAmt4 = (int32)((float)m_item->FactionAmt4*Mult); - - m_scaledItem->Endur = (uint32)((float)m_item->Endur*Mult); - m_scaledItem->DotShielding = (uint32)((float)m_item->DotShielding*Mult); - m_scaledItem->Attack = (uint32)((float)m_item->Attack*Mult); - m_scaledItem->Regen = (uint32)((float)m_item->Regen*Mult); - m_scaledItem->ManaRegen = (uint32)((float)m_item->ManaRegen*Mult); - m_scaledItem->EnduranceRegen = (uint32)((float)m_item->EnduranceRegen*Mult); - m_scaledItem->Haste = (uint32)((float)m_item->Haste*Mult); - m_scaledItem->DamageShield = (uint32)((float)m_item->DamageShield*Mult); - - - m_scaledItem->CharmFileID = 0; // this stops the client from trying to scale the item itself. -} - -bool EvoItemInst::EvolveOnAllKills() const { - return (m_evolveInfo && m_evolveInfo->AllKills); -} - -int8 EvoItemInst::GetMaxEvolveLvl() const { - if(m_evolveInfo) - return m_evolveInfo->MaxLvl; - else - return 0; -} - -uint32 EvoItemInst::GetKillsNeeded(uint8 currentlevel) { - uint32 kills = -1; // default to -1 (max uint32 value) because this value is usually divided by, so we don't want to ever return zero. - if (m_evolveInfo) - if (currentlevel != m_evolveInfo->MaxLvl) - kills = m_evolveInfo->LvlKills[currentlevel-1]; - - if (kills == 0) - kills = -1; - - return kills; -} - EvolveInfo::EvolveInfo() { // nothing here yet } @@ -1952,6 +1890,9 @@ EvolveInfo::EvolveInfo(uint32 first, uint8 max, bool allkills, uint32 L2, uint32 LvlKills[8] = L10; } +EvolveInfo::~EvolveInfo() { +} + bool Item_Struct::IsEquipable(uint16 Race, uint16 Class_) const { bool IsRace = false; diff --git a/common/Item.h b/common/Item.h index 20627593e..08a0aaa3f 100644 --- a/common/Item.h +++ b/common/Item.h @@ -27,7 +27,6 @@ class ItemInst; // Item belonging to a client (contains info on item, dye, au class ItemInstQueue; // Queue of ItemInst objects (i.e., cursor) class Inventory; // Character inventory class ItemParse; // Parses item packets -class EvoItemInst; // Extended item inst, for use with scaling/evolving items class EvolveInfo; // Stores information about an evolving item family #include @@ -135,7 +134,7 @@ public: // Public Methods /////////////////////////////// - virtual ~Inventory(); + ~Inventory(); // Retrieve a writeable item at specified slot ItemInst* GetItem(int16 slot_id) const; @@ -269,21 +268,28 @@ public: m_instnodrop = false; m_merchantslot = 0; m_color = 0; + + m_exp = 0; + m_evolveLvl = 0; + m_activated = false; + m_scaledItem = nullptr; + m_evolveInfo = nullptr; + m_scaling = false; } ItemInst(const ItemInst& copy); - virtual ~ItemInst(); + ~ItemInst(); // Query item type - virtual bool IsType(ItemClass item_class) const; + bool IsType(ItemClass item_class) const; // Can item be stacked? - virtual bool IsStackable() const; + bool IsStackable() const; // Can item be equipped by/at? - virtual bool IsEquipable(uint16 race, uint16 class_) const; - virtual bool IsEquipable(int16 slot_id) const; + bool IsEquipable(uint16 race, uint16 class_) const; + bool IsEquipable(int16 slot_id) const; // // Augements @@ -299,7 +305,7 @@ public: // Contents // ItemInst* GetItem(uint8 slot) const; - virtual uint32 GetItemID(uint8 slot) const; + uint32 GetItemID(uint8 slot) const; inline const ItemInst* operator[](uint8 slot) const { return GetItem(slot); } void PutItem(uint8 slot, const ItemInst& inst); void PutItem(SharedDatabase *db, uint8 slot, uint32 item_id); @@ -316,7 +322,7 @@ public: // Augments // ItemInst* GetAugment(uint8 slot) const; - virtual uint32 GetAugmentItemID(uint8 slot) const; + uint32 GetAugmentItemID(uint8 slot) const; void PutAugment(uint8 slot, const ItemInst& inst); void PutAugment(SharedDatabase *db, uint8 slot, uint32 item_id); void DeleteAugment(uint8 slot); @@ -324,14 +330,14 @@ public: bool IsAugmented(); // Has attack/delay? - virtual bool IsWeapon() const; - virtual bool IsAmmo() const; + bool IsWeapon() const; + bool IsAmmo() const; // Accessors const uint32 GetID() const { return m_item->ID; } const uint32 GetItemScriptID() const { return m_item->ScriptFileID; } - virtual const Item_Struct* GetItem() const { return m_item; } - void SetItem(const Item_Struct* item) { m_item = item; } + const Item_Struct* GetItem() const; + const Item_Struct* GetUnscaledItem() const; int16 GetCharges() const { return m_charges; } void SetCharges(int16 charges) { m_charges = charges; } @@ -371,12 +377,25 @@ public: bool operator!=(const ItemInst& right) const { return (this->m_item != right.m_item); } // Clone current item - virtual ItemInst* Clone() const; + ItemInst* Clone() const; bool IsSlotAllowed(int16 slot_id) const; - virtual bool IsScaling() const { return false; } - virtual bool IsEvolving() const { return false; } + bool IsScaling() const { return m_scaling; } + bool IsEvolving() const { return (m_evolveLvl >= 1); } + uint32 GetExp() const { return m_exp; } + void SetExp(uint32 exp) { m_exp = exp; } + void AddExp(uint32 exp) { m_exp += exp; } + bool IsActivated() { return m_activated; } + void SetActivated(bool activated) { m_activated = activated; } + int8 GetEvolveLvl() const { return m_evolveLvl; } + void SetScaling(bool v) { m_scaling = v; } + + void Initialize(SharedDatabase *db = nullptr); + void ScaleItem(); + bool EvolveOnAllKills() const; + int8 GetMaxEvolveLvl() const; + uint32 GetKillsNeeded(uint8 currentlevel); std::string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id=slot_id; s.inst=(const void *)this; std::string ser; ser.assign((char *)&s,sizeof(InternalSerializedItem_Struct)); return ser; } inline int32 GetSerialNumber() const { return m_SerialNumber; } @@ -409,6 +428,13 @@ protected: bool m_instnodrop; int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar. + uint32 m_exp; + int8 m_evolveLvl; + bool m_activated; + Item_Struct* m_scaledItem; + EvolveInfo* m_evolveInfo; + bool m_scaling; + // // Items inside of this item (augs or contents); std::map m_contents; // Zero-based index: min=0, max=9 @@ -416,45 +442,9 @@ protected: std::map m_timers; }; -class EvoItemInst: public ItemInst { -public: - // constructor and destructor - EvoItemInst(const EvoItemInst& copy); - EvoItemInst(const ItemInst& copy); - EvoItemInst(const Item_Struct* item = nullptr, int16 charges = 0); - ~EvoItemInst(); - - // accessors... a lot of these are for evolving items (not complete yet) - bool IsScaling() const { return (m_evolveLvl == -1); } - bool IsEvolving() const { return (m_evolveLvl >= 1); } - uint32 GetExp() const { return m_exp; } - void SetExp(uint32 exp) { m_exp = exp; } - void AddExp(uint32 exp) { m_exp += exp; } - bool IsActivated() { return m_activated; } - void SetActivated(bool activated) { m_activated = activated; } - int8 GetEvolveLvl() const { return m_evolveLvl; } - - EvoItemInst* Clone() const; - const Item_Struct* GetItem() const; - const Item_Struct* GetUnscaledItem() const; - void Initialize(SharedDatabase *db = nullptr); - void ScaleItem(); - bool EvolveOnAllKills() const; - int8 GetMaxEvolveLvl() const; - uint32 GetKillsNeeded(uint8 currentlevel); - - -private: - uint32 m_exp; - int8 m_evolveLvl; - bool m_activated; - Item_Struct* m_scaledItem; - const EvolveInfo* m_evolveInfo; -}; - class EvolveInfo { public: - friend class EvoItemInst; + friend class ItemInst; //temporary uint16 LvlKills[9]; uint32 FirstItem; diff --git a/common/features.h b/common/features.h index aa3f120d5..ca233248c 100644 --- a/common/features.h +++ b/common/features.h @@ -117,18 +117,11 @@ Zone extensions and features //New aggro system to reduce overhead. #define REVERSE_AGGRO -//Enable spacial queue to manage NPC update packets -//#define PACKET_UPDATE_MANAGER -//#define MANAGE_HP_UPDATES - //The highest you can #setskill / #setallskill #define HIGHEST_CAN_SET_SKILL 400 #define SKILL_MAX_LEVEL 75 -//#define MIN_RANGED_ATK_RANGE 25 -//replaced the above define with RuleI(Combat, MinRangedAttackDist) - /* Zone Numerical configuration @@ -169,7 +162,7 @@ enum { //timer settings, all in milliseconds AItarget_check_duration = 500, AIClientScanarea_delay = 750, //used in REVERSE_AGGRO AIassistcheck_delay = 3000, //now often a fighting NPC will yell for help - ClientProximity_interval = 1000, + ClientProximity_interval = 150, CombatEventTimer_expire = 12000, Tribute_duration = 600000, ZoneTimerResolution = 3, //sleep time between zone main loop runs (milliseconds) diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 2531d76fe..7f0058af4 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -1343,12 +1343,11 @@ ItemInst* SharedDatabase::CreateBaseItem(const Item_Struct* item, int16 charges) if (charges == 0 && item->MaxCharges == -1) charges = 1; + inst = new ItemInst(item, charges); + if(item->CharmFileID != 0 || (item->LoreGroup >= 1000 && item->LoreGroup != -1)) { - inst = new EvoItemInst(item, charges); - ((EvoItemInst*)inst)->Initialize(this); + inst->Initialize(this); } - else - inst = new ItemInst(item, charges); } return inst; } diff --git a/luabind/luabind/detail/call_function.hpp b/luabind/luabind/detail/call_function.hpp index 1b45ec157..e053c02df 100644 --- a/luabind/luabind/detail/call_function.hpp +++ b/luabind/luabind/detail/call_function.hpp @@ -323,7 +323,8 @@ namespace luabind #endif // LUABIND_CALL_FUNCTION_HPP_INCLUDED -#elif BOOST_PP_ITERATION_FLAGS() == 1 +#else +#if BOOST_PP_ITERATION_FLAGS() == 1 #define LUABIND_TUPLE_PARAMS(z, n, data) const A##n * #define LUABIND_OPERATOR_PARAMS(z, n, data) const A##n & a##n @@ -438,6 +439,6 @@ namespace luabind #undef LUABIND_OPERATOR_PARAMS #undef LUABIND_TUPLE_PARAMS - +#endif #endif diff --git a/luabind/luabind/detail/call_member.hpp b/luabind/luabind/detail/call_member.hpp index de8d56372..e63555bc6 100644 --- a/luabind/luabind/detail/call_member.hpp +++ b/luabind/luabind/detail/call_member.hpp @@ -316,7 +316,8 @@ namespace luabind #endif // LUABIND_CALL_MEMBER_HPP_INCLUDED -#elif BOOST_PP_ITERATION_FLAGS() == 1 +#else +#if BOOST_PP_ITERATION_FLAGS() == 1 #define LUABIND_TUPLE_PARAMS(z, n, data) const A##n * #define LUABIND_OPERATOR_PARAMS(z, n, data) const A##n & a##n @@ -360,4 +361,5 @@ namespace luabind #undef LUABIND_TUPLE_PARAMS #endif +#endif diff --git a/luabind/luabind/wrapper_base.hpp b/luabind/luabind/wrapper_base.hpp index d54c668f3..9adc05a35 100644 --- a/luabind/luabind/wrapper_base.hpp +++ b/luabind/luabind/wrapper_base.hpp @@ -89,7 +89,8 @@ namespace luabind #endif // LUABIND_WRAPPER_BASE_HPP_INCLUDED -#elif BOOST_PP_ITERATION_FLAGS() == 1 +#else +#if BOOST_PP_ITERATION_FLAGS() == 1 #define LUABIND_TUPLE_PARAMS(z, n, data) const A##n * #define LUABIND_OPERATOR_PARAMS(z, n, data) const A##n & a##n @@ -188,3 +189,4 @@ namespace luabind #undef N #endif +#endif \ No newline at end of file diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index f9e2e1c08..f44f2b9be 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -104,7 +104,6 @@ SET(zone_sources trading.cpp trap.cpp tribute.cpp - updatemgr.cpp watermap.cpp waypoints.cpp worldserver.cpp @@ -187,7 +186,6 @@ SET(zone_headers tasks.h titles.h trap.h - updatemgr.h watermap.h worldserver.h zone.h diff --git a/zone/QuestParserCollection.cpp b/zone/QuestParserCollection.cpp index fda25000a..4421f3525 100644 --- a/zone/QuestParserCollection.cpp +++ b/zone/QuestParserCollection.cpp @@ -732,8 +732,10 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s iter++; } - //second look for /quests/spells/spell_id.ext (precedence) - filename = "quests/spells/"; + //second look for /quests/global/spells/spell_id.ext (precedence) + filename = "quests/"; + filename += QUEST_GLOBAL_DIRECTORY; + filename += "/spells/"; filename += itoa(spell_id); iter = _load_precedence.begin(); @@ -750,7 +752,49 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s } iter++; - } + } + + //third look for /quests/zone/spells/default.ext (precedence) + filename = "quests/"; + filename += zone->GetShortName(); + filename += "/spells/default"; + + iter = _load_precedence.begin(); + while(iter != _load_precedence.end()) { + tmp = filename; + std::map::iterator ext = _extensions.find((*iter)->GetIdentifier()); + tmp += "."; + tmp += ext->second; + f = fopen(tmp.c_str(), "r"); + if(f) { + fclose(f); + filename = tmp; + return (*iter); + } + + iter++; + } + + //last look for /quests/global/spells/default.ext (precedence) + filename = "quests/"; + filename += QUEST_GLOBAL_DIRECTORY; + filename += "/spells/default"; + + iter = _load_precedence.begin(); + while(iter != _load_precedence.end()) { + tmp = filename; + std::map::iterator ext = _extensions.find((*iter)->GetIdentifier()); + tmp += "."; + tmp += ext->second; + f = fopen(tmp.c_str(), "r"); + if(f) { + fclose(f); + filename = tmp; + return (*iter); + } + + iter++; + } return nullptr; } @@ -780,8 +824,10 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script, iter++; } - //second look for /quests/items/item_script.ext (precedence) - filename = "quests/items/"; + //second look for /quests/global/items/item_script.ext (precedence) + filename = "quests/"; + filename += QUEST_GLOBAL_DIRECTORY; + filename += "/items/"; filename += item_script; iter = _load_precedence.begin(); @@ -800,6 +846,48 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script, iter++; } + //third look for /quests/zone/items/default.ext (precedence) + filename = "quests/"; + filename += zone->GetShortName(); + filename += "/items/default"; + + iter = _load_precedence.begin(); + while(iter != _load_precedence.end()) { + tmp = filename; + std::map::iterator ext = _extensions.find((*iter)->GetIdentifier()); + tmp += "."; + tmp += ext->second; + f = fopen(tmp.c_str(), "r"); + if(f) { + fclose(f); + filename = tmp; + return (*iter); + } + + iter++; + } + + //last look for /quests/global/items/default.ext (precedence) + filename = "quests/"; + filename += QUEST_GLOBAL_DIRECTORY; + filename += "/items/default"; + + iter = _load_precedence.begin(); + while(iter != _load_precedence.end()) { + tmp = filename; + std::map::iterator ext = _extensions.find((*iter)->GetIdentifier()); + tmp += "."; + tmp += ext->second; + f = fopen(tmp.c_str(), "r"); + if(f) { + fclose(f); + filename = tmp; + return (*iter); + } + + iter++; + } + return nullptr; } @@ -828,8 +916,10 @@ QuestInterface *QuestParserCollection::GetQIByEncounterQuest(std::string encount ++iter; } - //second look for /quests/encounters/encounter_name.ext (precedence) - filename = "quests/encounters/"; + //second look for /quests/global/encounters/encounter_name.ext (precedence) + filename = "quests/"; + filename += QUEST_GLOBAL_DIRECTORY; + filename += "/encounters/"; filename += encounter_name; iter = _load_precedence.begin(); diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 556465862..5bac6e143 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -2432,19 +2432,18 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y) bool changed = false; int i; for (i = slot_x; i < slot_y; i++) { - const ItemInst* inst = m_inv[i]; + ItemInst* inst = m_inv.GetItem(i); if(inst == 0) continue; bool update_slot = false; if(inst->IsScaling()) { - EvoItemInst* e_inst = (EvoItemInst*)inst; - uint16 oldexp = e_inst->GetExp(); - parse->EventItem(EVENT_SCALE_CALC, this, e_inst, nullptr, "", 0); + uint16 oldexp = inst->GetExp(); + parse->EventItem(EVENT_SCALE_CALC, this, inst, nullptr, "", 0); - if (e_inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client - e_inst->ScaleItem(); + if (inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client + inst->ScaleItem(); changed = true; update_slot = true; } @@ -2459,13 +2458,12 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y) if(a_inst->IsScaling()) { - EvoItemInst* e_inst = (EvoItemInst*)a_inst; - uint16 oldexp = e_inst->GetExp(); - parse->EventItem(EVENT_SCALE_CALC, this, e_inst, nullptr, "", 0); + uint16 oldexp = a_inst->GetExp(); + parse->EventItem(EVENT_SCALE_CALC, this, a_inst, nullptr, "", 0); - if (e_inst->GetExp() != oldexp) + if (a_inst->GetExp() != oldexp) { - e_inst->ScaleItem(); + a_inst->ScaleItem(); changed = true; update_slot = true; } @@ -2518,16 +2516,15 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) { bool update_slot = false; if(inst->IsScaling()) { - EvoItemInst* e_inst = (EvoItemInst*)inst; - uint16 oldexp = e_inst->GetExp(); + uint16 oldexp = inst->GetExp(); - parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0); + parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, inst, nullptr, "", 0); if(i < 22 || i == 9999) { - parse->EventItem(EVENT_EQUIP_ITEM, this, e_inst, nullptr, "", i); + parse->EventItem(EVENT_EQUIP_ITEM, this, inst, nullptr, "", i); } - if (e_inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client - e_inst->ScaleItem(); + if (inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client + inst->ScaleItem(); changed = true; update_slot = true; } @@ -2548,14 +2545,13 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) { if(a_inst->IsScaling()) { - EvoItemInst* e_inst = (EvoItemInst*)a_inst; - uint16 oldexp = e_inst->GetExp(); + uint16 oldexp = a_inst->GetExp(); - parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0); + parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, a_inst, nullptr, "", 0); - if (e_inst->GetExp() != oldexp) + if (a_inst->GetExp() != oldexp) { - e_inst->ScaleItem(); + a_inst->ScaleItem(); changed = true; update_slot = true; } diff --git a/zone/client.cpp b/zone/client.cpp index eb0ca2ee7..2fa49b6af 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -146,9 +146,6 @@ Client::Client(EQStreamInterface* ieqs) scanarea_timer(AIClientScanarea_delay), #endif tribute_timer(Tribute_duration), -#ifdef PACKET_UPDATE_MANAGER - update_manager(ieqs), -#endif proximity_timer(ClientProximity_interval), TaskPeriodic_Timer(RuleI(TaskSystem, PeriodicCheckTimer) * 1000), charm_update_timer(6000), @@ -7828,3 +7825,12 @@ void Client::IncrementAA(int aa_id) { SendAAStats(); CalcBonuses(); } + +void Client::SendItemScale(ItemInst *inst) { + int slot = m_inv.GetSlotByItemInst(inst); + if(slot != -1) { + inst->ScaleItem(); + SendItemPacket(slot, inst, ItemPacketCharmUpdate); + CalcBonuses(); + } +} diff --git a/zone/client.h b/zone/client.h index b22cac17e..f0993c12c 100644 --- a/zone/client.h +++ b/zone/client.h @@ -44,7 +44,6 @@ class Client; #include "merc.h" #include "zone.h" #include "AA.h" -#include "updatemgr.h" #include "questmgr.h" #include "QGlobals.h" @@ -838,9 +837,6 @@ public: void EnableTitle(int titleset); void RemoveTitle(int titleset); -#ifdef PACKET_UPDATE_MANAGER - inline UpdateManager *GetUpdateManager() { return(&update_manager); } -#endif void EnteringMessages(Client* client); void SendRules(Client* client); std::list consent_list; @@ -1124,6 +1120,7 @@ public: void TryItemTick(int slot); void ItemTimerCheck(); void TryItemTimer(int slot); + void SendItemScale(ItemInst *inst); int16 GetActSTR() { return( std::min(GetMaxSTR(), GetSTR()) ); } int16 GetActSTA() { return( std::min(GetMaxSTA(), GetSTA()) ); } @@ -1356,10 +1353,6 @@ private: #endif Timer tribute_timer; -#ifdef PACKET_UPDATE_MANAGER - UpdateManager update_manager; -#endif - Timer proximity_timer; Timer TaskPeriodic_Timer; Timer charm_update_timer; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 93084fa76..bfb2e369e 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1269,11 +1269,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) if (gmhideme) entity_list.QueueClientsStatus(this,outapp,true,Admin(),250); else -#ifdef PACKET_UPDATE_MANAGER - entity_list.QueueManaged(this,outapp,true,false); -#else entity_list.QueueCloseClients(this,outapp,true,300,nullptr,false); -#endif safe_delete(outapp); } diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 20b6cb63d..acc8baf88 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -82,10 +82,6 @@ bool Client::Process() { SendAllPackets(); } -#ifdef PACKET_UPDATE_MANAGER - update_manager.Process(); -#endif - if(adventure_request_timer) { if(adventure_request_timer->Check()) diff --git a/zone/entity.cpp b/zone/entity.cpp index fe9276128..8deeba20d 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1681,124 +1681,6 @@ void EntityList::QueueClients(Mob* sender, const EQApplicationPacket* app, bool } } -/* -rewrite of all the queue close methods to use the update manager -void EntityList::FilterQueueCloseClients(uint8 filter, uint8 required, Mob* sender, const EQApplicationPacket* app, bool ignore_sender, float dist, Mob* SkipThisMob, bool ackreq){ - if(dist <= 0) { - dist = 600; - } - -#ifdef PACKET_UPDATE_MANAGER - EQApplicationPacket* tmp_app = app->Copy(); -#else - float dist2 = dist * dist; //pow(dist, 2); -#endif - - LinkedListIterator iterator(client_list); - - iterator.Reset(); - while(iterator.MoreElements()) { - - Client* ent = iterator.GetData(); - uint8 filterval=ent->GetFilter(filter); - if(required==0) - required=1; - if(filterval==required){ - if ((!ignore_sender || ent != sender) && (ent != SkipThisMob) - ) { -#ifdef PACKET_UPDATE_MANAGER - if(ent->Connected()) { - ent->GetUpdateManager()->QueuePacket(tmp_app, ackreq, sender, ent->DistNoRoot(*sender)); - } -#else - if(ent->Connected() && (ent->DistNoRoot(*sender) <= dist2 || dist == 0)) { - ent->QueuePacket(app, ackreq); - } -#endif - } - } - iterator.Advance(); - } -#ifdef PACKET_UPDATE_MANAGER - EQApplicationPacket::PacketUsed(&tmp_app); -#endif -} - -void EntityList::QueueCloseClients(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, float dist, Mob* SkipThisMob, bool ackreq,uint8 filter) { - if (sender == 0) { - QueueClients(sender, app, ignore_sender); - return; - } - if(dist <= 0) { - dist = 600; - } -#ifdef PACKET_UPDATE_MANAGER - EQApplicationPacket* tmp_app = app->Copy(); -#else - float dist2 = dist * dist; //pow(dist, 2); -#endif - - - LinkedListIterator iterator(client_list); - - iterator.Reset(); - while(iterator.MoreElements()) { - - Client* ent = iterator.GetData(); - - if ((!ignore_sender || ent != sender) && (ent != SkipThisMob)) { - uint8 filter2=ent->GetFilter(filter); - if(ent->Connected() && - (filter==0 || (filter2==1 || - (filter2==99 && entity_list.GetGroupByClient(ent)!=0 && - entity_list.GetGroupByClient(ent)->IsGroupMember(sender)) - || (filter2==98 && ent==sender))) -#ifdef PACKET_UPDATE_MANAGER - ) { - ent->GetUpdateManager()->QueuePacket(tmp_app, ackreq, sender, ent->DistNoRoot(*sender)); - } -#else - && (ent->DistNoRoot(*sender) <= dist2 || dist == 0)) { - ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED); - } -#endif - } - iterator.Advance(); - } -#ifdef PACKET_UPDATE_MANAGER - EQApplicationPacket::PacketUsed(&tmp_app); -#endif -} - -void EntityList::QueueClients(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, bool ackreq) { - LinkedListIterator iterator(client_list); - -#ifdef PACKET_UPDATE_MANAGER - EQApplicationPacket* tmp_app = app->Copy(); -#endif - - iterator.Reset(); - while(iterator.MoreElements()) - { - Client* ent = iterator.GetData(); - - if ((!ignore_sender || ent != sender)) - { -#ifdef PACKET_UPDATE_MANAGER - ent->GetUpdateManager()->QueuePacket(tmp_app, ackreq, sender, ent->DistNoRoot(*sender)); -#else - ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED); -#endif - } - iterator.Advance(); - } -#ifdef PACKET_UPDATE_MANAGER - EQApplicationPacket::PacketUsed(&tmp_app); -#endif -} -*/ - -/* void EntityList::QueueManaged(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, bool ackreq) { LinkedListIterator iterator(client_list); @@ -1813,33 +1695,6 @@ void EntityList::QueueManaged(Mob* sender, const EQApplicationPacket* app, bool } iterator.Advance(); } -}*/ - -void EntityList::QueueManaged(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, bool ackreq) { - LinkedListIterator iterator(client_list); - -#ifdef PACKET_UPDATE_MANAGER - EQApplicationPacket* tmp_app = app->Copy(); -#endif - - iterator.Reset(); - while(iterator.MoreElements()) - { - Client* ent = iterator.GetData(); - - if ((!ignore_sender || ent != sender)) - { -#ifdef PACKET_UPDATE_MANAGER - ent->GetUpdateManager()->QueuePacket(tmp_app, ackreq, sender, ent->DistNoRoot(*sender)); -#else - ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED); -#endif - } - iterator.Advance(); - } -#ifdef PACKET_UPDATE_MANAGER - EQApplicationPacket::PacketUsed(&tmp_app); -#endif } diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index b8be88c64..fae5c3045 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -1173,6 +1173,11 @@ Lua_Inventory Lua_Client::GetInventory() { return &self->GetInv(); } +void Lua_Client::SendItemScale(Lua_ItemInst inst) { + Lua_Safe_Call_Void(); + self->SendItemScale(inst); +} + luabind::scope lua_register_client() { return luabind::class_("Client") .def(luabind::constructor<>()) @@ -1406,7 +1411,8 @@ luabind::scope lua_register_client() { .def("GetRaid", (Lua_Raid(Lua_Client::*)(void))&Lua_Client::GetRaid) .def("PutItemInInventory", (bool(Lua_Client::*)(int,Lua_ItemInst))&Lua_Client::PutItemInInventory) .def("PushItemOnCursor", (bool(Lua_Client::*)(Lua_ItemInst))&Lua_Client::PushItemOnCursor) - .def("GetInventory", (Lua_Inventory(Lua_Client::*)(void))&Lua_Client::GetInventory); + .def("GetInventory", (Lua_Inventory(Lua_Client::*)(void))&Lua_Client::GetInventory) + .def("SendItemScale", (void(Lua_Client::*)(Lua_ItemInst))&Lua_Client::SendItemScale); } luabind::scope lua_register_inventory_where() { diff --git a/zone/lua_client.h b/zone/lua_client.h index 068c38c19..54b4009b4 100644 --- a/zone/lua_client.h +++ b/zone/lua_client.h @@ -21,7 +21,7 @@ class Lua_Client : public Lua_Mob typedef Client NativeType; public: Lua_Client() { SetLuaPtrData(nullptr); } - Lua_Client(Client *d) { SetLuaPtrData(d); } + Lua_Client(Client *d) { SetLuaPtrData(reinterpret_cast(d)); } virtual ~Lua_Client() { } operator Client*() { @@ -261,6 +261,7 @@ public: bool PutItemInInventory(int slot_id, Lua_ItemInst inst); bool PushItemOnCursor(Lua_ItemInst inst); Lua_Inventory GetInventory(); + void SendItemScale(Lua_ItemInst inst); }; #endif diff --git a/zone/lua_corpse.h b/zone/lua_corpse.h index 3ae7a0960..dfb3b4b6d 100644 --- a/zone/lua_corpse.h +++ b/zone/lua_corpse.h @@ -18,7 +18,7 @@ class Lua_Corpse : public Lua_Mob typedef Corpse NativeType; public: Lua_Corpse() { SetLuaPtrData(nullptr); } - Lua_Corpse(Corpse *d) { SetLuaPtrData(d); } + Lua_Corpse(Corpse *d) { SetLuaPtrData(reinterpret_cast(d)); } virtual ~Lua_Corpse() { } operator Corpse*() { diff --git a/zone/lua_door.h b/zone/lua_door.h index 1a58a172a..c7baad8cc 100644 --- a/zone/lua_door.h +++ b/zone/lua_door.h @@ -17,7 +17,7 @@ class Lua_Door : public Lua_Entity typedef Doors NativeType; public: Lua_Door() { } - Lua_Door(Doors *d) { SetLuaPtrData(d); } + Lua_Door(Doors *d) { SetLuaPtrData(reinterpret_cast(d)); } virtual ~Lua_Door() { } operator Doors*() { diff --git a/zone/lua_entity.h b/zone/lua_entity.h index 4270a2cd0..7e3254ff3 100644 --- a/zone/lua_entity.h +++ b/zone/lua_entity.h @@ -21,7 +21,7 @@ namespace luabind { luabind::scope lua_register_entity(); -class Lua_Entity : public Lua_Ptr +class Lua_Entity : public Lua_Ptr { typedef Entity NativeType; public: diff --git a/zone/lua_entity_list.h b/zone/lua_entity_list.h index 4121dbc73..e9b5879f0 100644 --- a/zone/lua_entity_list.h +++ b/zone/lua_entity_list.h @@ -32,7 +32,7 @@ luabind::scope lua_register_corpse_list(); luabind::scope lua_register_object_list(); luabind::scope lua_register_door_list(); -class Lua_EntityList : public Lua_Ptr +class Lua_EntityList : public Lua_Ptr { typedef EntityList NativeType; public: diff --git a/zone/lua_group.h b/zone/lua_group.h index 92069c7a1..399abbe2b 100644 --- a/zone/lua_group.h +++ b/zone/lua_group.h @@ -14,7 +14,7 @@ namespace luabind { luabind::scope lua_register_group(); -class Lua_Group : public Lua_Ptr +class Lua_Group : public Lua_Ptr { typedef Group NativeType; public: diff --git a/zone/lua_hate_list.h b/zone/lua_hate_list.h index da5070bd1..4dc6502f3 100644 --- a/zone/lua_hate_list.h +++ b/zone/lua_hate_list.h @@ -10,7 +10,7 @@ struct tHateEntry; luabind::scope lua_register_hate_entry(); luabind::scope lua_register_hate_list(); -class Lua_HateEntry : public Lua_Ptr +class Lua_HateEntry : public Lua_Ptr { typedef tHateEntry NativeType; public: diff --git a/zone/lua_inventory.h b/zone/lua_inventory.h index 5033d5e67..ca49a55e6 100644 --- a/zone/lua_inventory.h +++ b/zone/lua_inventory.h @@ -14,7 +14,7 @@ namespace luabind { luabind::scope lua_register_inventory(); -class Lua_Inventory : public Lua_Ptr +class Lua_Inventory : public Lua_Ptr { typedef Inventory NativeType; public: diff --git a/zone/lua_item.h b/zone/lua_item.h index 335d0bb99..961da1333 100644 --- a/zone/lua_item.h +++ b/zone/lua_item.h @@ -12,7 +12,7 @@ namespace luabind { luabind::scope lua_register_item(); -class Lua_Item : public Lua_Ptr +class Lua_Item : public Lua_Ptr { typedef const Item_Struct NativeType; public: diff --git a/zone/lua_iteminst.cpp b/zone/lua_iteminst.cpp index 4d4d16e0a..32224d6a3 100644 --- a/zone/lua_iteminst.cpp +++ b/zone/lua_iteminst.cpp @@ -63,18 +63,9 @@ Lua_Item Lua_ItemInst::GetItem() { return Lua_Item(self->GetItem()); } -void Lua_ItemInst::SetItem(Lua_Item item) { - Lua_Safe_Call_Void(); - return self->SetItem(item); -} - Lua_Item Lua_ItemInst::GetUnscaledItem(int slot) { Lua_Safe_Call_Class(Lua_Item); - if(self->IsScaling()) { - const EvoItemInst *ev = reinterpret_cast(self); - return Lua_Item(ev->GetUnscaledItem()); - } - return Lua_Item(self->GetItem()); + return self->GetUnscaledItem(); } uint32 Lua_ItemInst::GetItemID(int slot) { @@ -199,53 +190,37 @@ void Lua_ItemInst::DeleteCustomData(std::string identifier) { void Lua_ItemInst::SetScale(double scale_factor) { Lua_Safe_Call_Void(); - if(self->IsScaling()) { - EvoItemInst *ev = reinterpret_cast(self); - ev->SetExp(static_cast(scale_factor * 10000.0 + 0.5)); - } + self->SetExp((int)(scale_factor*10000+.5)); +} + +void Lua_ItemInst::SetScaling(bool v) { + Lua_Safe_Call_Void(); + self->SetScaling(v); } uint32 Lua_ItemInst::GetExp() { Lua_Safe_Call_Int(); - if(self->IsScaling()) { - EvoItemInst *ev = reinterpret_cast(self); - return ev->GetExp(); - } - return 0; + return self->GetExp(); } void Lua_ItemInst::SetExp(uint32 exp) { Lua_Safe_Call_Void(); - if(self->IsScaling()) { - EvoItemInst *ev = reinterpret_cast(self); - ev->SetExp(exp); - } + self->SetExp(exp); } void Lua_ItemInst::AddExp(uint32 exp) { Lua_Safe_Call_Void(); - if(self->IsScaling()) { - EvoItemInst *ev = reinterpret_cast(self); - ev->AddExp(exp); - } + self->AddExp(exp); } int Lua_ItemInst::GetMaxEvolveLvl() { Lua_Safe_Call_Int(); - if(self->IsScaling()) { - EvoItemInst *ev = reinterpret_cast(self); - return ev->GetMaxEvolveLvl(); - } - return 0; + return self->GetMaxEvolveLvl(); } uint32 Lua_ItemInst::GetKillsNeeded(int current_level) { Lua_Safe_Call_Int(); - if(self->IsScaling()) { - EvoItemInst *ev = reinterpret_cast(self); - return ev->GetKillsNeeded(current_level); - } - return 0; + return self->GetKillsNeeded(current_level); } Lua_ItemInst Lua_ItemInst::Clone() { @@ -294,7 +269,6 @@ luabind::scope lua_register_iteminst() { .def("GetID", (uint32(Lua_ItemInst::*)(void))&Lua_ItemInst::GetID) .def("GetItemScriptID", (uint32(Lua_ItemInst::*)(void))&Lua_ItemInst::GetItemScriptID) .def("GetItem", (Lua_Item(Lua_ItemInst::*)(void))&Lua_ItemInst::GetItem) - .def("SetItem", (void(Lua_ItemInst::*)(Lua_Item))&Lua_ItemInst::SetItem) .def("GetCharges", (int(Lua_ItemInst::*)(void))&Lua_ItemInst::GetCharges) .def("SetCharges", (void(Lua_ItemInst::*)(int))&Lua_ItemInst::SetCharges) .def("GetPrice", (uint32(Lua_ItemInst::*)(void))&Lua_ItemInst::GetPrice) @@ -310,7 +284,8 @@ luabind::scope lua_register_iteminst() { .def("SetCustomData", (void(Lua_ItemInst::*)(std::string,bool))&Lua_ItemInst::SetCustomData) .def("GetCustomData", (std::string(Lua_ItemInst::*)(std::string))&Lua_ItemInst::GetCustomData) .def("DeleteCustomData", (void(Lua_ItemInst::*)(std::string))&Lua_ItemInst::DeleteCustomData) - .def("SetScale", (void(Lua_ItemInst::*)(void))&Lua_ItemInst::SetScale) + .def("SetScaling", (void(Lua_ItemInst::*)(bool))&Lua_ItemInst::SetScaling) + .def("SetScale", (void(Lua_ItemInst::*)(double))&Lua_ItemInst::SetScale) .def("GetExp", (uint32(Lua_ItemInst::*)(void))&Lua_ItemInst::GetExp) .def("SetExp", (void(Lua_ItemInst::*)(uint32))&Lua_ItemInst::SetExp) .def("AddExp", (void(Lua_ItemInst::*)(uint32))&Lua_ItemInst::AddExp) diff --git a/zone/lua_iteminst.h b/zone/lua_iteminst.h index 99e2b30e0..4e3461b68 100644 --- a/zone/lua_iteminst.h +++ b/zone/lua_iteminst.h @@ -13,7 +13,7 @@ namespace luabind { luabind::scope lua_register_iteminst(); -class Lua_ItemInst : public Lua_Ptr +class Lua_ItemInst : public Lua_Ptr { typedef ItemInst NativeType; public: @@ -22,7 +22,7 @@ public: Lua_ItemInst() : Lua_Ptr(nullptr), cloned_(false) { } Lua_ItemInst(ItemInst *d) : Lua_Ptr(d), cloned_(false) { } Lua_ItemInst(ItemInst *d, bool cloned) : Lua_Ptr(d), cloned_(cloned) { } - virtual ~Lua_ItemInst() { if(cloned_) { void *ptr = GetLuaPtrData(); if(ptr) { delete ptr; } } } + virtual ~Lua_ItemInst() { if(cloned_) { ItemInst *ptr = GetLuaPtrData(); if(ptr) { delete ptr; } } } operator ItemInst*() { return reinterpret_cast(GetLuaPtrData()); @@ -63,6 +63,7 @@ public: void SetCustomData(std::string identifier, bool value); std::string GetCustomData(std::string identifier); void DeleteCustomData(std::string identifier); + void SetScaling(bool v); void SetScale(double scale_factor); uint32 GetExp(); void SetExp(uint32 exp); diff --git a/zone/lua_mob.h b/zone/lua_mob.h index 37be4aec8..9f23b5d34 100644 --- a/zone/lua_mob.h +++ b/zone/lua_mob.h @@ -21,7 +21,7 @@ class Lua_Mob : public Lua_Entity typedef Mob NativeType; public: Lua_Mob() { SetLuaPtrData(nullptr); } - Lua_Mob(Mob *d) { SetLuaPtrData(d); } + Lua_Mob(Mob *d) { SetLuaPtrData(reinterpret_cast(d)); } virtual ~Lua_Mob() { } operator Mob*() { @@ -331,6 +331,7 @@ public: void SetFlurryChance(int value); int GetFlurryChance(); int GetSkill(int skill_id); + void CalcBonuses(); }; #endif diff --git a/zone/lua_npc.h b/zone/lua_npc.h index fdbc66bd1..3ea322adc 100644 --- a/zone/lua_npc.h +++ b/zone/lua_npc.h @@ -20,7 +20,7 @@ class Lua_NPC : public Lua_Mob typedef NPC NativeType; public: Lua_NPC() { SetLuaPtrData(nullptr); } - Lua_NPC(NPC *d) { SetLuaPtrData(d); } + Lua_NPC(NPC *d) { SetLuaPtrData(reinterpret_cast(d)); } virtual ~Lua_NPC() { } operator NPC*() { diff --git a/zone/lua_object.h b/zone/lua_object.h index 9aa89d1da..b93c3e761 100644 --- a/zone/lua_object.h +++ b/zone/lua_object.h @@ -17,7 +17,7 @@ class Lua_Object : public Lua_Entity typedef Object NativeType; public: Lua_Object() { SetLuaPtrData(nullptr); } - Lua_Object(Object *d) { SetLuaPtrData(d); } + Lua_Object(Object *d) { SetLuaPtrData(reinterpret_cast(d)); } virtual ~Lua_Object() { } operator Object*() { diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index a670eeb3a..b19fe8aeb 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -186,8 +186,8 @@ LuaParser::LuaParser() { ItemArgumentDispatch[EVENT_UNEQUIP_ITEM] = handle_item_equip; ItemArgumentDispatch[EVENT_AUGMENT_ITEM] = handle_item_augment; ItemArgumentDispatch[EVENT_UNAUGMENT_ITEM] = handle_item_augment; - ItemArgumentDispatch[EVENT_AUGMENT_INSERT] = handle_item_augment_reverse; - ItemArgumentDispatch[EVENT_AUGMENT_REMOVE] = handle_item_augment_reverse; + ItemArgumentDispatch[EVENT_AUGMENT_INSERT] = handle_item_augment_insert; + ItemArgumentDispatch[EVENT_AUGMENT_REMOVE] = handle_item_augment_remove; SpellArgumentDispatch[EVENT_SPELL_EFFECT_CLIENT] = handle_spell_effect; SpellArgumentDispatch[EVENT_SPELL_BUFF_TIC_CLIENT] = handle_spell_tic; diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index 5b6ee976d..b19c0234d 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -505,14 +505,34 @@ void handle_item_augment(QuestInterface *parse, lua_State* L, Client* client, It luabind::object l_item_o = luabind::object(L, l_item); l_item_o.push(L); lua_setfield(L, -2, "aug"); + + lua_pushinteger(L, extra_data); + lua_setfield(L, -2, "slot_id"); } -void handle_item_augment_reverse(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data, +void handle_item_augment_insert(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data, std::vector *extra_pointers) { Lua_ItemInst l_item(reinterpret_cast(extra_pointers->at(0))); luabind::object l_item_o = luabind::object(L, l_item); l_item_o.push(L); lua_setfield(L, -2, "item"); + + lua_pushinteger(L, extra_data); + lua_setfield(L, -2, "slot_id"); +} + +void handle_item_augment_remove(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data, + std::vector *extra_pointers) { + Lua_ItemInst l_item(reinterpret_cast(extra_pointers->at(0))); + luabind::object l_item_o = luabind::object(L, l_item); + l_item_o.push(L); + lua_setfield(L, -2, "item"); + + lua_pushinteger(L, extra_data); + lua_setfield(L, -2, "slot_id"); + + lua_pushboolean(L, *reinterpret_cast(extra_pointers->at(1))); + lua_setfield(L, -2, "destroyed"); } void handle_item_null(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data, diff --git a/zone/lua_parser_events.h b/zone/lua_parser_events.h index 058da6511..50e3f927c 100644 --- a/zone/lua_parser_events.h +++ b/zone/lua_parser_events.h @@ -98,7 +98,9 @@ void handle_item_equip(QuestInterface *parse, lua_State* L, Client* client, Item std::vector *extra_pointers); void handle_item_augment(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data, std::vector *extra_pointers); -void handle_item_augment_reverse(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data, +void handle_item_augment_insert(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data, + std::vector *extra_pointers); +void handle_item_augment_remove(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data, std::vector *extra_pointers); void handle_item_null(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data, std::vector *extra_pointers); diff --git a/zone/lua_raid.h b/zone/lua_raid.h index 8cc8ec778..cc88a1c3d 100644 --- a/zone/lua_raid.h +++ b/zone/lua_raid.h @@ -14,7 +14,7 @@ namespace luabind { luabind::scope lua_register_raid(); -class Lua_Raid : public Lua_Ptr +class Lua_Raid : public Lua_Ptr { typedef Raid NativeType; public: diff --git a/zone/lua_spell.h b/zone/lua_spell.h index d87c3654c..ba1307754 100644 --- a/zone/lua_spell.h +++ b/zone/lua_spell.h @@ -12,7 +12,7 @@ namespace luabind { luabind::scope lua_register_spell(); -class Lua_Spell : public Lua_Ptr +class Lua_Spell : public Lua_Ptr { typedef const SPDat_Spell_Struct NativeType; public: diff --git a/zone/mob.cpp b/zone/mob.cpp index 9fde24219..941d14360 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1075,9 +1075,6 @@ void Mob::SendHPUpdate() // destructor will free the pBuffer CreateHPPacket(&hp_app); -#ifdef MANAGE_HP_UPDATES - entity_list.QueueManaged(this, &hp_app, true); -#else // send to people who have us targeted entity_list.QueueClientsByTarget(this, &hp_app, false, 0, false, true, BIT_AllClients); entity_list.QueueClientsByXTarget(this, &hp_app, false); @@ -1115,7 +1112,6 @@ void Mob::SendHPUpdate() { GetPet()->CastToClient()->QueuePacket(&hp_app, false); } -#endif //MANAGE_HP_PACKETS // Update the damage state of destructible objects if(IsNPC() && IsDestructibleObject()) @@ -1195,9 +1191,6 @@ void Mob::SendPosUpdate(uint8 iSendToSelf) { } else { -#ifdef PACKET_UPDATE_MANAGER - entity_list.QueueManaged(this, app, (iSendToSelf==0),false); -#else if(move_tic_count == RuleI(Zone, NPCPositonUpdateTicCount)) { entity_list.QueueClients(this, app, (iSendToSelf==0), false); @@ -1208,7 +1201,6 @@ void Mob::SendPosUpdate(uint8 iSendToSelf) { entity_list.QueueCloseClients(this, app, (iSendToSelf==0), 800, nullptr, false); move_tic_count++; } -#endif } safe_delete(app); } @@ -1372,12 +1364,6 @@ void Mob::GMMove(float x, float y, float z, float heading, bool SendUpdate) { CastToNPC()->SaveGuardSpot(true); if(SendUpdate) SendPosition(); - //SendPosUpdate(1); -#ifdef PACKET_UPDATE_MANAGER - if(IsClient()) { - CastToClient()->GetUpdateManager()->FlushQueues(); - } -#endif } void Mob::SendIllusionPacket(uint16 in_race, uint8 in_gender, uint8 in_texture, uint8 in_helmtexture, uint8 in_haircolor, uint8 in_beardcolor, uint8 in_eyecolor1, uint8 in_eyecolor2, uint8 in_hairstyle, uint8 in_luclinface, uint8 in_beard, uint8 in_aa_title, uint32 in_drakkin_heritage, uint32 in_drakkin_tattoo, uint32 in_drakkin_details, float in_size) { diff --git a/zone/perl_questitem.cpp b/zone/perl_questitem.cpp index 0396ec666..fa5fd1c77 100644 --- a/zone/perl_questitem.cpp +++ b/zone/perl_questitem.cpp @@ -79,7 +79,7 @@ XS(XS_QuestItem_SetScale) Mult = (float)SvNV(ST(1)); if(THIS->IsScaling()) { - ((EvoItemInst*)THIS)->SetExp((int)(Mult*10000+.5)); + THIS->SetExp((int)(Mult*10000+.5)); } } XSRETURN_EMPTY; diff --git a/zone/spells.cpp b/zone/spells.cpp index 28fca659d..489131961 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -3472,15 +3472,6 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r TrySpellTrigger(spelltar, spell_id); TryApplyEffect(spelltar, spell_id); - - if(spell_id == 982) // Cazic Touch, hehe =P - { - char target_name[64]; - strcpy(target_name, spelltar->GetCleanName()); - strupr(target_name); - Shout("%s!", target_name); - } - if (spelltar->IsAIControlled() && IsDetrimentalSpell(spell_id) && !IsHarmonySpell(spell_id)) { int32 aggro_amount = CheckAggroAmount(spell_id, isproc); mlog(SPELLS__CASTING, "Spell %d cast on %s generated %d hate", spell_id, spelltar->GetName(), aggro_amount); diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index dc1a6172d..bdc59248e 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -164,6 +164,8 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme } else { + ItemInst *old_aug = nullptr; + const uint32 id = auged_with->GetID(); ItemInst *aug = tobe_auged->GetAugment(in_augment->augment_slot); if(aug) { std::vector args; @@ -171,15 +173,20 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme parse->EventItem(EVENT_UNAUGMENT_ITEM, user, tobe_auged, nullptr, "", slot, &args); args.assign(1, tobe_auged); + bool destroyed = false; + if(id == 40408 || id == 40409 || id == 40410) { + destroyed = true; + } + + args.push_back(&destroyed); + parse->EventItem(EVENT_AUGMENT_REMOVE, user, aug, nullptr, "", slot, &args); } - ItemInst *old_aug=nullptr; - const uint32 id=auged_with->GetID(); - if (id==40408 || id==40409 || id==40410) + if(id == 40408 || id == 40409 || id == 40410) tobe_auged->DeleteAugment(in_augment->augment_slot); else - old_aug=tobe_auged->RemoveAugment(in_augment->augment_slot); + old_aug = tobe_auged->RemoveAugment(in_augment->augment_slot); itemOneToPush = tobe_auged->Clone(); if (old_aug) diff --git a/zone/updatemgr.cpp b/zone/updatemgr.cpp deleted file mode 100644 index bc155ed04..000000000 --- a/zone/updatemgr.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) - - 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 -*/ -#include "../common/debug.h" -#include "../common/features.h" - -#ifdef PACKET_UPDATE_MANAGER -#include "updatemgr.h" -#include "mob.h" -#include "../common/EQStream.h" - -//squared distances for each level -//these values are pulled out of my ass, should be tuned some day -const float UpdateManager::level_distances2[UPDATE_LEVELS] - = { 50*50, 250*250, 500*500, 800*800 }; - -//delay between sending packets in each level, in ms -//its best if they are all multiples of UPDATE_RESOLUTION -//these values are pulled out of my ass, should be tuned some day -const uint32 UpdateManager::level_timers[UPDATE_LEVELS+1] = { UPDATE_RESOLUTION, //.3s - 2*UPDATE_RESOLUTION, //.6s - 3*UPDATE_RESOLUTION, //.9s - 9*UPDATE_RESOLUTION, //~2s - 34*UPDATE_RESOLUTION //~10s - }; - - -/* - This system assumes that two packets sent by a mob with the same - opcodes contain the same info at different times, and will prefer - to send only the most recent packet. If this is bad, then this - thing needs a redesign. - -*/ - -//build a unique ID based on opcode and mob id.. -#define MakeUpdateID(mob, app) (((mob->GetID())<<12) | (app->GetOpcode()&0xFFF)) - -UpdateManager::UpdateManager(EQStream *c) - : limiter(UPDATE_RESOLUTION) -{ - net = c; - int r; - for(r = 0; r <= UPDATE_LEVELS; r++) { - timers[r] = new Timer(level_timers[r]); - } -} - -UpdateManager::~UpdateManager() { - int r; - UMMap::iterator cur,end; - for(r = 0; r <= UPDATE_LEVELS; r++) { - safe_delete(timers[r]); - cur = levels[r].begin(); - end = levels[r].end(); - for(; cur != end; cur++) { - EQApplicationPacket *tmp = cur->second.app; - EQApplicationPacket::PacketUsed(&tmp); - } - levels[r].clear(); - } -} - -/* - Puts a packet into its proper spacial queue -*/ -void UpdateManager::QueuePacket(EQApplicationPacket *app, bool ack_req, Mob *from, float range2) { - int r = UPDATE_LEVELS; - UMMap *cur = levels; - const float *cur_d = level_distances2; - cur += UPDATE_LEVELS; //move to the end. - cur_d += UPDATE_LEVELS - 1; - //work backwards since mobs are more likely to be further away - for(r = UPDATE_LEVELS; r >= 0; r--, cur--, cur_d--) { - if(range2 < *cur_d) - continue; - //this packet falls into this queue... - uint32 id = MakeUpdateID(from, app); -// if(r < 2) -// net->QueuePacket(app, ack_req); -//LogFile->write(EQEMuLog::Debug, "Queueing packet from %s (0x%.4x) id=0x%x at level %d\n", from->GetName(), app->GetOpcode(), id, r); - app->PacketReferenced(); - //reference decrementing is taken care of my UMType destructor - //if anything is overwritten - (*cur)[id] = UMType(app, ack_req); -// (*cur)[id] = UMType(app->Copy(), ack_req); - return; - } - //if we get here, were in trouble... -} - -void UpdateManager::Process() { - if(!limiter.Check()) - return; - Timer **curt = timers; - int r; - for(r = 0; r <= UPDATE_LEVELS; r++, curt++) { - if(!(*curt)->Check()) - continue; - _SendLevel(r); - } -} - -void UpdateManager::FlushQueues() { - limiter.Start(); - Timer **curt = timers; - int r; - for(r = 0; r <= UPDATE_LEVELS; r++, curt++) { - (*curt)->Start(); - _SendLevel(r); - } -} - -void UpdateManager::_SendLevel(int level) { -/*LogFile->write(EQEMuLog::Error, "Sending for level %d", level); -if(level > 0) -{ - int r; - for(r = 0; r <= UPDATE_LEVELS; r++) { - LogFile->write(EQEMuLog::Error, "Level %d: %d", r, levels[r].size()); - } - { - float range2 = 5; - int r = UPDATE_LEVELS; - UMMap *cur = levels; - const float *cur_d = level_distances2; - cur += UPDATE_LEVELS; //move to the end. - cur_d += UPDATE_LEVELS - 1; - //work backwards since mobs are more likely to be further away - for(r = UPDATE_LEVELS; r >= 0; r--, cur--, cur_d--) { - LogFile->write(EQEMuLog::Error, "If they are less than %f away, they dont go in level %d", *cur_d, r); - if(range2 < *cur_d) - continue; - LogFile->write(EQEMuLog::Error, "A mob %f away gets put into level %d", range2, r); - } - } -}*/ - - UMMap::iterator cur,end; - UMMap *curm; - UMMap *om = levels + level; - cur = om->begin(); - end = om->end(); - uint32 key; - int r; - - while(cur != end) { - key = cur->first; - //relies on fast queue setting .app to null if it eats it -//LogFile->write(EQEMuLog::Debug, "Sending id 0x%x for level %d\n", key, level); - net->FastQueuePacket(&cur->second.app, cur->second.ack); -//EQApplicationPacket::PacketUsed(&cur->second.app); - cur++; - om->erase(key); - - //need to clear our any updates in slower levels - //so mobs dont jump backwards from old updates - curm = om + 1; - for(r = level+1; r <= UPDATE_LEVELS; r++, curm++) { - //do we need this count check? - if(curm->count(key) != 0) { - //reference decrementing is taken care of my UMType destructor - EQApplicationPacket *tmp = (*curm)[key].app; - curm->erase(key); - EQApplicationPacket::PacketUsed(&tmp); - } - } - } -} - - -#endif //PACKET_UPDATE_MANAGER - diff --git a/zone/updatemgr.h b/zone/updatemgr.h deleted file mode 100644 index ffc0a0c15..000000000 --- a/zone/updatemgr.h +++ /dev/null @@ -1,89 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) - - 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 UPDATE_MANAGER_H -#define UPDATE_MANAGER_H - -#include "../common/features.h" -#ifdef PACKET_UPDATE_MANAGER - -#include "../common/timer.h" -#include - -/*typedef enum { - updateMobPOS = 1, - updateMobHP -} updateType;*/ - -//the number of different queue levels to use -#define UPDATE_LEVELS 4 -#define UPDATE_RESOLUTION 300 -#define UPDATE_DROP_RANGE 800 - -//if the player moves more than this ammount, all queues are flushed. -#define UPDATE_JUMP_FLUSH 200 // - -class EQStream; -class EQApplicationPacket; -class Mob; - -class UMType { -public: - UMType() { - app = nullptr; ack = false; - } - UMType(EQApplicationPacket *_app, bool _ack) { - app = _app; ack = _ack; - } - - EQApplicationPacket *app; - bool ack; -}; - -typedef std::map UMMap; - -class UpdateManager { -protected: - //squared distances for each level - static const float level_distances2[UPDATE_LEVELS]; - - //delay between sending packets in each level, in ms - static const uint32 level_timers[UPDATE_LEVELS+1]; - -public: - UpdateManager(EQStream *c); - ~UpdateManager(); - - //range2 is the range of 'from' to this client, squared - void QueuePacket(EQApplicationPacket *app, bool ack_req, Mob *from, float range2); - void Process(); - void FlushQueues(); - -protected: - void _SendLevel(int level); - - EQStream *net; - - UMMap levels[UPDATE_LEVELS+1]; - Timer *timers[UPDATE_LEVELS+1]; - Timer limiter; -}; - -#endif //PACKET_UPDATE_MANAGER - -#endif - diff --git a/zone/zoning.cpp b/zone/zoning.cpp index e710161b9..3b5112c78 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -625,11 +625,6 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z //send out updates to people in zone. SendPosition(); - -#ifdef PACKET_UPDATE_MANAGER - //flush our position queues because we dont know where we will end up - update_manager.FlushQueues(); -#endif } EQApplicationPacket* outapp = new EQApplicationPacket(OP_RequestClientZoneChange, sizeof(RequestClientZoneChange_Struct));