Free and awesome. That's what mangos is!

You are not logged in.

Announcement

mangos-zero and mangos-one commit messages are available on Twitter, too. Follow mangos_zero and mangos_one for your classic and outlandish fun.

In case of trouble: you can reach the administrative team via Twitter@getmangos, and via mail.

#1 2009-05-13 01:55:05

Frozen-In-Time
Seed
Registered: 2008-11-03
Posts: 8
Website

Re: [PATCH] Horde & Alliance grouping/trade

This patch allows you to interact with any player horde or alliance as if they were your own faction. Only while in a group or a raid. This means trades, grouping, healing, enchanting in trade window and rez's work. I attempted to change the code so you could turn it on and off based on the mangosd.conf twoside options but for some reason I'm stuck. Anyway, here's the completed patch without conf checks. This patch was originated by False.Genesis. The ability to trade was possible due to help from Prefect, one of my server admin. Onwards to the patch. It is a git patch and my server version is 7464.

Patch posted below.
[color="Red"]
[UPDATE - NEW PATCH JUNE 9 2010 - WORKING MaNGOS/0.16.0 (* * Revision 10044 - *) ][/color]

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_FACTIONTEMPLATE);
+ 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_FACTIONTEMPLATE);
+ 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_FACTIONTEMPLATE);
+ 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 << glasses ); // 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(WorldPacket& 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 );

Offline

#2 2009-05-13 02:10:44

cyrex
Cereals incoming
Registered: 2006-03-09
Posts: 268

Re: [PATCH] Horde &amp; Alliance grouping/trade

I have not tested still (Cause am at work and just noticed this) but just a couple of questions:

1. Did you test out al you are mentioning here. I mean trade, enchant, healing in a group or raid. Well basically everything before the change in 3.0.3.

2. Did you test it out with latest version since there has been MANY changes from your 7464 up to now.

3. Any crashes or mangos system stability issues that we should worry about?

Offline

#3 2009-05-13 02:28:40

Frozen-In-Time
Seed
Registered: 2008-11-03
Posts: 8
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

1. Did you test out al you are mentioning here. I mean trade, enchant, healing in a group or raid. Well basically everything before the change in 3.0.3.


Yea it all works.

2. Did you test it out with latest version since there has been MANY changes from your 7464 up to now.


No. I don't run the latest version ever. I am always behind. I find a stable and stick with it until I find the next stable.

3. Any crashes or mangos system stability issues that we should worry about?


Other than me typing Ctrl-C by accident in the server window today, my server has not crashed in months.

Offline

#4 2009-05-13 14:57:27

LouisePalmer
Seed
Registered: 2009-02-25
Posts: 5

Re: [PATCH] Horde &amp; Alliance grouping/trade

Yeah, very nice.

I think it's necessary to integrate it in mangos core !
Many server have few player and it will be fantastic that we just have to activate it in conf files like an option.

THX

Offline

#5 2009-05-13 15:58:12

subhuman_bob
Cereals incoming
Registered: 2007-02-06
Posts: 104
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

+            if(target->getRace() == RACE_HUMAN)
+            *data << uint32(1);
+            else if(target->getRace() == RACE_ORC)
+            *data << uint32(2);
+            else if(target->getRace() == RACE_DWARF)           
+            *data << uint32(3);
+            else if(target->getRace() == RACE_NIGHTELF)           
+            *data << uint32(4);
+            else if(target->getRace() == RACE_UNDEAD_PLAYER)           
+            *data << uint32(5);
+            else if(target->getRace() == RACE_TAUREN)           
+            *data << uint32(6);
+            else if(target->getRace() == RACE_GNOME)           
+            *data << uint32(115);
+            else if(target->getRace() == RACE_TROLL)
+            *data << uint32(116);
+            else if(target->getRace() == RACE_BLOODELF)
+            *data << uint32(1610);
+            else if(target->getRace() == RACE_DRAENEI)
+            *data << uint32(1629);

There has to be a more efficient way of doing this. That's a lot of CPU time tied up right there.


Visit UDB Forums for a playable DataBase for MaNGOS.   Now with 3.2.2a data and a good source of rebirth in flames!
Note: forum address has been updated in my sig 16 Nov 2009
Millions of people worldwide suffer from insomnia, however I'm not gonna lose any sleep worrying about it.

Offline

#6 2009-05-13 19:47:03

xoum89
Seed
Registered: 2008-10-26
Posts: 13

Re: [PATCH] Horde &amp; Alliance grouping/trade

Thx for your patch.
but i have errors

error: patch failed: src/game/GroupHandler.cpp:197
error: src/game/GroupHandler.cpp: patch does not apply

can you help me ?

if i change your patch
by

diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp
old mode 100644
new mode 100755
index d1de13a..0778c92
--- a/src/game/GroupHandler.cpp
+++ b/src/game/GroupHandler.cpp
@@ -197,6 +197,14 @@ void WorldSession::HandleGroupAcceptOpcode( WorldPacket & /*recv_data*/ )
         return;

[color="Red"]+     uint8 subgroup = group->GetMemberGroup(GetPlayer()->GetGUID());[/color]
+// Monkey
+    bool allowTwoSideGroup = sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP);
+    if ( allowTwoSideGroup )
+    {
+    GetPlayer()->SetGroup(group, subgroup); // Defunct line added for test
+    group->BroadcastGroupUpdate();
+    }
+// Monkey
}

fatal: corrupt patch at line 91

Offline

#7 2009-05-13 20:05:41

Frozen-In-Time
Seed
Registered: 2008-11-03
Posts: 8
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

There has to be a more efficient way of doing this. That's a lot of CPU time tied up right there.

Have not noticed. Running AMD dual core with 1g mem only on Ubuntu Linux with a 7megabit connection. Of course we never have more than 20-30 people on at once. Your more than welcome to come see it working on my server if you'd like, might save you compile time if you don't like the way it works. enchanted-arts.com. 3.09 client.

xoum89
Open group handler.cpp and add the changes manually. That's what I did with the original False.Genisis code.

Offline

#8 2009-05-13 20:43:22

ckegg
Is it an apple?
Registered: 2007-10-08
Posts: 60

Re: [PATCH] Horde &amp; Alliance grouping/trade

Frozen-In-Time;71462 wrote:

Have not noticed. Running AMD dual core with 1g mem only on Ubuntu Linux with a 7megabit connection. Of course we never have more than 20-30 people on at once. Your more than welcome to come see it working on my server if you'd like, might save you compile time if you don't like the way it works. enchanted-arts.com. 3.09 client.

Maybe this?

uint32 race_data = target->getRace();
if(race_data == RACE_HUMAN)
  *data << uint32(1);
else if(race_data == RACE_ORC)
  ...................

do getRace() once

Offline

#9 2009-05-13 21:18:03

xoum89
Seed
Registered: 2008-10-26
Posts: 13

Re: [PATCH] Horde &amp; Alliance grouping/trade

doesn't work after modify .cpp and .h manualy.
Need a patch, Or good file, thx.

Offline

#10 2009-05-14 05:18:11

subhuman_bob
Cereals incoming
Registered: 2007-02-06
Posts: 104
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

uint32 race_data = target->getRace();
if(race_data == RACE_HUMAN)
  *data << uint32(1);
else if(race_data == RACE_ORC)

That's a good start, and part of what I was thinking of.  Yes, only doing getRace() one time is much more efficient.
The next logical improvement would be to use a switch.

Have not noticed. Running AMD dual core with 1g mem only on Ubuntu Linux with a 7megabit connection. Of course we never have more than 20-30 people on at once. Your more than welcome to come see it working on my server if you'd like, might save you compile time if you don't like the way it works.

Whether you can notice it or not is immaterial, looking up a player's race up to ten times in a row is inefficient- period.
Losing several hundred (or possibly thousands) of clock cycles on a multi-core multi-GHz CPU is not noticeable to a human.  Those wasted CPU cycles occur far too quickly for us to notice.


Visit UDB Forums for a playable DataBase for MaNGOS.   Now with 3.2.2a data and a good source of rebirth in flames!
Note: forum address has been updated in my sig 16 Nov 2009
Millions of people worldwide suffer from insomnia, however I'm not gonna lose any sleep worrying about it.

Offline

#11 2009-05-14 09:16:30

cyrex
Cereals incoming
Registered: 2006-03-09
Posts: 268

Re: [PATCH] Horde &amp; Alliance grouping/trade

xoum89;71461 wrote:

Thx for your patch.
but i have errors


can you help me ?

if i change your patch
by

Same error. for me line 197 is this

+    // Monkey
+    //    if(pOther->GetTeam() !=_player->GetTeam() )
+    //    {
+    //        SendTradeStatus(TRADE_STATUS_WRONG_FACTION);
[b]+    //        return;[/b] <--- Line 197
+    //    }
+    // Monkey
 

I do not get it. This is a commented line.

Offline

#12 2009-05-14 13:09:50

patro
Seed
Registered: 2007-07-09
Posts: 15

Re: [PATCH] Horde &amp; Alliance grouping/trade

ckegg;71467 wrote:

Maybe this?

uint32 race_data = target->getRace();
if(race_data == RACE_HUMAN)
*data << uint32(1);
else if(race_data == RACE_ORC)
...................

do getRace() once

I always used this from False.Genesis's GitHub:

2[/COLOR][/SIZE]22[/COLOR][/SIZE]22[/COLOR][/SIZE]22[/COLOR][/SIZE]22[/COLOR][/SIZE]22[/COLOR][/SIZE]22[/COLOR][/SIZE]22[/COLOR][/SIZE]22[/COLOR][/SIZE]2


It always worked for me smile

Offline

#13 2009-05-14 16:02:40

Shin Darth
Cereals incoming
From: Italy
Registered: 2008-11-01
Posts: 140
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

but i have errors

[QUOTE]error: patch failed: src/game/GroupHandler.cpp:197
error: src/game/GroupHandler.cpp: patch does not apply

[/QUOTE]


it's the same for me, need help plz!


☭ Antifascist ☭

Visit UDB Forums for a playable DataBase for MaNGOS. Supports 3.3.5a.

Offline

#14 2009-05-14 16:16:44

patro
Seed
Registered: 2007-07-09
Posts: 15

Re: [PATCH] Horde &amp; Alliance grouping/trade

Shin Darth;71536 wrote:

it's the same for me, need help plz!

What server rev are you trying to apply it to?
Cuz he said in the first post the patch was for rev 7464

Offline

#15 2009-05-14 16:29:32

Shin Darth
Cereals incoming
From: Italy
Registered: 2008-11-01
Posts: 140
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

the latest, 7825


☭ Antifascist ☭

Visit UDB Forums for a playable DataBase for MaNGOS. Supports 3.3.5a.

Offline

#16 2009-05-14 17:13:41

patro
Seed
Registered: 2007-07-09
Posts: 15

Re: [PATCH] Horde &amp; Alliance grouping/trade

For rev. 7776 (last one i made)

diff --git a/src/game/Group.cpp b/src/game/Group.cpp
index b2b495c..a2b99f1 100644
--- a/src/game/Group.cpp
+++ b/src/game/Group.cpp
@@ -310,6 +310,8 @@ bool Group::AddMember(const uint64 &guid, const char* name)
 
 uint32 Group::RemoveMember(const uint64 &guid, const uint8 &method)
 {
+ BroadcastGroupUpdate();
+
     // remove member and change leader (if need) only if strong more 2 members _before_ member remove
     if(GetMembersCount() > (isBGGroup() ? 1 : 2))           // in BG group case allow 1 members group
     {
@@ -1595,3 +1597,18 @@ void Group::_homebindIfInstance(Player *player)
             player->m_InstanceValid = false;
     }
 }
+
+void Group::BroadcastGroupUpdate(void)
+{
+ // Group Hack: force flags update on group leave - for values update hack
+ for(member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
+ {
+  Player *pp = objmgr.GetPlayer(citr->guid);
+  if(pp && pp->IsInWorld())
+  {
+   pp->ForceValuesUpdateAtIndex(UNIT_FIELD_BYTES_2);
+   pp->ForceValuesUpdateAtIndex(UNIT_FIELD_FACTIONTEMPLATE);
+   DEBUG_LOG("-- Forced group value update for '%s'", pp->GetName());
+  }
+ }
+}
\ No newline at end of file
diff --git a/src/game/Group.h b/src/game/Group.h
index 478b7c5..17cfac9 100644
--- a/src/game/Group.h
+++ b/src/game/Group.h
@@ -330,6 +330,9 @@ class MANGOS_DLL_SPEC Group
         InstanceGroupBind* GetBoundInstance(uint32 mapid, uint8 difficulty);
         BoundInstancesMap& GetBoundInstances(uint8 difficulty) { return m_boundInstances[difficulty]; }
 
+  //Group hack.
+  void BroadcastGroupUpdate(void);
+
     protected:
         bool _addMember(const uint64 &guid, const char* name, bool isAssistant=false);
         bool _addMember(const uint64 &guid, const char* name, bool isAssistant, uint8 group);
diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp
index b7c55e6..0373ab4 100644
--- a/src/game/GroupHandler.cpp
+++ b/src/game/GroupHandler.cpp
@@ -196,6 +196,7 @@ void WorldSession::HandleGroupAcceptOpcode( WorldPacket & /*recv_data*/ )
     if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
         return;
 
+ group->BroadcastGroupUpdate();
 }
 
 void WorldSession::HandleGroupDeclineOpcode( WorldPacket & /*recv_data*/ )
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 15963e8..35da227 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -637,6 +637,38 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
                     else
                         *data << (m_uint32Values[ index ] & ~UNIT_DYNFLAG_OTHER_TAGGER);
                 }
+    // FG: pretend that OTHER players in own group are friendly ("blue")
+    else if(index == UNIT_FIELD_BYTES_2 || index == UNIT_FIELD_FACTIONTEMPLATE)
+    {
+    bool ch = false;
+    if(target->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER && target != this)
+    {
+     if(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(), ((Player*)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 = ((Player*)this)->getFactionTemplateEntry();
+       ft2 = ((Player*)target)->getFactionTemplateEntry();
+       if(ft1 && ft2 && !ft1->IsFriendlyTo(*ft2))
+        {
+        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(), ((Player*)this)->GetName(), faction);
+        *data << uint32(faction);
+        ch = true;
+       }
+      }
+     }
+    }
+    if(!ch)
+    *data << m_uint32Values[ index ];
+    }
                 else
                 {
                     // send in current format (float as float, uint32 as uint32)
@@ -1496,6 +1528,19 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
     return pCreature;
 }
 
+void Object::ForceValuesUpdateAtIndex(uint32 i)
+{
+ m_uint32Values_mirror[i] = GetUInt32Value(i) + 1; // makes server think the field changed
+ if(m_inWorld)
+ {
+  if(!m_objectUpdated)
+  {
+   ObjectAccessor::Instance().AddUpdateObject(this);
+   m_objectUpdated = true;
+  }
+ }
+}
+
 namespace MaNGOS
 {
     class NearUsedPosDo
diff --git a/src/game/Object.h b/src/game/Object.h
index fc01e3a..ab0fdbc 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -300,6 +300,9 @@ class MANGOS_DLL_SPEC Object
 
         virtual bool hasQuest(uint32 /* quest_id */) const { return false; }
         virtual bool hasInvolvedQuest(uint32 /* quest_id */) const { return false; }
+
+  void ForceValuesUpdateAtIndex(uint32);
+
     protected:
 
         Object ( );
diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp
index aa323c9..df83656 100644
--- a/src/game/TradeHandler.cpp
+++ b/src/game/TradeHandler.cpp
@@ -534,11 +534,11 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
         return;
     }
 
-    if(pOther->GetTeam() !=_player->GetTeam() )
+    /*if(pOther->GetTeam() !=_player->GetTeam() )
     {
         SendTradeStatus(TRADE_STATUS_WRONG_FACTION);
         return;
-    }
+    }*/
 
     if( pOther->GetDistance2d( _player ) > 10.0f )
     {

Thnx to False.Genesis for the original patch
Thnx to Frozen-in-Time for the trading fix part

Offline

#17 2009-05-14 18:00:34

Shin Darth
Cereals incoming
From: Italy
Registered: 2008-11-01
Posts: 140
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

I tried yours and give me this error:

fatal: corrupt patch at line 158


☭ Antifascist ☭

Visit UDB Forums for a playable DataBase for MaNGOS. Supports 3.3.5a.

Offline

#18 2009-05-14 18:09:12

patro
Seed
Registered: 2007-07-09
Posts: 15

Re: [PATCH] Horde &amp; Alliance grouping/trade

Editted my post, i don't know if this one works... i get some weird errors with GIT lately... i think it's time to format my pc again tongue

Offline

#19 2009-05-14 18:25:35

Shin Darth
Cereals incoming
From: Italy
Registered: 2008-11-01
Posts: 140
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

I tried again after your last edit and give me this error:

fatal: corrupt patch at line 153


☭ Antifascist ☭

Visit UDB Forums for a playable DataBase for MaNGOS. Supports 3.3.5a.

Offline

#20 2009-05-14 20:46:54

Shin Darth
Cereals incoming
From: Italy
Registered: 2008-11-01
Posts: 140
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

nobody can help me?


☭ Antifascist ☭

Visit UDB Forums for a playable DataBase for MaNGOS. Supports 3.3.5a.

Offline

#21 2009-05-14 21:27:56

cyrex
Cereals incoming
Registered: 2006-03-09
Posts: 268

Re: [PATCH] Horde &amp; Alliance grouping/trade

@Patro - Leave the patch file here, the coding style in mangos has some problems and does not show correct patch format sometimes.

Offline

#22 2009-05-15 02:59:31

Frozen-In-Time
Seed
Registered: 2008-11-03
Posts: 8
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

Patro Your patch works on 7817 as well. not that I'll be updating anytime soon. Just a personal thing. Anyway for all those who can't figure out why I coded that the way I did. I could not program in C++ a "Hello world" program without looking up instruction on the net. I try not to ask for help so I just do it myself usually.  I'm more of a puzzle guy. All the pieces were there. I just kept re-arranging them until it worked. As I said for my server version 7464. So yea.. I don't code C++.. but I can re-arrange yours. smile Anyway.. just glad it works now for more people. And on a side note.. I couldn't apply the patch using any tools of any kind. each time I had to cut and paste into the c files for it to work.

Have fun everybody! smile

P.S. Thanks Patro (not for the patch.. the other thing)

Offline

#23 2009-05-15 04:18:21

cyrex
Cereals incoming
Registered: 2006-03-09
Posts: 268

Re: [PATCH] Horde &amp; Alliance grouping/trade

@Frozen - Don´t worry some of the people here are in the mangos thing to learn how to program. So you are with the rest of the people that want to learn. Keep it up.

Offline

#24 2009-05-15 11:48:05

thorazi
Banned
Registered: 2006-09-27
Posts: 6

Re: [PATCH] Horde &amp; Alliance grouping/trade

Frozen-In-Time;71397 wrote:

This patch allows you to interact with any player horde or alliance as if they were your own faction. Only while in a group or a raid. This means trades, grouping, healing, enchanting in trade window and rez's work. I attempted to change the code so you could turn it on and off based on the mangosd.conf twoside options but for some reason I'm stuck. Anyway, here's the completed patch without conf checks. This patch was originated by False.Genesis. The ability to trade was possible due to help from Prefect, one of my server admin. Onwards to the patch. It is a git patch and my server version is 7464.

Hi there,

No offence for Frozen-In-Time, but i released a similar patch for my server [7693] which seem to be fully functional now.

Just few mofications of the core needed and no crash return on our test server (running for 1 month now). What we did :
When a group or raid is made, all the members of the group/raid takes the faction of their leader.
If group is disband or a member is removed, members take back their faction. Easy as 1-2-3.

Here is my branch : git://github.com/missproject/mangos.git interfactionpatch
http://github.com/missproject/mangos/tr … ctionpatch

For those who wants the little changes :

------------------------------ src/game/Group.cpp ------------------------------
index e6e01aa..1e70bc5 100644
@@ -296,6 +296,16 @@ bool Group::AddMember(const uint64 &guid, const char* name)
                 player->SetDifficulty(m_difficulty);
                 player->SendDungeonDifficulty(true);
             }
+            // Group Interfactions interactions (test)
+            if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
+            {
+                Group *group = player->GetGroup();
+                if(Player *leader = objmgr.GetPlayer(group->GetLeaderGUID()))
+                {
+                    player->setFactionForRace(leader->getRace());
+                    sLog.outDebug( "WORLD: Group Interfaction Interactions - Faction changed (AddMember)" );
+                }
+            }            
         }
         player->SetGroupUpdateFlag(GROUP_UPDATE_FULL);
         UpdatePlayerOutOfRange(player);
@@ -340,7 +350,12 @@ uint32 Group::RemoveMember(const uint64 &guid, const uint8 &method)
                 data << uint64(0) << uint64(0) << uint64(0);
                 player->GetSession()->SendPacket(&data);
             }
-
+            // Restore original faction if needed
+            if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
+            {
+                player->setFactionForRace(player->getRace());
+                sLog.outDebug( "WORLD: Group Interfaction Interactions - Restore original faction (RemoveMember)" );
+            }
             _homebindIfInstance(player);
         }
 
@@ -411,6 +411,12 @@ void Group::Disband(bool hideDestroy)
                 player->SetOriginalGroup(NULL);
             else
                 player->SetGroup(NULL);
+            // Restore original faction if needed
+            if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
+            {
+                player->setFactionForRace(player->getRace());
+                sLog.outDebug( "WORLD: Group Interfaction Interactions - Restore original faction (Disband)" );
+            }
         }
 
         // quest related GO state dependent from raid membership

Again, it's not for blaming or anything else, just if we can share each other knowledge, it could be a better patch.

Good Job FIT. ^_^


Vox Populi fr server CoAdmin. aka "The Machine"
Venez nous rendre une petite visite ;)

Offline

#25 2009-05-15 13:55:24

subhuman_bob
Cereals incoming
Registered: 2007-02-06
Posts: 104
Website

Re: [PATCH] Horde &amp; Alliance grouping/trade

Just few mofications of the core needed and no crash return on our test server (running for 1 month now). What we did :
When a group or raid is made, all the members of the group/raid takes the faction of their leader.
If group is disband or a member is removed, members take back their faction. Easy as 1-2-3.

While this may not crash, there will be other complications.
There are numerous quest start items that only drop for one faction, as well as many quests inside instance that are only meant for one faction.
If you start changing players' factions, you're going to mess this up.  If you let players change their faction at will (by joining a group of the opposite faction) pretty soon they're going to figure out they can exploit this to access extra quests.
Not to mention strolling through the opposite faction's capital cities unmolested.


Visit UDB Forums for a playable DataBase for MaNGOS.   Now with 3.2.2a data and a good source of rebirth in flames!
Note: forum address has been updated in my sig 16 Nov 2009
Millions of people worldwide suffer from insomnia, however I'm not gonna lose any sleep worrying about it.

Offline

Board footer

Powered by FluxBB