Jump to content

[patch] INTERFACTION Horde and Ally can not heal / buff each other anymore


Recommended Posts

Can't this be done as a switch? Ten "if(target->getRace() ==.....)" in a row has to be very inefficient.

patro did the following mod of False.Genesis' patch on that same line in this post:

                      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();
                              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;
                          }

I also noticed that this update has a few trailing spaces, some trailing tabs, and a lot of tabs instead of spaces for indent. This may not mean much (I wouldn't know as I'm not much of a C++ programmer, but I always use spaces and never trail spaces as that's the way I was taught in college), but it seems inconsistent with the MaNGOS code style.

Link to comment
Share on other sites

  • 39 years later...

This patch created by False.Genesis: Horde and Ally can not heal / buff each other anymore has been rehabilitated by Bloutix tested and validated on my server. Thank you a False.Genesis and Bloutix Transition

diff --git a/src/game/Group.cpp b/src/game/Group.cpp
index bf4d5d3..4773d73 100644
--- a/src/game/Group.cpp
+++ b/src/game/Group.cpp
@@ -338,10 +338,22 @@ bool Group::AddMember(const uint64 &guid, const char* name)

uint32 Group::RemoveMember(const uint64 &guid, const uint8 &method)
{
+    // Monkey
+    if (sWorld.getConfig(CONFIG_INTERFACTION)) {
+        BroadcastGroupUpdate();
+    }
+    // Monkey
+
    // 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
    {
        bool leaderChanged = _removeMember(guid);
+        
+    // Monkey
+    if (sWorld.getConfig(CONFIG_INTERFACTION)) {
+        // Player *player = objmgr.GetPlayer(guid);
+    }
+    // Monkey

        if(Player *player = objmgr.GetPlayer( guid ))
        {
@@ -1686,3 +1698,18 @@ void Group::_homebindIfInstance(Player *player)
            player->m_InstanceValid = false;
    }
}
+
+// Monkey
+void Group::BroadcastGroupUpdate(void)
+{
+    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);
+        }
+    }
+}
+// Monkey
\\ No newline at end of file
diff --git a/src/game/Group.h b/src/game/Group.h
index 0411036..6678ea0 100644
--- a/src/game/Group.h
+++ b/src/game/Group.h
@@ -336,6 +336,10 @@ class MANGOS_DLL_SPEC Group
        InstanceGroupBind* GetBoundInstance(Player* player);
        InstanceGroupBind* GetBoundInstance(Map* aMap);
        BoundInstancesMap& GetBoundInstances(Difficulty difficulty) { return m_boundInstances[difficulty]; }
+        
+        // Monkey
+        void BroadcastGroupUpdate(void);
+        // Monkey

    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 74c9e04..f7381cc 100644
--- a/src/game/GroupHandler.cpp
+++ b/src/game/GroupHandler.cpp
@@ -196,6 +196,14 @@ void WorldSession::HandleGroupAcceptOpcode( WorldPacket & /*recv_data*/ )
    if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
        return;

+    uint8 subgroup = group->GetMemberGroup(GetPlayer()->GetGUID());
+    // Monkey
+    if (sWorld.getConfig(CONFIG_INTERFACTION)) {
+        GetPlayer()->SetGroup(group, subgroup); // Defunct line added for test
+        group->BroadcastGroupUpdate();
+    }
+    // Monkey
+    
}

void WorldSession::HandleGroupDeclineOpcode( WorldPacket & /*recv_data*/ )
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 4c1ca17..b446a67 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -687,6 +687,54 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
                    else
                        *data << (m_uint32Values[ index ] & <UNIT_DYNFLAG_OTHER_TAGGER);
                }
+        // Monkey
+         else if(sWorld.getConfig(CONFIG_INTERFACTION) && (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)
+             {
+            DEBUG_LOG("-- VALUES_UPDATE: Sending '%s' the blue-group-fix from '%s' (faction)", target->GetName(), ((Player*)this)->GetName());
+            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);
+            ch = true;
+             }
+
+         }
+     }
+             if(!ch)
+             *data << m_uint32Values[ index ];
+
+         }
+        // Monkey
+
                else
                {
                    // send in current format (float as float, uint32 as uint32)
@@ -1664,6 +1712,22 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
    return pCreature;
}

+// Monkey
+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);
+            AddToClientUpdateList();
+            m_objectUpdated = true;
+        }
+    }
+}
+// Monkey
+
namespace MaNGOS
{
    class NearUsedPosDo
diff --git a/src/game/Object.h b/src/game/Object.h
index 4707f47..7525ad5 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -301,6 +301,11 @@ class MANGOS_DLL_SPEC Object

        virtual bool hasQuest(uint32 /* quest_id */) const { return false; }
        virtual bool hasInvolvedQuest(uint32 /* quest_id */) const { return false; }
+        
+        // Monkey
+        void ForceValuesUpdateAtIndex(uint32);
+        // Monkey
+
    protected:

        Object ( );
diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp
index 6662545..fcc3393 100644
--- a/src/game/TradeHandler.cpp
+++ b/src/game/TradeHandler.cpp
@@ -532,11 +532,13 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
        return;
    }

-    if (pOther->GetTeam() !=_player->GetTeam() )
+    //Monkey
+    if (!sWorld.getConfig(CONFIG_INTERFACTION) && pOther->GetTeam() !=_player->GetTeam() )
    {
        SendTradeStatus(TRADE_STATUS_WRONG_FACTION);
        return;
    }
+    //Monkey

    if (!pOther->IsWithinDistInMap(_player,10.0f,false))
    {
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 7811a95..a8db425 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -632,6 +632,14 @@ void World::LoadConfigSettings(bool reload)
    m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL]    = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Mail",false);
    m_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST]            = sConfig.GetBoolDefault("AllowTwoSide.WhoList", false);
    m_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND]          = sConfig.GetBoolDefault("AllowTwoSide.AddFriend", false);
+    
+    //Monkey
+    m_configs[CONFIG_INTERFACTION]   = sConfig.GetBoolDefault("Interfaction", false);
+    if(m_configs[CONFIG_INTERFACTION]) {
+        sLog.outString( "Interfaction Allowed" );
+    }
+    //Monkey
+    
    m_configs[CONFIG_STRICT_PLAYER_NAMES]                = sConfig.GetIntDefault ("StrictPlayerNames",  0);
    m_configs[CONFIG_STRICT_CHARTER_NAMES]               = sConfig.GetIntDefault ("StrictCharterNames", 0);
    m_configs[CONFIG_STRICT_PET_NAMES]                   = sConfig.GetIntDefault ("StrictPetNames",     0);
diff --git a/src/game/World.h b/src/game/World.h
index fd8fa61..1649e57 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -105,6 +105,7 @@ enum WorldConfigs
    CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL,
    CONFIG_ALLOW_TWO_SIDE_WHO_LIST,
    CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND,
+    CONFIG_INTERFACTION,
    CONFIG_STRICT_PLAYER_NAMES,
    CONFIG_STRICT_CHARTER_NAMES,
    CONFIG_STRICT_PET_NAMES,
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index 6751cee..ba91902 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -784,6 +784,11 @@ Motd = "Welcome to the Massive Network Game Object Server."
#        Default: 0 (Not allowed)
#                 1 (Allowed)
#
+#    Interfaction
+#        Allow Group, Raid, Heal, Buff, and other between both factions
+#        Default: 0 (Not Allowed)
+#                 1 (Allowed)
+#
#    TalentsInspecting
#        Allow other players see character talents in inspect dialog (Characters in Gamemaster mode can
#        inspect talents always)
@@ -801,6 +806,7 @@ AllowTwoSide.Interaction.Auction = 0
AllowTwoSide.Interaction.Mail = 0
AllowTwoSide.WhoList = 0
AllowTwoSide.AddFriend = 0
+Interfaction = 0
TalentsInspecting = 1

###################################################################################################################

Link to comment
Share on other sites

+ 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);

Can't this be done as a switch? Ten "if(target->getRace() ==.....)" in a row has to be very inefficient.

Link to comment
Share on other sites

this isnt my original patch... i am still using the patches below and they work fine for me:

in this order:

[9e2a511]

[b5aaef3]

[f0c5ac8]

1st commit is the original version, also posted here on the forum and modified by other people, 2nd commit adds some functionality i needed in a SD2 custom script (NPCs beeing shown as same faction as player), and the 3rd one fixes pets/totems of group members beeing shown as hostile.

hope this helped. if anyone feels like making a patch from this version.... do so.

EDIT: after recent core changes, here is a corrected version for a function used:

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;
       }
   }
}

Link to comment
Share on other sites

  • 5 months later...
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use