how to use ifdef

Lets say we have this function in player.cpp

void Player::UpdateTriggerVisibility()
{
if (m_clientGUIDs.empty())
return;

if (!IsInWorld())
    return;

UpdateData udata;
WorldPacket packet;
for (GuidSet::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr)
{
    if (itr->IsCreature())
    {
        Creature* creature = GetMap()->GetCreature(*itr);
        // Update fields of triggers, transformed units or unselectable units (values dependent on GM state)
        if (!creature || (!creature->IsTrigger() && !creature->HasAuraType(SPELL_AURA_TRANSFORM) && !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)))
            continue;

        creature->SetFieldNotifyFlag(UF_FLAG_PUBLIC);
        creature->BuildValuesUpdateBlockForPlayer(&udata, this);
        creature->RemoveFieldNotifyFlag(UF_FLAG_PUBLIC);
    }
    else if (itr->IsGameObject())
    {
        GameObject* go = GetMap()->GetGameObject(*itr);
        if (!go)
            continue;

        go->SetFieldNotifyFlag(UF_FLAG_PUBLIC);
        go->BuildValuesUpdateBlockForPlayer(&udata, this);
        go->RemoveFieldNotifyFlag(UF_FLAG_PUBLIC);
    }
}

if (!udata.HasData())
    return;

udata.BuildPacket(&packet);
GetSession()->SendPacket(&packet);

}

And we included a custom file:

#include “CustomFunctions.h”

And in this custom header file we have the same function as in that player.cpp above but a bit edited.

How to disable that function in player.cpp using a bool to compile the function from “CustomFunctions.h” instead that one from player.cpp

I heard something about #ifdef #endif

That’s quite an odd thing to do, anyway, this should do the trick:

// CustomFunctions.h

#define CUSTOM_UPDATE_TRIGGER_VISIBILITY

void Player::UpdateTriggerVisibility()
{
}

// Player.cpp

#include “CustomFunctions.h”

#ifndef CUSTOM_UPDATE_TRIGGER_VISIBILITY
void Player::UpdateTriggerVisibility()
{
if (m_clientGUIDs.empty())
return;

}
#endif
Why would you do this… absolutely no idea.

If you wanted to avoid editing Player.cpp… you can’t, you have to change it anyway so why not do the change directly?

Thanks Nay, I do found a way not to edit the core directly for my custom modifications /emoticons/default_smile.png