Skip to content

Instantly share code, notes, and snippets.

@Tasssadar
Created September 28, 2010 21:33
Show Gist options
  • Save Tasssadar/601823 to your computer and use it in GitHub Desktop.
Save Tasssadar/601823 to your computer and use it in GitHub Desktop.
src/game/Group.cpp | 33 ++++++++++++++++++++++++
src/game/Group.h | 3 ++
src/game/GroupHandler.cpp | 3 ++
src/game/Object.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++-
src/game/Object.h | 3 ++
src/game/TradeHandler.cpp | 6 +++-
src/game/Unit.cpp | 3 ++
src/game/Unit.h | 9 ++++++-
8 files changed, 118 insertions(+), 4 deletions(-)
diff --git a/src/game/Group.cpp b/src/game/Group.cpp
index 7aa97e1..ea9756c 100644
--- a/src/game/Group.cpp
+++ b/src/game/Group.cpp
@@ -308,6 +308,9 @@ bool Group::AddMember(const uint64 &guid, const char* name)
uint32 Group::RemoveMember(const uint64 &guid, const uint8 &method)
{
+// Frozen Mod
+BroadcastGroupUpdate();
+// Frozen Mod
// remove member and change leader (if need) only if strong more 2 members _before_ member remove
if(GetMembersCount() > uint32(isBGGroup() ? 1 : 2)) // in BG group case allow 1 members group
{
@@ -1742,6 +1745,36 @@ void Group::_homebindIfInstance(Player *player)
player->m_InstanceValid = false;
}
}
+//Frozen Mod
+void Group::BroadcastGroupUpdate(void)
+{
+ for(member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
+ {
+ Player *pp = sObjectMgr.GetPlayer(citr->guid);
+ if(pp && pp->IsInWorld())
+ {
+ pp->ForceValuesUpdateAtIndex(UNIT_FIELD_BYTES_2);
+ pp->ForceValuesUpdateAtIndex(UNIT_FIELD_FACTIONTEMPLA TE);
+ DEBUG_LOG("-- Forced group value update for '%s'", pp->GetName());
+ if(pp->GetPet())
+ {
+ pp->GetPet()->ForceValuesUpdateAtIndex(UNIT_FIELD_BYTES_2);
+ pp->GetPet()->ForceValuesUpdateAtIndex(UNIT_FIELD_FACTIONTEMPLA TE);
+ DEBUG_LOG("-- Forced group value update for '%s' pet '%s'", pp->GetName(), pp->GetPet()->GetName());
+ }
+for(uint32 i = 0; i < MAX_TOTEM_SLOT; ++i)
+ {
+ if(Unit *totem = Unit::GetUnit(*pp, pp->m_TotemSlot[i]))
+ {
+ totem->ForceValuesUpdateAtIndex(UNIT_FIELD_BYTES_2);
+ totem->ForceValuesUpdateAtIndex(UNIT_FIELD_FACTIONTEMPLA TE);
+ DEBUG_LOG("-- Forced group value update for '%s' totem #%u", pp->GetName(), i);
+ }
+ }
+ }
+ }
+}
+// Frozen Mod
static void RewardGroupAtKill_helper(Player* pGroupGuy, Unit* pVictim, uint32 count, bool PvP, float group_rate, uint32 sum_level, bool is_dungeon, Player* not_gray_member_with_max_level, Player* member_with_max_level, uint32 xp )
{
diff --git a/src/game/Group.h b/src/game/Group.h
index c9cffe3..93c090f 100644
--- a/src/game/Group.h
+++ b/src/game/Group.h
@@ -357,6 +357,9 @@ class MANGOS_DLL_SPEC Group
InstanceGroupBind* GetBoundInstance(Player* player);
InstanceGroupBind* GetBoundInstance(Map* aMap, Difficulty difficulty);
BoundInstancesMap& GetBoundInstances(Difficulty difficulty) { return m_boundInstances[difficulty]; }
+// Frozen Mod
+ void BroadcastGroupUpdate(void);
+// Frozen Mod
protected:
bool _addMember(const uint64 &guid, const char* name, bool isAssistant=false);
diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp
index d73b233..e2bbf39 100644
--- a/src/game/GroupHandler.cpp
+++ b/src/game/GroupHandler.cpp
@@ -207,6 +207,9 @@ void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data )
// everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
return;
+// Frozen Mod
+group->BroadcastGroupUpdate();
+// Frozen Mod
}
void WorldSession::HandleGroupDeclineOpcode( WorldPacket & /*recv_data*/ )
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 55fc2d0..d842d50 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -657,6 +657,52 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
else
*data << (m_uint32Values[ index ] & ~UNIT_DYNFLAG_TAPPED);
}
+// Frozen Mod
+
+else if(index == UNIT_FIELD_BYTES_2 || index == UNIT_FIELD_FACTIONTEMPLATE)
+{
+bool ch = false;
+if((GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT) && target != this)
+{
+bool forcefriendly = false; // bool for pets/totems to offload more code from the big if below
+if(GetTypeId() == TYPEID_UNIT)
+{
+forcefriendly = (((Creature*)this)->isTotem() || ((Creature*)this)->isPet())
+&& ((Creature*)this)->GetOwner()->GetTypeId() == TYPEID_PLAYER
+&& ((Creature*)this)->GetOwner()->IsFriendlyTo(target) // pet owner must be friendly to target
+&& ((Creature*)this)->GetOwner() != target // no need to send hackfix to pet owner
+&& (target->IsInSameGroupWith((Player*)((Creature*)this)->GetOwner()) || target->IsInSameRaidWith((Player*)((Creature*)this)->GetOwner()));
+}
+
+if(((Unit*)this)->IsSpoofSamePlayerFaction() || forcefriendly
+|| (target->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER && (target->IsInSameGroupWith((Player*)this) || target->IsInSameRaidWith((Player*)this))))
+{
+if(index == UNIT_FIELD_BYTES_2)
+{
+DEBUG_LOG("-- VALUES_UPDATE: Sending '%s' the blue-group-fix from '%s' (flag)", target->GetName(), ((Unit*)this)->GetName());
+*data << ( m_uint32Values[ index ] & (UNIT_BYTE2_FLAG_SANCTUARY << 8) ); // this flag is at uint8 offset 1 !!
+ch = true;
+}
+else if(index == UNIT_FIELD_FACTIONTEMPLATE)
+{
+FactionTemplateEntry const *ft1, *ft2;
+ft1 = ((Unit*)this)->getFactionTemplateEntry();
+ft2 = ((Unit*)target)->getFactionTemplateEntry();
+if(ft1 && ft2 && (!ft1->IsFriendlyTo(*ft2) || ((Unit*)this)->IsSpoofSamePlayerFaction()))
+{
+uint32 faction = ((Player*)target)->getFaction(); // pretend that all other HOSTILE players have own faction, to allow follow, heal, rezz (trade wont work)
+DEBUG_LOG("-- VALUES_UPDATE: Sending '%s' the blue-group-fix from '%s' (faction %u)", target->GetName(), ((Unit*)this)->GetName(), faction);
+*data << uint32(faction);
+ch = true;
+}
+}
+}
+}
+if(!ch)
+*data << m_uint32Values[ index ];
+
+}
+// Frozen Mod
else
{
// send in current format (float as float, uint32 as uint32)
@@ -1662,7 +1708,21 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
// return the creature therewith the summoner has access to it
return pCreature;
+ }
+// Frozen Mod
+void Object::ForceValuesUpdateAtIndex(uint32 i)
+{
+ m_uint32Values_mirror[i] = GetUInt32Value(i) + 1; // makes server think the field changed
+ if(m_inWorld)
+ {
+ if(!m_objectUpdated)
+ {
+ AddToClientUpdateList();
+ m_objectUpdated = true;
+ }
+ }
}
+// Frozen Mod
namespace MaNGOS
{
@@ -1945,4 +2005,4 @@ bool WorldObject::IsControlledByPlayer() const
default:
return false;
}
-}
\ No newline at end of file
+}
diff --git a/src/game/Object.h b/src/game/Object.h
index 04c31f0..055e2d5 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -276,6 +276,9 @@ class MANGOS_DLL_SPEC Object
virtual bool hasQuest(uint32 /* quest_id */) const { return false; }
virtual bool hasInvolvedQuest(uint32 /* quest_id */) const { return false; }
+// Frozen Mod
+ void ForceValuesUpdateAtIndex(uint32);
+// Frozen Mod
protected:
Object ( );
diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp
index e9c636f..719986e 100644
--- a/src/game/TradeHandler.cpp
+++ b/src/game/TradeHandler.cpp
@@ -531,12 +531,14 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacke t& recvPacket)
SendTradeStatus(TRADE_STATUS_IGNORE_YOU);
return;
}
-
- if (pOther->GetTeam() !=_player->GetTeam() )
+// Frozen Mod
+/* if (pOther->GetTeam() !=_player->GetTeam() )
{
SendTradeStatus(TRADE_STATUS_WRONG_FACTION);
return;
}
+*/
+// Frozen Mod
if (!pOther->IsWithinDistInMap(_player,10.0f,false))
{
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index f54cca2..47272ab 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -251,6 +251,9 @@ Unit::Unit()
// remove aurastates allowing special moves
for(int i=0; i < MAX_REACTIVE; ++i)
m_reactiveTimer[i] = 0;
+// Frozen Mod
+ m_spoofSamePlayerFaction = false;
+// Frozen Mod
}
Unit::~Unit()
diff --git a/src/game/Unit.h b/src/game/Unit.h
index b4b4077..b059fc1 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1822,6 +1822,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
PetAuraSet m_petAuras;
void AddPetAura(PetAura const* petSpell);
void RemovePetAura(PetAura const* petSpell);
+// Frozen Mod
+ inline void SetSpoofSamePlayerFaction(bool b) { m_spoofSamePlayerFaction = b; }
+ inline bool IsSpoofSamePlayerFaction(void) {return m_spoofSamePlayerFaction; }
+// Frozen Mod
// Movement info
MovementInfo m_movementInfo;
@@ -1873,8 +1877,11 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
uint32 m_reactiveTimer[MAX_REACTIVE];
uint32 m_regenTimer;
uint32 m_lastManaUseTimer;
+// Frozen Mod
+ bool m_spoofSamePlayerFaction : 1;
+// Frozen Mod
- private:
+ public:
void CleanupDeletedAuras();
bool IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura* aura, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const*& spellProcEvent );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment