error: expected unqualified-id before 'if'

In file included from /home/gameserver/source/src/server/game/Battlegrounds/Battleground.cpp:26:0:
/home/gameserver/source/src/server/game/Miscellaneous/Formulas.h:232:17: error: expected unqualified-id before ‘if’
if (Guild* guild = player->GetGuild())
^
make[2]: *** [src/server/game/CMakeFiles/game.dir/Battlegrounds/Battleground.cpp.o] Error 1
make[1]: *** [src/server/game/CMakeFiles/game.dir/all] Error 2
make: *** [all] Error 2

[COLOR=rgb(0,0,0)]can’t compile a kernel server because of this error

[COLOR=rgb(0,0,0)]//Guild-Level-System (Bonus: MonsterKillXp)
[COLOR=rgb(0,0,0)]if (Guild* guild = player->GetGuild())
[COLOR=rgb(0,0,0)]{
[COLOR=rgb(0,0,0)]//GuildXP-Bonus
[COLOR=rgb(0,0,0)]if (guild->HasLevelForBonus(GUILD_BONUS_XP_1))
[COLOR=rgb(0,0,0)]gain += uint32(gain0.05 (f);
[COLOR=rgb(0,0,0)]if (guild->HasLevelForBonus(GUILD_BONUS_XP_2))
[COLOR=rgb(0,0,0)]gain += uint32(gain
0.1 f);
[COLOR=rgb(0,0,0)]}

[COLOR=rgb(0,0,0)]here is the code of the patch, what could be the problem?

Why is the f separated by a space from the float numbers?
Also remove the extra ( before the first f

Cant see what would cause the error in this code atm …

I believe we need the code right before the part you aready posted.

/*

  • Copyright © 2008-2014 TrinityCore <http://www.trinitycore.org/>
  • Copyright © 2005-2009 MaNGOS <http://getmangos.com/>
  • 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; either version 2 of the License, or (at your
  • option) any later version.
  • This program is distributed in the hope that it will be useful, but WITHOUT
  • ANY WARRANTY; 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, see <http://www.gnu.org/licenses/>.
    */

#ifndef TRINITY_FORMULAS_H
#define TRINITY_FORMULAS_H

#include “World.h”
#include “SharedDefines.h”
#include “ScriptMgr.h”
#include “Player.h”
#include “WorldSession.h”
#include “Guild.h”

namespace Trinity
{
namespace Honor
{
inline float hk_honor_at_level_f(uint8 level, float multiplier = 1.0f)
{
float honor = multiplier * level * 1.55f;
sScriptMgr->OnHonorCalculation(honor, level, multiplier);
return honor;
}

    inline uint32 hk_honor_at_level(uint8 level, float multiplier = 1.0f)
    {
        return uint32(ceil(hk_honor_at_level_f(level, multiplier)));
    }
} // namespace Trinity::Honor

namespace XP
{
    inline uint8 GetGrayLevel(uint8 pl_level)
    {
        uint8 level;

        if (pl_level <= 5)
            level = 0;
        else if (pl_level <= 39)
            level = pl_level - 5 - pl_level / 10;
        else if (pl_level <= 59)
            level = pl_level - 1 - pl_level / 5;
        else
            level = pl_level - 9;

        sScriptMgr->OnGrayLevelCalculation(level, pl_level);
        return level;
    }

    inline XPColorChar GetColorCode(uint8 pl_level, uint8 mob_level)
    {
        XPColorChar color;

        if (mob_level >= pl_level + 5)
            color = XP_RED;
        else if (mob_level >= pl_level + 3)
            color = XP_ORANGE;
        else if (mob_level >= pl_level - 2)
            color = XP_YELLOW;
        else if (mob_level > GetGrayLevel(pl_level))
            color = XP_GREEN;
        else
            color = XP_GRAY;

        sScriptMgr->OnColorCodeCalculation(color, pl_level, mob_level);
        return color;
    }

    inline uint8 GetZeroDifference(uint8 pl_level)
    {
        uint8 diff;

        if (pl_level < 8)
            diff = 5;
        else if (pl_level < 10)
            diff = 6;
        else if (pl_level < 12)
            diff = 7;
        else if (pl_level < 16)
            diff = 8;
        else if (pl_level < 20)
            diff = 9;
        else if (pl_level < 30)
            diff = 11;
        else if (pl_level < 40)
            diff = 12;
        else if (pl_level < 45)
            diff = 13;
        else if (pl_level < 50)
            diff = 14;
        else if (pl_level < 55)
            diff = 15;
        else if (pl_level < 60)
            diff = 16;
        else
            diff = 17;

        sScriptMgr->OnZeroDifferenceCalculation(diff, pl_level);
        return diff;
    }

    inline uint32 BaseGain(uint8 pl_level, uint8 mob_level, ContentLevels content)
    {
        uint32 baseGain;
        uint32 nBaseExp;

        switch (content)
        {
            case CONTENT_1_60:
                nBaseExp = 45;
                break;
            case CONTENT_61_70:
                nBaseExp = 235;
                break;
            case CONTENT_71_80:
                nBaseExp = 580;
                break;
            default:
                TC_LOG_ERROR("misc", "BaseGain: Unsupported content level %u", content);
                nBaseExp = 45;
                break;
        }

        if (mob_level >= pl_level)
        {
            uint8 nLevelDiff = mob_level - pl_level;
            if (nLevelDiff > 4)
                nLevelDiff = 4;

            baseGain = ((pl_level * 5 + nBaseExp) * (20 + nLevelDiff) / 10 + 1) / 2;
        }
        else
        {
            uint8 gray_level = GetGrayLevel(pl_level);
            if (mob_level > gray_level)
            {
                uint8 ZD = GetZeroDifference(pl_level);
                baseGain = (pl_level * 5 + nBaseExp) * (ZD + mob_level - pl_level) / ZD;
            }
            else
                baseGain = 0;
        }

        sScriptMgr->OnBaseGainCalculation(baseGain, pl_level, mob_level, content);
        return baseGain;
    }

    inline uint32 Gain(Player* player, Unit* u)
    {
        Creature* creature = u->ToCreature();
        uint32 gain = 0;

        if (!creature || (!creature->IsTotem() && !creature->IsPet() && !creature->IsCritter() &&
            !(creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL)))
        {
            float xpMod = 1.0f;

            gain = BaseGain(player->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(), u->GetZoneId()));

            if (gain && creature)
            {
                if (creature->isElite())
                {
                    // Elites in instances have a 2.75x XP bonus instead of the regular 2x world bonus.
                    if (u->GetMap() && u->GetMap()->IsDungeon())
                        xpMod *= 2.75f;
                    else
                        xpMod *= 2.0f;
                }

                xpMod *= creature->GetCreatureTemplate()->ModExperience;
            }

            float premium_rate = player->GetSession()->IsPremium() ? sWorld->getRate(RATE_XP_KILL_PREMIUM) : 1.0f;
            xpMod *= sWorld->getRate(RATE_XP_KILL);
            gain = uint32(gain * xpMod * premium_rate);
        }

        sScriptMgr->OnGainCalculation(gain, player, u);
        return gain;
    }             
    inline float xp_in_group_rate(uint32 count, bool isRaid)
    {
        float rate;

        if (isRaid)
        {
            // FIXME: Must apply decrease modifiers depending on raid size.
            rate = 1.0f;
        }
        else
        {
            switch (count)
            {
                case 0:
                case 1:
                case 2:
                    rate = 1.0f;
                    break;
                case 3:
                    rate = 1.166f;
                    break;
                case 4:
                    rate = 1.3f;
                    break;
                case 5:
                default:
                    rate = 1.4f;
            }
        }

        sScriptMgr->OnGroupRateCalculation(rate, count, isRaid);
        return rate;
    }
} // namespace Trinity::XP

} // namespace Trinity
//Guild-Level-System (Bonus: MonsterKillXp)

if (Guild* guild = player->GetGuild())
{
//GuildXP-Bonus
if (guild->HasLevelForBonus(GUILD_BONUS_XP_1))
gain += uint32(gain0.05f);
if (guild->HasLevelForBonus(GUILD_BONUS_XP_2))
gain += uint32(gain
0.1f);
}
#endif

at the very end

— Canned message start —

This thread is not related to the official Trinity codebase and was moved to the Custom Code section.

Please read the stickies next time.

— Canned message end —

[COLOR=rgb(0,0,0)]tell me how to fix it?

Is this a part of a patch or did you write this?

It seems the code you originally posted is in completely wrong place.

It should be inside some function, but it isnt.

Need more info

yes they are. it is part of the patch. patch on the pumping system of guilds. where in the code it should be, I’ve tried everything.

Then we need the patch to help further.

Otherwise we cant know where the patch was supposed to place the code.

You probably made a mistake when applying it. And you probably applied the patch manually.